Live data from Hacker News

ES6 Cheatsheet

github.com

51–60 of 89 posts

Re: ES6 Cheatsheet

#51
post #41

Is there a similar thing for coffescript?

Less and less people are using CoffeeScript due to ECMA2015/ES6 being released with the large majority of functionality that CoffeeScript was created for.

You're probably better off just switching to ES6, but that's just my opinion.

Re: ES6 Cheatsheet

#52
> Unlike var, let and const statements are not hoisted to the top of their enclosing scope.

No, let is hoisted to the top of the enclosing scope [1] ("temporal dead zone" notwithstanding). let, however, is not hoisted to the top of the enclosing function.

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

Re: ES6 Cheatsheet

#53

The only thing from this list of new ES6 idioms that doesn't sit comfortably with me is the short-hand for creating classes. I remember being kind of blown away way back in the day with the prototypical/functional nature of Javascript and how you could wrangle something into being that behaved in an object-oriented manner just like other languages that had explicit class declaration and object instantiation. Part of…

I think the cheatsheet does a great job of summarizing what makes me uncomfortable with es6 classes: >"...the syntax for creating classes in ES6 obscures how implementation and prototypes work under the hood..." Yes, it's great for if you're uncomfortable with prototypal inheritance and the "javascript way of doing things" (I'll maybe summarize that as composition over inheritance, mixins, knowing how to use call/app…

Agreed. And I meant prototypal, not prototypical :)

Re: ES6 Cheatsheet

#57
Is "WeakMap" really the suggested way to implement private class properties?

Using "this" as a key into a Map of private variables looks bizarre. I would rather keep my code concise than create a layer of obfuscation.

Re: ES6 Cheatsheet

#58

Is "WeakMap" really the suggested way to implement private class properties? Using "this" as a key into a Map of private variables looks bizarre. I would rather keep my code concise than create a layer of obfuscation.

It was really hard to make truly private properties that couldn't be leaked in some way without WeakMap. If you don't need foolproof leakage, Symbols are a more convenient way to get most of the benefits of private properties. This is intentional: as I recall, the committee realized that WeakMap wasn't the most ergonomic solution and created Symbols as a more convenient, though less ironclad, alternative.

Re: ES6 Cheatsheet

#59

The only thing from this list of new ES6 idioms that doesn't sit comfortably with me is the short-hand for creating classes. I remember being kind of blown away way back in the day with the prototypical/functional nature of Javascript and how you could wrangle something into being that behaved in an object-oriented manner just like other languages that had explicit class declaration and object instantiation. Part of…

Prototype inheritance is fairly hard to reason about and fairly verbose to set up correctly. And if we aren't supposed to avoid inheritance that applies equally to prototype inheritance as well. Prototype inheritance allows even crazier inheritance situations.

I don't think it's reasonable to eliminate inheritance (it's very useful when it's needed) but restricting it down from what Javascript currently provides natively is a good thing.

Re: ES6 Cheatsheet

#60

Great reference and overview of ES6. One minor quibble. I was bothered by the misuse of the words "lexical" and "interpolate". The lexical value of the keyword "this " is the string "this". Then, you might translate between two technologies such as CommonJS and ES6 but interpolating between them implies filling in missing data by averaging known values. Granted this word is commonly abused. Sorry this is a bit pedant…

> By sticking to this paradigm, we make our code easily readable and allow ourselves to interpolate between CommonJS and ES6 modules. This sentence should probably say "interoperate"

I believe you are right.
Post reply on HN