标准对象

7 篇文章 0 订阅

typeof 123; // ‘number’
typeof NaN; // ‘number’
typeof ‘str’; // ‘string’
typeof true; // ‘boolean’
typeof undefined; // ‘undefined’
typeof Math.abs; // ‘function’
typeof null; // ‘object’
typeof []; // ‘object’
typeof {}; // ‘object’

var now = new Date();
now; // Wed Jun 24 2015 19:49:22 GMT+0800 (CST)
now.getFullYear(); // 2015, 年份
now.getMonth(); // 5, 月份,注意月份范围是0~11,5表示六月
now.getDate(); // 24, 表示24号
now.getDay(); // 3, 表示星期三
now.getHours(); // 19, 24小时制
now.getMinutes(); // 49, 分钟
now.getSeconds(); // 22, 秒
now.getMilliseconds(); // 875, 毫秒数
now.getTime(); // 1435146562875, 以number形式表示的时间戳

JSON.stringify(xiaoming);
JSON.stringify(xiaoming, null, ’ ‘);(只为pretty,熟悉linux的同学都懂得)
JSON.stringify(xiaoming, [‘name’, ‘skills’], ’ ‘);
{
“name”: “小明”,
“skills”: [
“JavaScript”,
“Java”,
“Python”,
“Lisp”
]
}

拿到一个JSON格式的字符串,我们直接用JSON.parse()把它变成一个JavaScript对象:
JSON.parse(‘[1,2,3,true]’); // [1, 2, 3, true]
JSON.parse(‘{“name”:”小明”,”age”:14}’); // Object {name: ‘小明’, age: 14}
JSON.parse(‘true’); // true
JSON.parse(‘123.45’); // 123.45

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值