日期:2014-05-16 浏览次数:20388 次
var Dog = function(name, age){
this.name = name;
this.age = age;
}
Dog.prototype = {
constructor : Dog,
sayName : function(){
console.log(this.name);
}
}
Dog('jikey', 4);
console.log(this.name == window.name); // true
console.log(this.name); // jikey
console.log(this.age); // 4
var Dog = function(name, age){
this.name = name;
this.age = age;
}
Dog.prototype = {
constructor : Dog,
sayName : function(){
console.log(this.name);
}
}
var dog2 = new Dog('tang', 5);
dog2.sayName();
var dog3 = new Dog('csdn', 10);
dog3.sayName();