1. A function is an object, and its name is a pointer to a function object. It is not bound to a function.
2. functions are not overloaded (function overloading: The same function name corresponds to the implementation of multiple functions .)
For Examle:
Function addnum (num) {return num + 10}
Function addnum (num) {return num + 20}
Addnum (10); // 30
3. function expressions and function names (the parser will take the lead in reading the function declaration, which is equivalent in other cases ).
4. A function as a value.
Sort the object array by an object attribute?
Copy codeThe Code is as follows: function compareFunction (properyName ){
Return function (obj1, obj2 ){
Var value1 = obj1 [propertyName];
Var value2 = obj2 [propertyName];
If (value1> value2 ){
Return 1;
} Else if {value1 <value2 }{
Return-1;
Else {
Return 0
}
}
}
Var data = [{name: "Jin", age: 24}, {name: "awei", 25}];
Data. sort (compareFunction ("name "));
Data [0]. name;
5. Internal Attributes of the function (arguments (callee), this );
6. attributes and methods of functions.
Attribute: length, prototype
Method: apply (), call ()