I am learning javascript and would like to help understand a piece of code.
From the Object.DefineProperties definition, the first parameter is the object. Is MyObjectConstructor a declaration or an object. With a constructor function, I would expect to call a new one to make it an object.
That's what bothers me. Or, as I read in Javascript functions, these are objects, so I consider it as an object, and the this property is where all the staticProps and instance instances are added to?
var _prototypeProperties = function (child, staticProps, instanceProps) {
if (staticProps){
Object.defineProperties(child, staticProps)
};
if (instanceProps) {
Object.defineProperties(child.prototype, instanceProps);
}
};
function myFunction() {
function MyObjectConstructor(element) {
this.element = element;
this.initialized = false;
}
_prototypeProperties(MyObjectConstructor, {...}, {...});
}
source
share