prototype是javascript中一个特殊的概念,只要是一个函数对象就有prototype属性,
因为javascript中的函数可以作为一个对象的构造器来创建一个对象,所以一个函数的prototype主要会影响到以这个函数为构造器生成的对象
function Func(){}
var test = new Func()
Func.prototype.a="hello"
test.a //hello
函数的原型对象默认子包含一个指向函数构造函数的constructor属性
如果是普通对象只有__proto__属性而没有prototype属性在一般情况下__proto__属性指向了对象的构造函数的prototype属性
function Func(){}
var test = new Func()
test.__proto__.a=1
test.a //a
Func.prototype //a
以上代码说明 test.__proto__ 和 Func.prototype 其实指向的是同一个东西
function Func(){}
var test1 = new Func()
var test2 = new Func()
test1.__proto__.a=1
test2.a //1
这里test1对象和test2对象都是从Func函数new出来的算是兄弟对象通过__proto__居然可以访问到同一块数据