JavaScript authoritative design--javascript expressions and operators (brief study note five)

Source: Internet
Author: User

1.3 Primitive expressions

1. Direct Volume: 1.23//Digital Direct quantity"Hello"//String Direct volume                        ...2. Original expression consisting of reserved words:true//Returns a Boolean value: Truefalse/ falseNULL//Returns a value: null3. Variables:I//return value of variable isum//Returns the value of Sum  2. Object Initialization Expressions    
var p={        x:2.3,        y:-1.2    }    //  An object that has two attribute members
 Object Direct amount can also be nested:    
var rea={        upp:{            x:2,            y:2        },        low:{            x:4,            y :5        }    }
  3. Left valueAn lvalue is an ancient term that means that an expression can only appear to the left of the assignment operator  4. Problems with value comparisonstwo values the problem of type conversion occurs when comparing. (This conversion is only for the equality operator, which is also the "= =")No type conversions occur in the congruent operator = = =. the rule to convert is: The object is converted to the original value, and then the comparison is made. The object is converted to the original value by the Tosrting () method or the ValueOf () method. Example: "1" ==true//result is: trueFirst, the Boolean value true is converted to the number 1 and then the comparison is performed"1" ==1then the string "1" is converted to the number 11==1because the values of two numbers are equal, the comparison result is true  5.in operatorThe in operator wants to have a string on the left or can be converted to a string, and hopefully the right side is an objectExample:   
var point={        x:1,        y:2    }    in point    // The result is true, where there is a property named X in Object point  " ToString " in point     // result is true, object inherits the ToString () method
  6.instanceof operatoryou want to have an object on the left and the object's class on the rightExample:    
var d=New  Date ();     instanceof Date;    // true    instanceof  Object    //True, all objects are instances of object    instanceof number      //  False,d is not a number object
 in order to evaluate an expression: O instanceof F. JavaScript calculates F.prototype First, then finds O in the prototype chain , and if found, then O is an instance of F, and the expression returns TRUE. If F.prototype is not in the prototype chain of O, then O is not an instance of F and returns false.

JavaScript-Authoritative design--javascript expressions and operators (brief study note five)

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.