JS function type _javascript tips

Source: Internet
Author: User
1. A function is an object, and a function name is a pointer to a function object and is not bound to a function.
2. Functions are not overloaded (function Overload: 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 expression and function reputation (the parser takes the lead in reading function declarations, others are equivalent).
4. function as a value.
Sort the array of objects by an object property?
Copy Code code 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 properties of the function (arguments (callee), this);
6. Properties and methods of the function.
Attributes: Length, prototype
Methods: 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.