JS高级

 

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值