The function scope in JavaScript exists to "hide" variables and functions. It conforms to our principle of least privilege. Another benefit is that it can avoid conflicts with identifiers of the same name. Today we will mainly talk about this immediate execution function. Before this review, anonymous functions and named functions, whether anonymous or named, are function declarations for function expressions. They must have a name, otherwise an error will be reported function foo(){ //Function declaration //...}Here I will explain an Easter egg. Maybe you always like to use some sample codes when I write articles. Words like fn, func, demo, foo, bar, foobar fn and func are the abbreviations of function Demo is the abbreviation of the word demonstration "example" foo, bar, foobar we have
1. Detailed explanation of JavaScript anonymous, named functions and immediate execution functions IIFE
Introduction: The function scope in JavaScript exists to "hide" variables and functions in line with our principle of least privilege. Another benefit is that it can avoid identifiers with the same name. Today we mainly talk about this immediate execution function. Before that, we review anonymous functions and named functions. Whether anonymous or named, anonymous functions and named functions are function declarations for function expressions, so they must have names. Otherwise, an error will be reported function foo(){ //Function declaration //...} This
2. C#Optional parameters and named parameters
Introduction: C# optional parameters and named parameters
3. javascript Recommended four calling methods for named functions, page 1/3_javascript skills
Introduction: There is no difference in the execution results of the four methods. But if the function has a return value, you may be a little disappointed when calling it with new.
Introduction: The various calling methods of named functions have been introduced in the previous section. This article looks at how to determine whether a function is called by new or by other methods.
5. Summary of various calling methods of named functions in JavaScript_javascript skills
Introduction: This article It mainly introduces a summary of the various calling methods of named functions in JavaScript. This article summarizes 4 methods. Friends in need can refer to
[Related Q&A recommendations]:
javascript - Regarding the selection of dispatch and callback in Vue
javascript - Regarding the reassignment of the function itself within the named IIFE?
c++ - Unnamed namespace cannot be placed in .h
javascript - Vue component named slot traversal problem
javascript - Named functions cannot be accessed outside the function
The above is the detailed content of 5 recommended articles about naming. For more information, please follow other related articles on the PHP Chinese website!