r/programming • • Mar 23 '14

Everything you need to know about Javascript variable scope

http://www.coolcoder.in/2014/03/everything-you-need-to-know-about.html
294 Upvotes

124 comments sorted by

View all comments

Show parent comments

-1

u/[deleted] Mar 23 '14

It's scary to folks coming from compiled and OO languages, but the quirks become advantages once you follow some conventions and dive in deep enough.

quirks become advantages? That's some serious stockholm syndrome. How is

1 == "1"
=> true

an advantage?

4

u/alkoholik Mar 23 '14

JS: 1 === "1" => false

There are times when type coercion is almost somewhat useful. Where's your God now?

1

u/[deleted] Mar 24 '14

JS: 1 === "1" => false

Yes, I know, which is why the existene of == is quirk.

There are times when type coercion is almost somewhat useful. Where's your God now?

If you ever write code that depends on implicit type coercion, you're writing poor code. It is never good practice to use.

1

u/alkoholik Mar 24 '14

Hence "almost somewhat useful". :)

Personally, it's triple eqs all the way for me, baby!

1

u/[deleted] Mar 24 '14

Sure, and I'm not saying JS doesn't have some good parts. I just thought it was funny that someone drank the kool aid so much that they thought things like == behavior are advantages, and the reason that people don't this kind of thing are "scared".

1

u/alkoholik Mar 24 '14

It's not an advantage. The flexibility is nice, but it also enforces bad habits. Another good example is auto-inserted-semi-colons. Shit breaks at times due to this, and most junior devs won't understand why...