DEV Community

loading...

Discussion on: 17 Pro JavaScript tricks you didn't know

Collapse
aralroca profile image
Aral Roca

Same for

if(a!=123) // before // NOOBS

if(a^123) // after // PRO
Enter fullscreen mode Exit fullscreen mode

a^123 is not very clean IMO. Maybe a better one will be if(a !== 123)

Collapse
aralroca profile image
Aral Roca

And it's not correct for decimal numbers.

Boolean(122^123) // true
Boolean(123.1^123) // false -> is not correct, should be true 123.1 !== 123
Boolean(123^123) // false
Enter fullscreen mode Exit fullscreen mode

Much better to use the !== operator.

Collapse
nucliweb profile image
Joan León

IMHO

if(a!=123) // before // NOOBS

if(a!==123) // after // PRO
Enter fullscreen mode Exit fullscreen mode
Collapse
migueloop profile image
Miguel Ruiz

Also we should think this is something that someone who comes from another Programming Language won't understand easily, just for saving 1 character