所以,我想知道以下代码块之间的区别。我发现在定义一些业务逻辑模块时没有什么不同。
function People(){}
People.prototype = {role : 'user'}
function Male(){}
Male.prototype = new People(); // the difference
var m = new Male()
m.role // print user
m instanceof Male // print true
function People(){}
People.prototype = {role : 'user'}
function Male(){}
Male.prototype = People.prototype; // the difference
var m = new Male()
m.role // print user
m instanceof People // print true