1.3 Primitive expressions
1. Direct Volume: 1.23//Digital Direct volume "Hello"//String Direct volume ... 2. Original expression of reserved words: TRUE//Return Boolean: TRUE/False NULL//return a value: null 3. Variable: I//returns the value of the variable i Sum//Returns the value of Sum
2. Object Initialization Expressions
var p={ x:2.3, y:-1.2 } //An object with 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 equality operators, or "= =") and no type conversions occur in the equality 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. For example: "1" ==true//The result is: True first converts the Boolean value true to the number 1, then performs a comparison of "1" ==1 and then the string "1" is converted to a number 11==1 because the values of two numbers are equal, so 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 is an example of an object:
var point={ x:1, y:2 } "X" in the point //result is true, Object point has a property named X "ToString" in the point //The result is true, the object inherits the ToString () method
6.instanceof operatorYou want to have an object on the left and a class example for the object on the right:
var d=new Date (); D instanceof Date; True d instanceof object //true, all objects are instances of object objects D instanceof number //false,d not 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 Expressions and operators