Javascript ~~
Javascript ~~
What do the squigglies mean in javascript? I have tried googling for "Javascript ~~". All that comes up is what javascript is. Not what the ~~ mean in Javascript.
Re: Javascript ~~
The squiggle is a tilde. The tilde in javascript is used for bit shifting.
~(5.5) // => -6
~(-6) // => 5
~~5.5 // => 5 (same as Math.floor(5.5))
~~(-5.5) // => -5 (NOT the same as Math.floor(-5.5), which would give -6 )
http://stackoverflow.com/questions/5971 ... javascript
~(5.5) // => -6
~(-6) // => 5
~~5.5 // => 5 (same as Math.floor(5.5))
~~(-5.5) // => -5 (NOT the same as Math.floor(-5.5), which would give -6 )
http://stackoverflow.com/questions/5971 ... javascript
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Javascript ~~
Of course, in client-side JS, there are only a small handful of use cases for bitwise operations because JS does not handle binary data by default. Most of the time bitwise operations are useful for working directly with binary. It is an afterthought that they are in client-side JS at all. XOR could have some usage for encryption, but since the salt is in plain text on the client, what's the point?
The indelible lord of tl;dr