Operation operators:
var a = 1+ "a" +1+1;console.log (a);
Code Execution procedure: 1+ string a+1+1 = 1a11.
var a = 1+1+ "a" +1;console.log (a);
The comparison operator calculates the method from left to right, and any number type is added to the string equal to the string, because A is a string of all equals 1a11.
var a = 1/0;console.log (a); var B = -1/0;console.log (b);
Result: Code execution process a equals infinity; b equals-infinity;
Infinity(无穷); Infinity虽然是个英文单词,但它是一个数字类型。
var a = 0/0;console.log (a);
Result: a equals nan;
NaN(Not a Number) 0除以0,除不了,不是个数是非数,但非数也算个数。
var a = 1%5;console.log (a);
The result equals: 1;
因为1除以5除不尽,余数1,所以等于1。
var a = 10%5;console.log (a);
Results: 0;
因为10除以5,等于2没有余数,所以等于0;
var a = 1;var B = A + + +1, (A + 1 is assigned to b,a itself plus 1) console.log (b);
Result: b equals 2.
因为“++” 如果放后边是等语句执行完再自身加1。
var a = 1;var B = ++a + 1; (a itself plus 1 equals 2, plus 1) console.log (b);
Result: b equals 3.
因为“++”如果放前边是先自身加1在执行语句。
var a = 1;var B = ++a + 1; (a itself plus 1 equals 2, plus 1) console.log (b);
Add:
a+=10 = = = A+10;
Priority: "=" The Weakest, "()" has the highest priority.
Little Practice One:
var a = (3-5/6 + 1)%2;var B = 3; b%= A + 3; document.write (a++); document.write (--b);
Little Exercise Two:
var a = 123;var B = 234;
The values of A and B are interchanged without creating new variables.
If there is a misunderstanding in the text, please point out the criticism ~ (≧▽≦)/~
JavaScript manipulation operators