var Plugin = function(){}
Plugin.prototype = {
sayHello:function(){
console.log("hello")
}
}
var p = new Plugin()
console.log(p.constructor === Object) //true
如果加上constructor
var Plugin = function(){}
Plugin.prototype = {
constructor: Plugin,
sayHello:function(){
console.log("hello")
}
}
var p = new Plugin()
console.log(p.constructor === Plugin) //true
將建構子指向本身,否則預設指向Object
如果加上constructor