Analysis on the concepts and usage of JS anonymous functions and anonymous self-executing functions

亚连
Release: 2018-05-29 17:14:18
Original
1285 people have browsed it

This article mainly introduces the concepts and usage of JS anonymous functions and anonymous self-executing functions. It analyzes the concepts, functions, application scenarios and related usage skills of anonymous functions and anonymous self-executing functions in the form of examples. Friends in need can refer to it. Next

The examples in this article describe the concepts and usage of JS anonymous functions and anonymous self-executing functions. Share it with everyone for your reference, the details are as follows:

1. Common scenarios of anonymous functions

The anonymous function in js is a very common function type, compare Common scenarios:

 
Copy after login

The above shows the common usage scenarios of anonymous functions. (Note: querySelector is a new method of finding DOM elements in H5)

2. Anonymous self-executing function

As the name suggests, anonymous self-executing function first It is an anonymous function, but this function can be executed automatically by itself without the help of other elements.