87,839
社区成员




function Person(name) {
this.name = name;
this.sayName = function () {
console.log(this.name);
};
}
or defined as prototypes property:
Person.prototype.profile = {
name: "Nicholas",
age: 29
}
<script type=text/javascript>
window.onload=function (){
Person();
}
function Person() {
Person.prototype= {
name: "Nicholas",
age: 29
}
alert(Person.prototype.name);
}
</script>