var aa = { name: "xuhaitao", age: 38 };
console.log(aa);
console.log(aa.__proto__ == Object.prototype)
function Haitao(name, age) {
this.name = name;
this.age = age;
this.getMing = function() {
return this.name;
}
}
//向函数对象的显示原型中添加一个方法
Haitao.prototype.getName = function() {
console.log(this);
}
var p01 = new Haitao("xuhaitao", 38);
console.log(p01);
var cc = new Object();
console.log(cc);
console.log(p01.__proto__.__proto__ == cc.__proto__); //打印结果:true
上面代码打印结果:
var aa = null;
aa = { name: "xuhaitao" }
aa = null;
var aa;
console.log(aa); //打印结果:undefined
var aa = { name: "xuhaitao" }
var bb = aa;
function test(obj) {
obj = { name: "xuhaihuan" };
}
test(aa);
console.log(aa.name); //打印结果:xuhaitao
console.log(bb.name); //打印结果:xuhaitao
var mm = {};
function test2() {
this.xxx = "xuhairu";
}
test2.call(mm);
console.log(mm.xxx); //打印结果:xuhairu
function haitao(val01, val02) {
this.zhi01 = val01;
this.zhi02 = val02;
this.add = function() {
console.log(this.zhi01 + this.zhi02);
}
this.jian = function() {
console.log(this.zhi01 - this.zhi02);
}
}
var p01 = new haitao(25, 36);
var p02 = new haitao(33, 36);
p01.add(); //61
p01.jian(); //-11
p02.add(); //69
p02.jian(); //-3
FR:徐海涛(hunk Xu)
QQ技术交流群:386476712