function player(name,age)
{
this.name = name;
this.age = age;
this.id = id;
}
function id()
{
this.id = name;
}
var mo = new player("Tom","26");
alert(mo.id);
为什么player()在实例化之后,mo的id属性可以访问id()?
他们的作用域不一样啊
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
函数有个提升的机制。你person构造函数this.sayName就等于function sayName()函数