Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I agree, this post is super-b, but it also shows why JS is the mess everybody knows it is. When you use a function as a constructor, the function creates an object and assigns as its __proto__ the value of the function's 'prototype', which is an object with the class' methods and that has an attribute 'constructor' that points back to the constructor function... and all that... for what? What purpose has this over-complex dance of references? Before trying to justify the current status quo, let's ask ourselves "could it be done easily?"

The answer is a resounding yes. Javascript is a prototype oriented language (nothing wrong with that) who is ashamed of being prototype oriented and wanted to look object (class) oriented, and that's a shame.

And of course, we have ECMA, a committee whose motto is "let's not change any past error no matter how flagrant it is, let's add just another layer of painting over it". That's why we have to live with hoisting and var/let, and crazy type conversions that are an affront to every living neuron in the universe, and typeof which return useless values, and yes, two comparison operators because the first one was worse than wrong.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: