What's the difference?
阿驼
阿驼 2017-12-06 17:00:30
0
2
1384

    add=function(){}

     function add(){}


阿驼
阿驼

我是一名前端

reply all(2)
有人@我

The functions are the same, but the meaning is a little different. The first is to define a variable and let the anonymous function assign the value.

The second is an ordinary non-anonymous function, which is the same when called. You should I know that the immediate execution function is somewhat similar to the anonymous one

In short, you can write it however you want, as long as it can be called

ringa_lee

These are the two most basic ways of function declaration.

var add = function () { }

This method defines the namespace as add to avoid duplication of method names in other class libraries.

function add() { }

This is a general way of writing, and it is easy to cause naming conflicts when using various plug-ins.


Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!