其他分享
首页 > 其他分享> > 【学习笔记】内部对象

【学习笔记】内部对象

作者:互联网

内部对象

 

Date

var now = new Date();
now.getFullYear();    //年
now.getMonth();       //月   0~11月
now.getDate();         //日
now.getDay();        //星期几
now.getHours();      //时
now.getMinutes();     //分
now.getSeconds();    //秒
​
now.getTime();    //时间戳

image-20220914193935159

​
​
now = new Date(1663155471285)
Wed Sep 14 2022 19:37:51 GMT+0800 (中国标准时间)
now.toDateString
ƒ toDateString() { [native code] }
now.toDateString()
'Wed Sep 14 2022'
now.toLocaleString
ƒ toLocaleString() { [native code] }
now.toLocaleString()
'2022/9/14 19:37:51'

 

JSON

JSON是什么?

image-20220914200527330

 

在JavaScript中,一切皆为对象,任何js支持的类型都可以用JSON来表示

格式:

 

var obj = {
    name:'wzt',
    age:23,
    sex:'男'
}

image-20220914200930632

 

对象是可以展开的

 

var jsonuser = JSON.stringify(user)

image-20220914201208602

我们可以看到json字符串不可展开,并且不是键值对,都是字符串

 

image-20220914201517362

把json字符串给转化为了对象,其中json字符串需要用引号引起来

标签:toLocaleString,对象,笔记,学习,var,JSON,字符串,now
来源: https://www.cnblogs.com/wztblogs/p/16694382.html