we know that classes are just functions in javascript and classes is just an abstraction, syntactic sugar, whatever you want to call it, over its prototype-based inheritance. For example:
class foo {
bar() {}
}
is transformed to:
function foo() {}
foo.prototype.bar = function() {};
but if we use a public instance as
class foo {
bar = "Hello World";
}
we cannot access the bar
instance properies as
foo.prototype.bar
(undefined)
I know we have to create a new instance to access it like:
var instance = new foo();
console.log(instance.bar); // "Hello World"
but somehomw bar
property must be baked in foo
‘s proptotye, so where is it?
learn how pubilc instance is used internally by ES6