日期:2014-05-16 浏览次数:20398 次
User.prototype.sayHello=function(){
alert("hello");
}
user.sayHello();这样的话弹出hellovar user=new User();User.prototype={
sayHello:function(){
alert("hello");
}
}user.sayHello();ff报user.sayHello is not a function
function User(){
//code here
}
var user=new User()
User.prototype.sayHello=function(){
alert("hello");
}
User.prototype={
sayHello:function(){
alert("hello");
}
}
function User(){
//code here
}
var methods={
sayHello:function(){
alert("hello");
}
}
methods={
sayHello:function(){
alert("hello");
},
sayWord:function(){
alert("word");
}
}
User.prototype=methods;
var user=new User();
user.sayWord();