DEV Community

Cover image for Syntax Trap #001
Tabea
Tabea

Posted on

Syntax Trap #001

Hey there πŸ‘‹

I've spent a lot of time learning the details of JavaScript and stumbled across lots of surprising gotchas that only became clear after understanding what's going on under the hood.

I plan to post one of these each day (or so) and would love to get discussions around the specific "problems".

Here's the first: What's the result?

const num = '5';
console.log("5" * 4 + num);
Enter fullscreen mode Exit fullscreen mode
  1. Error
  2. 25
  3. 205
  4. 55555

Easy, right :)
.. said some of my coworkers, before getting it wrong πŸ€“

Top comments (0)