Ecmascript 6 (scratchbook)

This page is mainly used for me to add notes on things I encounter while working with EcmaScript 6 in Chrome (48)

Classes:

When working with EcmaScript 6 you can use classes. Classes are defined like so:

Really straight forward

Inheritance

Inheritance can be done like so

 

This

EcmaScript 6 suffers from the same issue with the This keyword as previous versions. So when you have a class in which you add a eventlistener on a node the this in that eventHandler will be the caller (window) and not the class instance

Easy solution (source)

 

Leave a Reply

Your email address will not be published. Required fields are marked *