[英]Javascript: anonymous function with jQuery as parameter
I'm looking at a JavaScript plug-in for the first time, their instruction directs one to include referencing the jQuery API in the head of a HTML document. 我是第一次使用JavaScript插件,它们的指令指导一个人在HTML文档的头部包含引用jQuery API的信息。
The first line of JS in their plug-in entails what I've come to understand is a self-invoking anonymous function JS插件的第一行包含了我所了解的是一个自调用匿名函数
(function($) {...} )(JQuery);
// ... represents many lines of script
I've only been working with JS for about a year. 我只在JS工作了大约一年。 Thanks!
谢谢!
function a(){} -> this return a function object 函数a(){}->返回函数对象
(function a(){}) -> this is a function object (函数a(){})->这是一个函数对象
(function a(){})(...) -> call that function object to run with or without args (function a(){})(...)->调用该函数对象以使用或不使用args进行运行
So it's just like a function call after all. 毕竟,这就像一个函数调用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.