JavaScript anonymous function, which means that a function does not have a name, let's list the test code
Copy Code code as follows:
/*
* Commonly common functions are like this
*/
function Debug (data) {
Console.log (data);
}
But some functions, it just happens to write this
Copy Code code as follows:
(function (x, y) {
Debug (x + y);
})
It's called the anonymous function.
Copy Code code as follows:
var fun = null;
(function () {
var test = function (x, y) {
Debug (x +y);
}
Fun =test;
})();
This time you enter fun in the console of the browser and you will find that it prints out function (x, y) {debug (x +y);} Well obviously this is a function if you enter fun (1, 2); This is the time to print out 3. Let's look at the types below.
Copy Code code as follows:
var U = {
uid:32812,
Gamelist: (function () {
var list = new Array ();
list[7]= ' 360 ';
List[6]= ' Baidu ';
if (list!= ' null ') {
return list;
}
}
)(),
ServerList: (function () {
var list = new Array ();
list[1188]= ' 360 ';
List[1165]= ' Baidu ';
if (list!= ' null ') {
return list;
}
}
)(),
Channellist: (function () {
var list = new Array ();
list[9]= ' Hand travel net ';
return list;
}
)(),
Searchname:function (T,id) {
if (id = = False | |/^\d+$/.test (id) = = False) {
Return ' This is a function ';
}else if (eval (t). hasOwnProperty (ID)) {
return eval (t) [id];
}else{
return ' test ';
}
}
};
This time you enter u in the console and you will find that it is an array. u[' searchname ' is a function, u[' qudaolist '] returns a result.