Js Function Type

Source: Internet
Author: User

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 ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.