Home > Web Front-end > JS Tutorial > Commonly used anonymous functions

Commonly used anonymous functions

一个新手
Release: 2017-09-23 09:58:49
Original
1466 people have browsed it

Anonymous function

Anonymous function refers to a function without a name. Anonymous means that there is no name. If you write it directly, an error will be reported. There is no way to use it. There is no function defined. .

So, anonymous functions must be used in combination.

Usage 1, assign a value to a variable/object attribute (register event), and call it through the variable.

2, self-executing, self-calling.

3, passed as a parameter, parameter: function

;(function(){
console.log("呵呵");
})();
Copy after login

//Self-calling function, self-executing function: function declaration and function call together. It is customary to add a semicolon before

to prevent global variable pollution

The above is the detailed content of Commonly used anonymous functions. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template