Message from JavaScript talks

June 2017

— Many think they are not quite sane, or proficient? Something. I try not to judge.

— 

Could I do this:

class MyClass {
#priv = 42;
}

MyClass.staticMethod =
function (myInstance) {
// Can I get #priv from here?
};

— If not, that's fine

— As long as ALL the accessors of #priv neccessarily have to be defined within the class declaration I don't see a problem

Message permanent page

— Hmm, not sure!

— As I understand it class is just a special function, and assigning a property to an uninstantiated class should get you the same results as assigning a property to a function definition.

Message permanent page

— Uuuh noo

— Which... I have never tried, haha

— It creates a static method

— 

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


equivalent to:

function MyClass() {
};

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

Message permanent page

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

— That's the only difference