Javascript notes-Basic Knowledge

Source: Internet
Author: User
Tags javascript array

1. Each function object has a Length attribute, indicating the parameter format that the function expects to receive.

Unlike the arguments of the function, arguments. Length indicates the parameter format actually received by the function.


2. There are five original data types in javascript: undefined, null, Boolean, number, and string.


3. The undefined data type has only one value: undefined.


4. The NULL data type has only one value: null.


5. boolean data types include true and false.


6. There is no char data type in JavaScript.


7. typeof is a unary operator followed by the variable name. It is used to obtain the data type of the variable,

The returned values include undefined, Boolean, number, string, and object.


8. In JavaScript, if the function does not declare the return value, undefined is returned.


9. Relationship between null and undefined: Undefined is actually derived from null.


10. Forced type conversion: There are three types of forced type conversion in javascript:

Boolean (value), number (value), string (value ).


11. In JavaScript, for variables defined in the function, adding var indicates local variables, and without var indicates global variables.


12. In JavaScript, all objects are inherited from object objects.

Properties in the object cannot be enumerated (propertyisenumerable returns false), so it cannot

Through... In statement.


13. In JavaScript, You can dynamically add or delete object attributes.

VaR object = new object ();
// Alert (object. username );
Object ["username"] = "shengsiyuan ";
Alert (object. username );
Delete object. Username; // The username attribute has been deleted from the object.
Alert (object. username );


14. The second method for defining objects in javascript:

// The most common way to define objects in Javascript
VaR object = {Username: "zhangsan", password: 123 };

Alert (object. username );
Alert (object. Password );


15. For the sort method of JavaScript array,

It will first convert the content to be sorted into a string (call the tostring () method ),

Sort strings sequentially.


16. Anonymous Functions

VaR array = [1, 3, 25];

// Anonymous Function
Array. Sort (function (num1, num2)
{
VaR temp1 = parseint (num1 );
VaR temp2 = parseint (num2 );

If (temp1 <temp2)
{
Return-1;
}
Else if (temp1 = temp2)
{
Return 0;
}
Else
{
Return 1;
}
}
);

Alert (array );

Related Article

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.