Skip to content

Instantly share code, notes, and snippets.

@pelid
Last active October 28, 2017 20:53
Show Gist options
  • Save pelid/49d145fae568c6124ca6cfb4816b458f to your computer and use it in GitHub Desktop.
Save pelid/49d145fae568c6124ca6cfb4816b458f to your computer and use it in GitHub Desktop.
JS headaches
> "5" - 3
2
> "5" + 3
"53" // почему ?!
>'5' + + '3'
"53" // кажется, здесь все логично
> '5' + - '3'
"5-3" // ан нет
> 'foo' + + 'foo'
"fooNaN" // потрясающе!
// и еще немного магии
> var x = 3;
> '5' + x - x
50
> '5' - x + x
5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment