var object = {
name: "Eric",
age: 24,
sayHi: function(){
console.log("My name is "+ this.name + " this year is " + this.age + "years old.")
}
};
var object = new Object();
object.name = "Eric";
object.age = 24;
object.sayHi = function(){....};
function Person() {
this.name = "Eric";
this.age = 24;
this.sayHi = function(){
console.log(this.name);
}
}
var object1 = new Person();
var object2 = new Person();
function Person() {
this.name = 'Eric';
this.age = 24;
}
Person.prototype = {
sayHi: function() {
},
};
var object1 = new Person();
var object2 = new Person();
function Person(name,age) {
this.name = name || "";
this.age = age || "";
}
Person.prototype = {
sayHi: function() {
},
};
var object1 = new Person(name1,age1);
var object2 = new Person(name2,age2);
function Person(option) { //用一个对象把所有参数覆盖
this.name = option.name || "";
this.age = option.age || "";
}
Person.prototype = {
sayHi: function() {
},
};
var object1 = new Person({
name: "Eric",
age: 24
});
var object2 = new Person({
name: "XXX",
age: xx
});
function Person(option) {
this._init(option);
}
Person.prototype = {
_init: function (option){
this.name = option.name;
this.age = option.age;
},
sayHi: function(){
console.log("HI");
}
};
var object1 = new Person({
name: "Eric";
age: 24
});
object1.sayHi();
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有