Message from JavaScript talks

June 2017

— It creates a static method

— 

class MyClass {
static myMethod () {
return 4;
}
}


equivalent to:

function MyClass() {
};

MyClass.myMethod =
function myMethod() {
return 4;
};

— Except second one can run as a function (without new) as well

— That's the only difference

— Heh, static methods AND instance methods can all be changed at runtime dude

— I see

— For static, that is not something I expected. It seems I know less about class syntax in JS than I thought I did

Message permanent page

— 

function MyClass() {
}

var myInstance = new MyClass();

MyClass.prototype.foo = () => 'bar';

myInstance.foo(); // 'bar'

Message permanent page

— All this works in runtime

— Class syntax is just sugar over this stuff

— This is how you did classes in ES5 btw

— I know haha