News for hackers. Stuff that matters.
Re:JavaScript Equality Minesweeper by simias on Monday September 17, 2018 @09:07AM (#18005539)
You'll have to show me one inventive and useful "ninja" trick revolving around the use of '=='. Sounds to me like the classic "my programming language is perfect and if you don't like it you're just too dumb to get it". This is pretty common among C developers in my experience but I didn't expect that from JS enthusiasts. What's next, PHP ninjas?
Re:JavaScript Equality Minesweeper by thalesmello on Monday September 17, 2018 @02:12PM (#18008388)
> You'll have to show me one inventive and useful "ninja" trick revolving around the use of '=='

Sure! For starters, you can write

    if (foo == null) { ... }
Because `undefined` gets coerced to `null`, it saves you from writing:

    if (foo === null || foo === undefined) { ... }
And, because it's shorter, it's even allowed by [some JS linters](https://standardjs.com/).

There you have your JS ninja trick to handle two distinct null types^TM .

Re:JavaScript Equality Minesweeper by simias on Monday September 17, 2018 @06:38PM (#18010731)
I would argue that it's only a "feature" because JS has this needless dichotomy between null and undefined so it's basically two issues cancelling each-other, but that sounds a lot like moving the goalpost so I'll concede the point.
Re:JavaScript Equality Minesweeper by thalesmello on Monday September 17, 2018 @07:01PM (#18010865)
Just to make sure, my "ninja trick" was meant in an ironic manner. In my opinion, it sucks JavaScript has two equality operators, and it's inexcusable for it to have two different null types. That fact that you can use the forer to check for the latter with less code doesn't make either okay in any sense.
Re:JavaScript Equality Minesweeper by paradite on Monday September 17, 2018 @10:55AM (#18006471)
>You'll have to show me one inventive and useful "ninja" trick revolving around the use of '=='.

1. I was making a generalized statement around JS, not specifically '=='. That's a misinterpretation of my statement.

>"my programming language is perfect"

2. I did not say JavaScript is perfect. That's a misinterpretation of my statement.

>"if you don't like it you're just too dumb to get it"

3. I did not say "if you don't like you're just too dumb." That's a misinterpretation of my statement.

Re:JavaScript Equality Minesweeper by thebuzzsaw on Monday September 17, 2018 @12:43PM (#18007512)
Did you stop to consider that maybe you conveyed these ideas regardless of whether you meant to?

JavaScript really _isn't_ all that expressive.

Re:JavaScript Equality Minesweeper by paradite on Monday September 17, 2018 @01:39PM (#18008056)
I tried my best, but I can't control how other people interpret it. That's what comments are for after all, to deal with information asymmetry like this.

I just don't get it. What's wrong with expressing my love for a language that I love? I am not even asking for anyone to switch to JS, just expressing my feel.

Re:JavaScript Equality Minesweeper by keymone on Monday September 17, 2018 @02:04PM (#18008314)
what's wrong with people disagreeing with you? isn't that what comments are (partly) for?
Re:JavaScript Equality Minesweeper by paradite on Monday September 17, 2018 @02:12PM (#18008393)
Yes. Maybe I am too conscious of people disagreeing with each other. It's actually very normal.

Thanks for pointing that out.

I think might be due to the downvotes somehow. It makes you wonder if you did something wrongly or it is simply people disagreeing with you.