标准对象

时间:2020-02-05 11:12:02   收藏:0   阅读:63

typeof获取对象的的类型

大专栏  标准对象
1
2
3
4
5
6
7
8
9
typeof 123; // 'number'
typeof NaN; // 'number'
typeof 'str'; // 'string'
typeof true; // 'boolean'
typeof undefined; // 'undefined'
typeof Math.abs; // 'function'
typeof null; // 'object'
typeof []; // 'object'
typeof {}; // 'object'

各种类型的判断方法

除了null和undefined,其他的object都有toString方法;

对于数值类型调用toString方法需要用括号或双引号括起:

1
2
123..toString(); // '123', 注意是两个点!
(123).toString(); // '123'

Date

原文:https://www.cnblogs.com/lijianming180/p/12262453.html

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