All the numbers in 1.ECMAScript are stored in the IEEE-754 64-bit format, but the bitwise operators do not directly manipulate the 64-bit values. The first 64 bits are converted to 32-bit integers, then manipulated, and the results are then turned into 64 bits.
2. The first is the sign bit. The next 31 digits represent the value of the integer.
3. Use ToString (2) to print the binary, resulting in the binary being processed.
4. Bitwise non (NOT) ~, the number turns into binary, take the inverse. The equivalent of the operand first to negative 1;
5. Bitwise AND (and) &, two numbers of binary, there is a 0 result is 0, two are 1 is 1.
6. Bitwise OR (OR) |, there is a 1 result of 1, all 0 is 0.
7. Bitwise XOR (XOR) ^, the same is 0, the difference is 1;
8.== and! =, first convert and then compare. = = = and!== only compare not convert
9.label mates for, such as loop statements used. Used to jump out or end.
10. The argument property is hidden in the function and can be overridden. But JS is not overloaded.
When reading in place, suddenly want to test performance.
Own essays to test the applet.
var arr1 = new Array ();
var arr2 = new Array ();
var num = 0;
function Testnot () {
var str = "This was the letter Sigma";
var query = "Sigma";
do {
var timeStart1 = new Date ();
for (var i=0; i<10000000; i++) {
Str.indexof (query);
}
var timeEnd1 = new Date ();
var result1 = Timeend1-timestart1;
Arr1.push (RESULT1);
Console.log ("Str1.indexof (query):" + (TIMEEND1-TIMESTART1) + "MS");
var timeStart2 = new Date ();
for (var i=0; i<10000000; i++) {
~str.indexof (query);
}
var timeEnd2 = new Date ();
var result2 = Timeend2-timestart2;
Arr2.push (RESULT2);
Console.log ("~str1.indexof (query):" + (TIMEEND2-TIMESTART2) + "MS");
document.write ("General wording:" + result1+ "MS");
document.write ("Bit non-notation:" + result2+ "MS" + "<br>");
document.write ("=================================<br>");
num++;
}
while (NUM<10);
}
function Arrresult () {
var tempArr1 = 0;
var tempArr2 = 0;
var arr1length = arr1.length;
var arr2length = arr2.length;
for (var i=0; i<arr1length; i++) {
TEMPARR1 = Arr1[i] + tempArr1;
Console.log (TEMPARR1);
}
var arr1time = temparr1/arr1length;
document.write (the average time of the "+num+" of the ordinary notation: "+arr1time+" ms<br> ");
for (var i=0; i<arr2length; i++) {
TEMPARR2 = tempArr2 + arr2[i];
}
var arr2time = temparr2/arr2length;
document.write ("+num+" Time of the "non-written" Times: "+arr2time+" ms<br> ");
var contrastresult = Arr1time-arr2time;
document.write ("bit is not written faster than the normal wording:" +contrastresult+ "MS");
}