Basically - before ES2015 - when creating an objects using object literals you couldn't add methods to the object.
As of ES2015 it is possible to add methods to object literals, which makes object literals and class declarations pretty close:
var obj = {
// __proto__
__proto__: theProtoObj,
// Shorthand for ‘handler: handler’
handler,
// Methods
toString() {
// Super calls
return 'd ' + super.toString();
},
// Computed (dynamic) property names
[ 'prop_' + (() => 42)() ]: 42
};
Another important thing is when you want to create instances of a class - you would want to create a class declaration and init objects based on that class declaration.