JS基础--String\Math\Date\Symbol

时间:2020-12-13 20:30:08   收藏:0   阅读:24

嗨!我是前端小M~~

String--字符串

属性:str.length 字符串的长度只能获取不能设置

方法:

Math--数学

方法:

Date--日期对象

方法:

let timeObj = new Date();
let year = timeObj.getFullYear();    //年
let month = timeObj.getMonth()+1;    //月
let day = timeObj.getDate();         //日
let hourse = timeObj.getHours();     //时
let minutes = timeObj.getMinutes();  //分
let seconds = timeObj.getSeconds();  //秒
console.log(year);
console.log(month);
console.log(day);
console.log(hourse);
console.log(minutes);
console.log(seconds);
console.log(timeObj);    //2020-11-10T09:27:19.420Z   时间戳

Symbol--简单数据类型

只支持[ ]访问法

let obj ={
name:‘zhangsan‘,
age:18,
}
let name = Symbol("name");
obj[name]="lisi";
console.log(obj)// name:‘zhangsan‘,age:18,Symbol(name)]: ‘lisi‘

  

 

原文:https://www.cnblogs.com/trail0226/p/14129224.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!