13.Date

发布时间 2023-09-24 16:43:38作者: 一名狗书匠&

//方法就是把函数放在对象里面,对象只有属性和方法!
var jiang={
name:'岳不群',
shengri:2003,
asd:function () {
var non=new Date().getFullYear();//获取到当前的日期
return non-this.shengri;
}
}
-------------------------------------------------------------------
this 是无法指向的,是默认指向调用它的那个对象;

apply:所有函数都有的方法, 去指向一个对象来实现调用
asd.apply(jiang,[]);
----------------------------------------------------------------
typeof 判断数据类型
typeof 123
'number'
typeof '123'
'string'
typeof true
'boolean'
typeof {}
'object'
typeof []
'object'
typeof Math.abs
'function'
----------------------------------------------------
var x=new Date();
console.log(x);
x.getFullYear();//年
x.getMonth();//月
x.getDate();//日
x.getHours()//小时
x.getMinutes();//分
x.getSeconds()//秒
x.getTime();//时间戳
//时间戳转化为时间
var asd=new Date(1695543538269);

--------------------------------------------------------------------------------------