3 ms·
The worst one for me with JavaScript lately is trying to build some form of object orientation into my code. There's no canonical way to even implement a constr
by davedx 14y ago
The worst one for me with JavaScript lately is trying to build some form of object orientation into my code. There's no canonical way to even implement a constructor, for christ's sake. I haven't even dared to touch trying to use it for polymorphism. Or composition, for that matter. I'm staying the hell away from it for anything simpler than UI code.
If JavaScript was a nicer language I would be spending more time in Node.JS, but it's not, so I'm sticking with Rails.
- chris_wot 14y agoYou're forcing class based inheritance onto a language that specialises in prototypical inheritance... however, try http://tobyho.com/2010/11/22/javascript-constructors-and/ http://tobyho.com/2010/11/22/javascript-constructors-and/
- ufo 14y agoI actually don't mind this problem much, although that might be my "functional programming" bias. You only really need a "canonical" way to do things if you will be wanting to use features that depend on your classes being implemented in a predictable way. For example, class inheritance or implementing "super" method functionality. > I haven't even dared to touch trying to use it for polymorphism. Its not at hard as it sounds, since you have first class functions and closures. You can often handle functions directly instead of needing to create objects for everything.