JavaScriptでのプロトタイプ2
[size=medium;]シンプルなプロトタイプ:[/size]
[size=medium;]1、[/size][size=medium;] 簡潔なプロトタイプモードを使用する場合、constructorプロパティはperson関数を指しません.overrideのデフォルトのプロトタイプモードのためです.新しいプロトタイプモードのconstructorはobject関数をデフォルトで指す.
[size=medium;]2、原型関数全体を書くことから

[size=medium;]第1段エラーコードの図解[/size]

[size=medium;]2段目のコードの図解[/size]
function person(){} person.prototype={ name:"zhangsan", age:33, sayhello:function(){ alert("hello,i'm "+this.name); } } var person = new person(); person.sayhello(); //hello,i'm zhangsan alert(person instanceof object);//true alert(person instanceof person);//true alert(person.constructor ==person);//false alert(person.constructor==object);//true

[size=medium;]1、[/size][size=medium;] 簡潔なプロトタイプモードを使用する場合、constructorプロパティはperson関数を指しません.overrideのデフォルトのプロトタイプモードのためです.新しいプロトタイプモードのconstructorはobject関数をデフォルトで指す.
[size=medium;]2、原型関数全体を書くことから
function person(){} var person = new person(); person.prototype={ name:"zhangsan", age:33, sayhello:function(){ alert("hello,i'm "+this.name); } } person.sayhello(); // person.sayhello is not a function
function person(){} person.prototype={ name:"zhangsan", age:33, sayhello:function(){ alert("hello,i'm "+this.name); } } var person = new person(); person.sayhello(); //hello,i'm zhangsan
[size=medium;]上の2つのコード:異なる点はpersonインスタンスを構築する位置が異なるだけで、異なる結果が現れ、その真相を図で説明することができます.[/size]
[size=medium;]第1段エラーコードの図解[/size]

[size=medium;]2段目のコードの図解[/size]