Constructor invocation
suggest changeWhen a function is invoked as a constructor with the new keyword, this is the object being constructed. If the constructor returns an object, that object is the result of new instead of the object bound to this.
function Obj(name) {
this.name = name;
}
const obj = new Obj("Foo");
console.log(obj);
This will log
{ name: "Foo" }
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents