All the examples of classes I see are
class myClass{
constructor(){}
someFunction(){}
what I want to add is
someObject {myvalue:value}
}
this doesn't seem to compile. An old fashioned object would be
{
somefunction: function(){}
someProperty: {myvalue:value}
}
is this not possible in es6 classes?
You'd need to put it inside your constructor:
If required, you can add the object onto the prototype chain the same as you would in ES5:
Note that there is no such thing as real private properties on a class. Any variable you attach to a class is public.
There is a Stage 0 proposal for Class Properties in ES7. If using Babel, this can be enabled using Experimental mode, allowing the following: