Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is (function e(t,n,r){ ...}) in Javascript? [duplicate]

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
}
)
like image 312
Hye Jin Avatar asked Sep 08 '16 19:09

Hye Jin


People also ask

What is function e in JavaScript?

"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.

What is function T JavaScript?

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.

What does apply () do in JavaScript?

The apply() method calls the specified function with a given this value, and arguments provided as an array (or an array-like object).

Are functions reusable in JavaScript?

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.


1 Answers

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.

like image 171
Caspar Wylie Avatar answered Oct 12 '22 21:10

Caspar Wylie