Hacker News new | ask | show | jobs
by phpnode 4181 days ago
> those who don't use it are often forced to take it into account in their code; especially library authors.

No, `class` is syntactic sugar for the most common way of doing classes in ES3 and ES5. There is no semantic difference between:

    function Thing () {}

    Thing.prototype.greet = function () { alert("hello"); };
and

    class Thing {
      greet () {
        alert("hello");
      }
    }

They are the same, so it introduces no new traps for library authors.
1 comments

About the only thing that might be interesting to see is how constructor parameters are handled. With the prototyping system, I consider it to be a bug to initialize members in the constructor - if you always just call an 'init' method straight after construction (typically chained, much like in Objective C - var thing = new Thing().init(param); ) then protyping is very simple and does nothing surprising. It's only if you really really really want to have RAII that things become complicated...