You do not have a constructor function.
A constructor function is one you can call with the keyword new
in order to produce a new instance of said function. However, yours that just produces plain objects with no inheritance:
Your implementation:
let construct = function(name = "john", last = "marks") {
return {
name: name,
last: last,
};
};
let me = new construct("mike", "tyson");
console.log(me instanceof construct); //false
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…