JS其他引用类型对象

1、单体对象
Global对象(全局),这个对象不存在,无形的对象,其内部定义了一些方法和属性
encodeURI、encodeURIComponent、decodeURI、decodeURIComponent、eval、parseInt、parseFloat、isNaN、             escape、unescape
下面对这几个方法逐一讲解:
a、encodeURI和encodeURIComponent
var uri = 'http://www.bjsxt.com cn'; 
document.write(encodeURI(uri)); // http://www.bjsxt.com%20cn 
        document.write(encodeURIComponent(uri)); //http%3A%2F%2Fwww.bjsxt.com%20cn 
        document.write("<br/>"); //document.write(decodeURI(uri)); //http://www.bjsxt.com cn               document.write(decodeURIComponent(uri)); //http://www.bjsxt.com cn
b、eval(String)无形的js解析器
var str = "var a = 10; var b = 20"; 
 eval(str); alert(a);   //10
//数组字符串转成对象
var str = "{name:'z3',age:15}";
var obj = eval('('+str+')');
alert(obj.name);  //z3
c、escape和unescape,针对汉字进行编码和解码
var str = "尚学堂"; 
        document.write(escape(str)); //%u5C1A%u5B66%u5802 
        document.write(unescape(str));//尚学堂
Math对象 和Java类似
2、Date对象
var date = new Date(); //产生一个日期对象 
document.write(date);     //     Tue May 24 2016 19:31:57 GMT+0800 (中国标准时间)
var year = date.getFullYear();  
document.write(year);    //  2016
var month = date.getMonth() + 1;  //外国的时间月份得加 1
document.write(month);  //  5
        var day = date.getDate();
document.write(day);   //  24
var hours = date.getHours(); 
        document.write(hours);   //19
 var minutes = date.getMinutes(); 
  d ocument.write(minutes);    //38
  var seconds = date.getSeconds(); 
  document.write(seconds); // 43
var week = date.getDay();
document.write(week); //获得星期几
// 今天是:2016年5月24日 19:42:9 星期2
document.write('今天是:'+ year +'年'+month+'月'+day+'日'+' '+hours+':'+minutes+':'+seconds+' '+'星期'+week);
3、基本包装类型:Boolean、String、Number,和Java的用法类似,在此就不一一介绍。
4、function类型、正则表达式类型(以后介绍)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值