News for hackers. Stuff that matters.
Re:JavaScript Coercions Grid by tuesdayrain on Saturday March 30, 2019 @10:26AM (#19529563)
I'm not entirely sure why all of this even exists, it seems like it creates a lot of potential for bugs. I've been developing in JS for years and I've never intentionally used type coercion. If I ever needed to operate on multiple types I would always explicitly cast them to the correct type beforehand.
Re:JavaScript Coercions Grid by saghm on Saturday March 30, 2019 @10:57AM (#19529716)
I think it's mostly just backwards compatibility at this point; unlike with server-side languages, you can't just bump the major version and let people switch to it at their own pace. No browser is motivated to make breaking changes because there's a chance that they could break existing sites, and from a user's perspective, all they'll see is that site Foo works in Browser A but not Browser B, so Browser A will presumably lose some market share.
Re:JavaScript Coercions Grid by gambler on Saturday March 30, 2019 @12:14PM (#19530154)
>unlike with server-side languages, you can't just bump the major version and let people switch to it at their own pace.

That's what strict mode was for.

Re:JavaScript Coercions Grid by saghm on Sunday March 31, 2019 @05:14PM (#19538438)
I'm not super knowledgeable about JS, but my guess is that most of the stuff described in the article probably don't happen under strict mode, right?
Re:JavaScript Coercions Grid by gambler on Wednesday April 03, 2019 @11:41AM (#19564279)
Correct.
Re:JavaScript Coercions Grid by baddox on Saturday March 30, 2019 @01:21PM (#19530584)
Using variables in Boolean expressions (to check whether the value exists) is the one place I (and probably most JS developers) use type coercion. Which can still bite you, especially if you have a zero that you expect to be considered a present value.