Re:How Good C# Habits can Encourage Bad JavaScript Habits
by pmjordan on Thursday October 07, 2010 @05:37PM
(#1769645)
new is a keyword and has various other gotchas. The most egregious is probably is the silent but deadly failure when you forget it altogether:
Calling a free function binds the global object (window in the browser) to the implicit this parameter; assigning a URL to window.location is clearly quite an obvious bug, most cases of forgetting new when calling a constructor are much more subtle. Luckily, you can defend against it in the constructor's code:
I strongly recommend reading what Douglas Crockford has written on the topic of JavaScript, or watching his excellent videos. (this from someone who detests video as a medium of conveying this sort of info)
[ Parent
| on HN ]
There are no comments on this comment yet.