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

Who told you that JavaScript was "not really OO"?


It doesn't have classes or inheritance.


You don't count this as inheritance? Also, classes aren't required for OOP.

    function Parent() {
        // somestuff
    }
    function Child() {
        Parent.call(this);
    }
    Child.prototype = new Parent();
    Child.prototype.constructor = Child


I call that prototypical construction. The point is, it's hardly java.


Neither classes nor inheritance are necessary for OOP. A good read on this topic: http://wcook.blogspot.de/2012/07/proposal-for-simplified-mod...

Btw, you can also do classes with JavaScript: http://mootools.net/docs/core/Class/Class

JavaScript's prototype-based OOP is a superset of class-based OOP.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

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

Search: