Home  >  Article  >  Web Front-end  >  Introduction to JavaScript advanced syntax_javascript skills

Introduction to JavaScript advanced syntax_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:51:301116browse

(function($){})(jQuery);

It’s actually relatively simple, you need to understand a few concepts:

1. (), in JavaScript () means executing a method, such as:

function x(){

alert("xxx");

}

var a = x; // No call, a is a function

var a = x(); //The function is called, and the value of a is the result of the call: undefined

2. jQuery is a jQuery object, which means that when calling a function, a parameter passed in is a jQuery object.

There’s nothing to say about this

3. (function($){}) This is an anonymous function, the formal parameter is $, and parentheses are definitely required.

You can understand it at a glance. The above formula is equivalent to

var f = function($){};

f(jQuery);

Look at it now, it’s neither simple nor weird...

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn