This article analyzes the usage of function name.length attribute in Javascript. Share it for your reference, as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head> <title></title> <script type="text/javascript"> //Function name.length represents the number of parameters defined by the function. Here the sayHi function defines a parameter a, so output 1 //Different from arguments.length, arguments.length refers to the number of formal parameters passed in when external calls window.onload = function () { sayHi(); } function saysHi(a) { alert(sayHi.length); //Print out 1 } alert(sayHi.length); //It is also printed out 1 </script></head><body></body></html>For more information about JavaScript related content, please check out the special topics of this site: "Summary of JavaScript array operation techniques", "Summary of JavaScript mathematical operation usage methods", "Summary of JavaScript data structures and algorithm techniques", "Summary of JavaScript switching effects and techniques", "Summary of JavaScript search algorithm techniques", "Summary of JavaScript animation effects and techniques", "Summary of JavaScript errors and debugging techniques" and "Summary of JavaScript traversal algorithms and techniques"
I hope this article will be helpful to everyone's JavaScript programming.