代码在这里:
http://jsbin.com/xabowoyihawe/1/edit?js,console
问题: 为什么noop.name可以取到值而noop.title是undefined?而name和title都是在noop.prototype中的
function noop() { }
function _extend(source, obj) {
for (var prop in source) {
if(!obj.prototype[prop]) {
obj.prototype[prop] = source[prop]
}
}
return obj
}
noop.prototype["name"] = 'noop'
_extend({"title":"sometitle"}, noop)
var n = new noop()
console.log( noop.name, noop.title, noop.prototype.name, noop.prototype.title, noop.prototype)
console.log( n.name, n.title)