看一段代碼先
Student繼承Person
放到瀏覽器運(yùn)行后拾积,關(guān)于原型要三種情況來講
1. var 變量的原型關(guān)系
在addWatch下xiaoming變量的函數(shù)關(guān)系
xiaoming 的_proto_(即原型)指向了function 函數(shù)對(duì)象的prototype屬性
2.function 函數(shù)對(duì)象的原型關(guān)系
在addWatch下函數(shù)對(duì)象Student
Student的prototype屬性是一個(gè)屬性差油,賦值為一個(gè)prototyep對(duì)象
還有一個(gè)_proto_屬性诽凌,這是它真正的原型观堂,是一個(gè)function
3.function函數(shù)對(duì)象的prototype的原型關(guān)系
addWatch下Student.prototype屬性
此prototype屬性是一個(gè)對(duì)象桂塞,有兩個(gè)默認(rèn)屬性
1.constructor
2._proto_
function 和prototype對(duì)象的相互利用關(guān)系