I have been wrapping my head around pseudoclassical inheritance in Javascript , and continuing on this topic I wanted to set an Static property/method , for a defined Constructor function.
I want to avoid the class syntax for it.
function Food () {
isEdible = true;
}
console.log(Food.isEdible); // undefined
I know this example is wrong
I am wondering how it has been done on the rest of the Javascript Object model, with methods so important like for instance
Array.of(element1, element2, /* …, */ elementN)
Which can be accessed without the need of Instanciating an Array
Reflect.definePropertyorObject.defineProperty, but also into eitherReflect.getOwnPropertyDescriptororObject.getOwnPropertyDescriptor...and regarding the OP's use case, the next one is an appropriate way...Reflect.defineProperty(Food, 'isEdible', { /* enumerable: false, */configurable: true, writable: true, value: true });