JavaScript OOP 2

var line = 0;  
function log(str){  
    line++;  
    document.write("<p><span style='color:blue;'>"+line+"</span>\toutput:<strong><b style='color:red;'>"  
    +str+"</b></strong>  [Time:"+new Date()+"]</p>")  
}

log("Boolean(null) = "+Boolean(null));
log("Boolean(undefined) = "+Boolean(undefined));
log("Boolean(\"\") = " + Boolean(""));
log(isFinite(3));
log(isNaN(5));
log(NaN);
log(typeof NaN);
log(typeof(Object));
log(typeof Object);
var o = new Object();
log(typeof o);
log("has property name :" + o.hasOwnProperty("name"));
log("isPrototypeOf(name) :" + Object.prototype.isPrototypeOf(Object));
//log(true++);
try{
    test();
}
catch(err){
    log(err);
    log(err.message);
}
finally{
    log("finally");
}
with(o){
    log(isPrototypeOf(Object));
}
with("name"){
    log(isPrototypeOf(o));
}
O=Object;
log(new O());
log(-1>>>0);//usigned int32


1	output:Boolean(null) = false [Time:Sun May 20 2018 23:08:35 GMT+0800 (中国标准时间)]

2	output:Boolean(undefined) = false [Time:Sun May 20 2018 23:08:35 GMT+0800 (中国标准时间)]

3	output:Boolean("") = false [Time:Sun May 20 2018 23:08:35 GMT+0800 (中国标准时间)]

4	output:true [Time:Sun May 20 2018 23:08:35 GMT+0800 (中国标准时间)]

5	output:false [Time:Sun May 20 2018 23:08:35 GMT+0800 (中国标准时间)]

6	output:NaN [Time:Sun May 20 2018 23:08:35 GMT+0800 (中国标准时间)]

7	output:number [Time:Sun May 20 2018 23:08:35 GMT+0800 (中国标准时间)]

8	output:function [Time:Sun May 20 2018 23:08:35 GMT+0800 (中国标准时间)]

9	output:function [Time:Sun May 20 2018 23:08:35 GMT+0800 (中国标准时间)]

10	output:object [Time:Sun May 20 2018 23:08:35 GMT+0800 (中国标准时间)]

11	output:has property name :false [Time:Sun May 20 2018 23:08:35 GMT+0800 (中国标准时间)]

12	output:isPrototypeOf(name) :true [Time:Sun May 20 2018 23:08:35 GMT+0800 (中国标准时间)]

13	output:ReferenceError: test is not defined [Time:Sun May 20 2018 23:08:35 GMT+0800 (中国标准时间)]

14	output:test is not defined [Time:Sun May 20 2018 23:08:35 GMT+0800 (中国标准时间)]

15	output:finally [Time:Sun May 20 2018 23:08:35 GMT+0800 (中国标准时间)]

16	output:false [Time:Sun May 20 2018 23:08:35 GMT+0800 (中国标准时间)]

17	output:false [Time:Sun May 20 2018 23:08:35 GMT+0800 (中国标准时间)]

18	output:[object Object] [Time:Sun May 20 2018 23:08:35 GMT+0800 (中国标准时间)]

19	output:4294967295 [Time:Sun May 20 2018 23:08:35 GMT+0800 (中国标准时间)]

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值