JavaScript basic Syntax &3

Source: Internet
Author: User
Tags logical operators

1.window. Json
Json.parse (text [, Reviver]); = = text: A valid JSON string is required; Reviver: optional, handler function; returns null or undefined when the member of text is removed; typically used to convert a string to a JSON object;
Json.stringify (); = = Converts the JSON object to a string;
2. Expressions && operators;
An arithmetic expression:
+ = Plus, strings and numbers are added to return strings, leading + converts to numbers; + ' 1a ' = 1; ' a ' + 1 = ' A1 ';
-= Minus, will automatically do digital conversion;
* = Multiply
/= except
% = to take surplus; = = 5%2 = 1;
++/--+ = increment/Decrement The last calculation is retained by the previous result, and the a++ returns A; the result is a+1; ++a will return a+1 results also for a+1;
Bitwise operators:
~ = to take the operand negative, and then minus one to = =-9;
& = As long as any one is 0 & the result of the operation is 0.
Example: 1 & 2 = = 0; & = 0;
8 & 1 = = 0; & (+ 0000) = 0;
9 & 1 = = 1; 1001 & 0001 = 1;
| = | The difference with & is that if any one of the operands in the corresponding bit is 1 then the result is 1;
Example: 1 | 2 = = = 3; 01 | Ten = 3;
9 | 2 = = = 11; 1001 | =>1011 = 11;
^ = + ^ Operator with | Similar, but a little different is that if two operation bits are 1, the result is 0;
Example: 1 ^ 2 = = 3; 3;
9 ^ 1 = = 8; 1001 ^ n = 8;
<< = moves to the left, the bits that exceed are lost, and the vacated bits are 0 1 << 2 = = 4; 1 = 4
>> = moves to the right, the bits that exceed will be lost, and the vacated bits complement 0 >> 2 = = 2;1010 = 2; Any decimal >> 0 can be rounded;
>>> (unsigned Right shift)
Sometimes there are problems: for example: 1.7976931348623157e+308 >> 5; = 1.7976931348623157e+308 << 5; Do not use scientific notation;
PS: When using parseint () to process a number, convert the number to a string after processing;
Logical operators:
&&
Returns false/0/'/nan/null/undefined when the first operand is false/0/'/nan/null/undefined
Other, returns the second operand (not necessarily a Boolean)
The second operand (expression) is no longer evaluated when a short-circuit operation occurs, that is, the first operator is false
||
The second operand is returned when the first operand is false/0/'/nan/null/undefined;
When the first operand is true, it is returned directly;
Prosperous short-circuit operation, when the first operator is true, the second operand is no longer computed;
! = = Take counter
Empty string/numeric 0/null/nan/undefined, return True
Other, return False
The application!!, equivalent to converting the operand to a Boolean
Relational Expressions:
== \ ===; = = = no comparison type; = = = Comparison type;
!= \ !==; =
The same as the return value is a Boolean type (True/false)
null and undefined equal
NaN and any value comparisons are not equal
If there is an operand of Boolean, convert the True/false to 1/0
String and number comparison, the string is converted to a number
If one operand is an object and the other is not an object, then the object's. ValueOf () method is called, and the resulting value is compared with the above rule.
>=,> <=,< = There's nothing in math to say.
in = Whether in the object example: Var key in obj;
instanceof = The object is not an instance of another object;

JavaScript basic Syntax &3

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.