Three JavaScript Quirks That Java/C Developers Should Know

Hi.

I think the article had two issue, one of which was a simple typo. Based on that, I think your reply was a bit too hard for what is, in my opinion, only one real error.

First error outlined is that the first snippet doesn’t work properly. This was because the “if (false)” was actually an “if (true)”. You seem to understand JavaScript enough to easily spot that this was just a typo. So, perhaps, instead of writing 15 lines of text claiming how bad was the code and the article, I think you could have simply written: “Hey dude, there’s a typo in your article”. It’d have been more than enough. As a long-time writer (~130 articles to date) I have made a lot of such typos because it simply happens (as the author himself replied).

Second error is more severe and I apologize for that as the reviewer. The error is: “functions are a primitive type in JavaScript.” This is of course wrong and I’ve fixed the text.

Just to make it even more clear how your comment was too hard, I want to highlight this point:

You talk about JS being the first ‘mainstream’ language to implement closures. this shows that you or, have no idea what closures are, or with mainstream, you mean: ‘that I know’. The fist language implementing closures was somewhere around 1970 (if I remember correct). I wasn’t even born then…

Keeping in mind that mainstream languages today are pretty much JavaScript, Java, PHP, C#, C/C++, and Ruby, why asserting that JS has closures and is mainstream is wrong? To me this seems absolutely true. If you consider some old fashion language from the '70 as mainstream today, it’s fine. However, I’m pretty sure that most developers would agree with that statement.

Another example of how you overreacted:

You also state that functions (can) have properties. Not sure if this is such a special thing, it’s an object…

In JS functions are object and the author is targeting people coming from Java and C. Therefore completely beginners. With this in mind, isn’t explicitly asserting that functions can have properties worth mention? I thinks so.
Moreover, few days ago I was explaining exactly this concept to a friend of mine who is a pure Java developer and it’s just approaching JavaScript. He was shocked twice. The first time when I explained to him that functions in JavaScript are objects. The second time when I highlighted that because functions are objects they can have properties. If you, thanks to your knowledge, don’t find this concepts shocking then fine. But don’t assume that other developers wouldn’t benefit from it.

So, in conclusion, thank you for the two points but I think your reply was a bit exaggerated.