I am a Developer, Blogger and Coffee addict. Java developer by profession, Q2A developer by addiction. This is my personal website where I write few stuff which could be useful for other developers.
vara=10,b=20;console.log("a = "+a+" , b = "+b);// a = 10 , b = 20b=[a,a=b][0];// swap the variables console.log("a = "+a+" , b = "+b);// a = 20 , b = 10
Truncate a value to a Integer in Javascript
Usage
Result
~~0.125
0
~~1
1
~~1.6
1
~~"2.59"
2
~~-2.8
-2
~~"Apple"
0
~~[]
0
~~null
0
Note -: It never returns NaN. If it fails, it just returns 0