I found the following short and tricky codes forDouble Bitwise NOT (~~) - James Padolseyhttp://james.padolsey.com/javascript/double-bitwise-not/Web Reflection: two simple JavaScript tricks (old but always useful )http://webreflection.blogspot.com/2008/06/two-simple-tricks-in-javascript-olds.htmldouble bitwiseMath.round(v)=== ~~vMath.floor(v)=== ~~v(if v> 0)isNaN(Number(v)) ? 0 : Number(v)=== ~~v(if v does not float )double nonBoolean(v)=== !!v( !Boolean(v)=== !v)bitwise shiftMath.round(v / 2)=== v >> 1Math.round(v)=== v >> 0single bitwise nota.indexOf(v) !== -1=== ~a.indexOf(v)Are there any shorter or more complex codes in javascript?
Math.round(v)
~~v
Math.floor(v)
isNaN(Number(v)) ? 0 : Number(v)
Boolean(v)
!!v
!Boolean(v)
!v
Math.round(v / 2)
v >> 1
v >> 0
a.indexOf(v) !== -1
~a.indexOf(v)
"" Javascript. Google , .
http://resnet.uoregon.edu/~gurney_j/jmpc/bitwise.html
http://lab.polygonal.de/2007/05/10/bitwise-gems-fast-integer-math/
http://www.beyond3d.com/content/articles/8/