Let's say i have the following class:
function Base() {};
Base.prototype.Const = 0;
and a derived function:
function Derived() {};
The Derived function has access to this.Const . Now my question is - I haven't seen any case where people define Consts on the prototype and i wonder why not? Is there any problem using this method? (it seems like a good practice to me since the const in not global and contained within the class and it's not on the this)
I'm not necessarily talking about a constant - but a variable that all the derived classes might want to use... like ID or something else
You are using it right according to the JavaScript definitive guide Book
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With