1. Turn the rounding into a numerical type:
1 console.log ("10.340" |); 102 Console.log ("10.560" ^0); 103 Console.log ( -2.25|0); -24 Console.log (~~-2.25); -2
2. Date to Value:
var d = +new Date (); 1499149610813
3. Random Code:
1 Math.random (). toString (+). substring (2); 14-bit: adfe8d8800e042 math.random (). ToString ($). substring (2); 11-bit: Yc290rtrpij
4. Exchange value:
1 a= [B, b=a][0];
5. Condition Judgment:
1 var a = b && 1; 2 //equivalent to 3 if (b) {4 a = 1 } 6 7 var a = B | | 1; 8 //equivalent to 9 if (b) A = b;10 else a = 1;
6. Empty the array:
1 arr.length=0; Set array length empty array
7. Force the Boolean value:
1 var a= ""; 2!! A; Double exclamation points to really convert the variable to the corresponding Boolean value, the first exclamation point is converted to a Boolean value, but this operation gets its inverse value, and then take the inverse operation to get its corresponding true Boolean value
8. Application of the displacement character:
1 var num = >> 1; Equivalent to 10/2, but more efficient 2 console.log (num)//5;3 4 var num = 2 << 3; 2 of Four Square 5 console.log (num)//16;
JavaScript Kinky Tricks