JS07

常用的内置对象

     对象是JavaScript的特性之一,它是一种非常重要的数据类型,是自我包含的数据集合。

   

创建Date对象方法

 

new Date()

new Date(month dd,yyyy hh:mm:ss)

new Date(yyyy,mth,dd,hh,mm,ss)

new Date(yyyy,mth,dd)

new Date(ms)

 

Date对象获取时间细节方法:

 

getDate()

Date对象返回一个月中的某一天(1~31)

getDay()

Date对象返回一周中的某一天(0~6)

getMonth()

Date对象返回月份(0~11

getFullYear()

Date对象以四位数字返回年份

getHours()

返回Date对象的小时(0~23

getMinutes()

返回Date对象的分钟(0~59

getSeconds()

返回Date对象的秒数(0~59

getTime()

返回197011日至今的毫秒数

 

Date对象设置时间的方法:

 

setDate()

设置Date对象中月的某一天(1~31

setMonth()

设置Date对象中月份(0~11

setFullYear()

设置Date对象中的年份(四位数字)

setHours()

设置Date对象中的小时(0~23

setMinutes()

设置Date对象中的分钟(0~59

setSeconds()

设置Date对象中的秒钟(0~59

setMilliseconds()

设置Date对象中的毫秒(0~999

 

Math对象的常用方法:

 

abs(x)

返回数的绝对值

ceil(x)

对数进行上舍入

floor(x)

对数进行下舍入

max(x,y)

返回xy中的最高值

min(x,y)

返回xy中的最低值

pow(x,y)

返回xy次幂

random()

返回0~1之间的随机数

round(x)

把数四舍五入为最接近的整数

sqrt(x)

返回数的平方根

 

posted on 2019-08-16 13:56  小蜘zhu  阅读(353)  评论(0编辑  收藏  举报