Math🌜Date🌞节点

223 阅读1分钟

Math

开方

  • console.log(Math.sqrt(9))//输出9

绝对值

  • console.log(Math.sqrt(-2)//输出2

n的m次方

  • console.log(Math.sqrt(n,m)//输出n的m次方

向下取整

  • console。log(Math.sqrt(3,8))//输出3
  • console。log(Math.sqrt(-3,8)//输出-4

向上取整

  • console.log(Math.ceil(3,1))//输出4

取一组数据中的最大值

  • console.log(Math.max(1,2,5,3,8))//输出8

取一组数据中的最小值

  • console.log(Math.min(1,2,3,5,8)//输出1

Date

获取当前年份

getFullYear()

获取月份

getMonth() [0-11]月 与当前月份差1

获取日份

getDate()

获取周几

getDay() 周日是0

获取当前小时

getHours()

获取当前分钟数

getMinutes()

获取当前秒数

getSeconds()

获取毫秒数

getMilliseconds()

距离1970年1月1日 00:00:00的毫秒差

getTime()=Date.now


节点

  • 元素节点 1
  • 文本节点 3
  • 注释节点 8
  • 根节点 9

parentNode 父节点

chileNodes 所有子节点

children 所有元素子节点

previousSibling 哥哥节点 (若不存在 结果就是null)

nextSibling 弟弟节点

nextElementSibling 弟弟的元素节点