DEV Community

Discussion on: What do you wish to know about JavaScript when you were in university?

Collapse
amyth91 profile image
Amit Kamble

Hmmm, I'd say stuff like.

  1. String + number = concatenated number or string

    • '5' + 5 = 55
    • '5a' + 5 = '5a5'
  2. String - number = number or NaN

    • '5' - 5 = 0
    • '5a' - 5 = NaN

I've spent some time debugging an issue related to this and only found it a few years ago. Wish they had a class like 'JS - Fun facts'.

Collapse
itsmenatalie profile image
Natalia Author

yup! Great idea for some tricky examples and exercises! :D

Collapse
recss profile image
Kevin K. Johnson

Type coercion, if anyone is curious about the topic.

Collapse
leob profile image
leob

The famous example:

'10' + 1 === '101'
'10' - 1 === 9

:-)

(and the difference between == and === that's also a nice one)