Live data from Hacker News

ES6 Classes

javascriptjanuary.com

1–10 of 51 posts

Re: ES6 Classes

#2
I’m quite unfamiliar with OOP in JavaScript, so I’d appreciate if someone could chime in with how this differs from ES5: is this just syntactic sugar, or is there a semantic change as well?

Re: ES6 Classes

#3

I’m quite unfamiliar with OOP in JavaScript, so I’d appreciate if someone could chime in with how this differs from ES5: is this just syntactic sugar, or is there a semantic change as well?

It's just syntactic sugar. Still using prototypal inheritance under the hood.

Re: ES6 Classes

#4

I’m quite unfamiliar with OOP in JavaScript, so I’d appreciate if someone could chime in with how this differs from ES5: is this just syntactic sugar, or is there a semantic change as well?

From MDN[1]:

> JavaScript classes, introduced in ECMAScript 2015, are primarily syntactical sugar over JavaScript's existing prototype-based inheritance. The class syntax does not introduce a new object-oriented inheritance model to JavaScript.

[1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

Re: ES6 Classes

#7

I’m quite unfamiliar with OOP in JavaScript, so I’d appreciate if someone could chime in with how this differs from ES5: is this just syntactic sugar, or is there a semantic change as well?

From MDN[1]: > JavaScript classes, introduced in ECMAScript 2015, are primarily syntactical sugar over JavaScript's existing prototype-based inheritance. The class syntax does not introduce a new object-oriented inheritance model to JavaScript. [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

Do note though that there is a lot of syntax that is hidden with the `class` keyword. So even though it is primarily a syntactic sugar, it is by no means trivial.

Re: ES6 Classes

#9
I think ES6 classes are the worst of all worlds. I know people from a Java background really want classes in their Javascript but this is not that.

ES6 classes look like kind of sort of like a class but if you poke it at all you see lots of sharp edges and weird behaviours that make no sense unless you know what it's sugar for.

Re: ES6 Classes

#10

I really dislike the formatting with a space between function name and arguments function foo (a, b) { compared to the more common: function foo(a, b) {

For better or for worse this is part of the "Standard Style": https://www.npmjs.com/package/standard

It always seemed like an odd choice to me that would make people less likely to adopt it.

Post reply on HN