Home>Article>Web Front-end> What are the ways to call functions in javascript
Methods for calling functions in JavaScript: 1. Use the "Object.Function Name()" statement to call; 2. Use "Function Name().call(Caller, Parameter 1, Parameter 2, ... ..);" statement call; 3. Use the "function name().apply(caller, parameter array);" statement call.
The operating environment of this tutorial: Windows 7 system, JavaScript version 1.8.5, Dell G3 computer.
Named functions
Anonymous function (recommended)
Use the function class to construct an anonymous function
Format:new Function (('Parameter list'), ('Parameter list'), ('Function execution body'));
Note:
Column: Use of named functions
Global variables in functions can be accessed directly
Functions in functions need to be called first before they can be accessed
Column: Implement function calls within functions (calls of local functions)
Result: Laoli is so cute, he is not a woman
Column: implement three calls
Column: in the array Function call
Result: [Related recommendations:The above is the detailed content of What are the ways to call functions in javascript. For more information, please follow other related articles on the PHP Chinese website!