DEV Community

JavaScript can do that?

Yaser Adel Mehraban on June 26, 2019

You might be wondering why I am writing less these days. I assure you, it's not because I am getting lazy (I am ATM 🤩), it's just that I am on a lo...
Collapse
 
cubiclebuddha profile image
Cubicle Buddha

This is one of the many great reasons to use TypeScript. It's not that TypeScript won't let you do these strange things... it's just that it's like "did you know that you're about to automatically coerce your number to a string?"

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

I'm not sure typescript will save you from JavaScript itself maybe 50% of the above insanity.

Collapse
 
tarascz profile image
Jiří Tarašovič

The rest of 50% you can avoid by using '===' instead of '==' as it's recommended everywhere.

Thread Thread
 
adam_cyclones profile image
Adam Crockett 🌀

I always assumed everyone knew that 😆. It's been a while since I started.

Collapse
 
nssimeonov profile image
Templar++

No amount of TypeScript can save you from JS quirks, but at least Saint A. Hejlsberg did a good job helping as much as he could...

Collapse
 
stephangalea profile image
Stephan Galea

These are all fun and games. Until someone asks them in a test during an interview or a programming test and you are one that never met such things because you have enough logic to never end up with such code :p

Collapse
 
yashints profile image
Yaser Adel Mehraban

If I ever got asked one of these in an interview, I'd question the company's approach to attract candidates. And it probably isn't a good place to work either 🧐

Collapse
 
nssimeonov profile image
Templar++

And if someone asks you anything like this during an interview, the only valid reply is that you're sane enough not to use it. Then stand up and walk out of... correction - run away as fast as possible.

Collapse
 
stereobooster profile image
stereobooster • Edited

I'm not sure if the article meant to be sarcasm or not. When I read "HTML can do that?" - 😲🤩, when I read "JS can do that?" - 🤨😞.

Collapse
 
sandeepbalachandran profile image
Sandeep Balachandran

Does not matter. Its another version of " __ can do that?". What matter the most is "can you do that?"

Collapse
 
stereobooster profile image
stereobooster

I have no idea what you meant

Thread Thread
 
yashints profile image
Yaser Adel Mehraban

I don't think comparison between posts is a valid thing to do, everyone has different perspectives, and if this has upset you, then it means you probably need to spend a bit more time reading about JS.
In another perspective, some of these might be the cause of a bug in your code base and knowing why it's happening will definitely help you

Thread Thread
 
stereobooster profile image
stereobooster

So it's not sarcasm just coincidence in titles. The only thing I wanted to ask 👌

Collapse
 
nssimeonov profile image
Templar++

The only valid reply to "... can do that?" is this meme:

memegenerator.net/img/instances/57...

Collapse
 
raisaugat profile image
Saugat Rai

Mind === blown.
Great article

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

I didn't know some of these and now I have more ambition to tease my colleagues

Collapse
 
yashints profile image
Yaser Adel Mehraban

😂

Collapse
 
stefanbalan profile image
Stefan Balan

This is NOT a 3 minute read! :)
It's a 3 minute read plus 5 minutes of "let me open up the console real quick".

Collapse
 
elanandkumar profile image
Anand Kumar

Great article.

Collapse
 
yashints profile image
Yaser Adel Mehraban

Thanks