Operators of JScript

Source: Internet
Author: User
Tags object bitwise comparison string
js|jscript| operations

JScript has a full range of operators, including arithmetic, logic, bits, assignments, and some other operators.

instanceof TD style= "BORDER:0;PADDING:0;" >
Calculated logical bit Operations Assigning values Miscellaneous          
Describe Symbol Describe Symbol Describe Symbol Describe Symbol Describe Symbol
negative value logic not ! bitwise reverse ~ Assignment = delete delete
increment less than < bitwise left << op assignment OP = typeof operator typeof
descending greater than > bitwise right-shift >> &NBSP; &NBSP; void void
multiplication <= unsigned right-move >>> &NBSP; &NBSP; instanceof
Division is greater than or equal to >= bitwise AND & &NBSP; &NBSP; new new
modulo operation equals bitwise XOR or ^ &NBSP; &NBSP; in in
addition does not equal != bitwise OR | &NBSP; &NBSP;   &NBSP;
subtraction Logic and && &NBSP; &NBSP;   &NBSP; &NBSP; &NBSP
&NBSP; &NBSP; logical OR | | &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;
&NBSP; &NBSP; condition (ternary operator)   &NBSP; &NBSP;   &NBSP; &NBSP;
&NBSP; &NBSP; comma   &NBSP; &NBSP;   &NBSP; &NBSP;
&NBSP; &NBSP; strictly equal   &NBSP; &NBSP;   &NBSP; &NBSP;
Not strictly equal !==

For example, the identity pair of the string "1" and the value 1 will result in a comparison of true. Strict equality does not cast different types of values, so it thinks that the string "1" is not the same as the value 1.

The basic string, numeric, and Boolean values are compared by value. If their values are the same, the comparison results are equal. Objects (including Array,Function,String,number,Boolean,Error, Date , and RegExp object) is compared by reference. Even if the two variables of these types have the same value, the comparison results are true only if they are exactly the same object.

For example:

Two basic strings with the same value. var string1 = "Hello";var string2 = "Hello"; Two objects with the same value  . var StringObject1 = new String(string1);var StringObject2 = new String(string2); The comparison result is  true . if (string1 == string2)       executes certain commands (that will be run). The comparison result is  false . if (StringObject1 == StringObject2)     // executes some commands (does not run). to compare  the value of an object,   or by using a   method. if (StringObject1.valueOf() == StringObject2)      // executes certain commands (that will be run).



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.