I am studying the List.js Framework. This is a starting code. If I remove it(even remove the surrounding "()" of function e), Code is not working.
What is this? I think it is already defined in Javascript method.
(function e(t,n,r){
function s(o,u){
if(!n[o]){
if(!t[o]){
var a=typeof require=="function"&&require;
if(!u&&a) return a(o,!0);
if(i)return i(o,!0);
var f=new Error("Cannot find module '"+o+"'");
throw f.code="MODULE_NOT_FOUND",f
}
var l=n[o]={exports:{}};
t[o][0].call(l.exports,function(e){
var n=t[o][1][e];
return s(n?n:e)
},l,l.exports,e,t,n,r)
}
return n[o].exports
}
var i=typeof require=="function"&&require;
for(var o=0;o<r.length;o++)
s(r[o]);
return s
}
)
"function(e)" is the event handling function (on event, object is created). "e" is the object handler (object is made accessible). "preventDefault()" is a method (function) provided by the object.
A function in JavaScript is similar to a procedure—a set of statements that performs a task or calculates a value, but for a procedure to qualify as a function, it should take some input and return an output where there is some obvious relationship between the input and the output.
The apply() method calls the specified function with a given this value, and arguments provided as an array (or an array-like object).
Another essential concept in coding is functions, which allow you to store a piece of code that does a single task inside a defined block, and then call that code whenever you need it using a single short command — rather than having to type out the same code multiple times.
It is a minified version of javascript (which does not make any actual difference, other than file size, and readability) so really, it is actually very much normal javascript code. However, written without the non compulsory syntax, unneeded whitespace, shorter variable names, all in efforts to reduce file transfer time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With