In JavaScript there is a special data type---function type, and each function of JavaScript is an instance of the type of the functions. Because a function is an object, the function name is actually a pointer to a function object and is not bound to a function.
1<pre name= "code" class= "HTML" >functionsum (num1,num2)2 {3 returnNUM1 +num2;4 }5 6Alert (sum (10,10));// -7 varother =sum;8Alert (Other (10,10));// -9sum =NULL;TenAlert (Other (10,10));// -
The function name as a pointer to a function helps to understand why there is no concept of function overloading in ECMAScript
function sum (NUM1) {return num1 +100function sum (NUM1) {return num1 +200 ;} Alert (sum); // -
Although two functions with the same name are declared, the following function overrides the previous one, which is equivalent to the code below
function sum (NUM1) {return num1 +100function(NUM1) {return num1 +200 ;} Alert (sum); // -
When you create a second function, you actually overwrite the first function variable sum of the reference
Search Number:ruixin, or scan the QR code below, follow the blog public number, irregular brain the Internet: