JavaScript base four (call expressions and operators)

Source: Internet
Author: User
Tags object object

1. Invocation of functions and creation of objects

1) A pair of parentheses (): Used to invoke the function;

2) if new FN () is used before the function name, this is the creation of the object; It is divided into two steps: 1.new creates an empty object {},2. EXECUTE FN () specifically, the new object is passed as a value to this, and adding a property to this is the addition of a property to the newly created object.

3) If the constructor does not return a value, the newly created object is the current one, and if the constructor has a return value, the return value represents the newly created object.

2. Operators

1) About order: ① all 1-dollar operators and 3-yuan? : All from right to left ; ② most of the 2-dollar operators are left-to- right; ③= and the operators associated with = from right to left , ④ to the 2-operator Calculation Order from left to right

2) Several special operators: void (return undefined), typeof (return string), delete (delete property returns Boolean)

3) All number is floating-point type, so in the division and modulo operation, we can't expect to get some results. Like 2.1+1.8=3.9000000000000004,3+0.9=3.9.

3.+ operator

You can operate on number and string two types, and when string and number are evaluated, it takes precedence to String:1+2=3,"1" +2= "Three", "1" + "2" = "12"

    true+true=2,1+{}= "1[object object",2+null=2 (Null converted to 0),2+undefined=nan

4.===: strictly equal, type and value must be the same,null===undefined , 0===-0,0===+0,infinity===infinity

5. Comparison operators can only match number and string, conversions to not both types, first to base type (valueof), and then to ToString. Infinity is larger than any number,-infinity is smaller than any number. Always returns False if Nan participates in a comparison

6.String and number comparison , preferential conversion to number, such as "one" >2--true

7.in operator

  

8.instanceof: Determines whether an instance of an object, all objects is an instance of the objects. This is for objects where value types return False

9. Values that can be converted to false :null, undefined, 0,-0, NaN, and ""; Use!! You can convert any value to the corresponding Boolean value

10.eval Operator:JavaScript Converts a string into JavaScript code and returns the execution result. For example, eval ("3+2")-->5. Should try to avoid using.

11.typeof

  

12.delete: Removes an object's property or an array of elements if the property or element does not exist returns false.

JavaScript base four (call expressions and operators)

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.