<script>
function User (theName, theEmail) {
this.name = theName;
this.email = theEmail;
}
User.prototype = {
constructor: User,
changeEmail:function (newEmail) {
this.email = newEmail;
return "New Email Saved: " + this.email;
}
}
// A User
firstUser = new User("Richard", "Richard@examnple.com");
firstUser.changeEmail("RichardB@examnple.com");
</script>
这段代码取自这里:http: //javascriptissexy.com/oop-in-javascript-what-you-need-to-know/
问题:
把这条线放在上面是不是很重要:constructor: User,
?如果我删除了这条线,它仍然有效。