I encountered problems in the case I referred to when learning jquery custom plug-in development.
为情所困2017-06-12 09:31:41
Point the constructor to itself, otherwise it will point to Object by default
var Plugin = function(){}
Plugin.prototype = {
sayHello:function(){
console.log("hello")
}
}
var p = new Plugin()
console.log(p.constructor === Object) //true
If you add constructor
var Plugin = function(){}
Plugin.prototype = {
constructor: Plugin,
sayHello:function(){
console.log("hello")
}
}
var p = new Plugin()
console.log(p.constructor === Plugin) //true