当前位置:网站首页>js 使用toString 区分Object、Array
js 使用toString 区分Object、Array
2022-07-01 09:13:00 【su27_0101】
typeof分不清
typeof 是 js提供的 用于判断变量类型的 保留字
但对于判断Object 与 Array 都会返回 Object
也就是分不清
typeof [ ];//Object
typeof {};//Object
toString 来区分
利用Object.prototype.toString
打印的字符串区分
Object.prototype.toString.call([]);//'[object Array]'
Object.prototype.toString.call({});//'[object Object]'
也可区分其他类型
Object.prototype.toString.call(arguemnts);//'[object Arrguments]'
边栏推荐
- Shell脚本-特殊变量:Shell $#、$*、[email protected]、$?、$$
- Shell脚本-while循环详解
- Performance improvement 2-3 times! The second generation Kunlun core server of Baidu AI Cloud was launched
- Shell script - positional parameters (command line parameters)
- Installing Oracle EE
- 通过 代码实例 理解 浅复制 与 深复制
- Why is the Ltd independent station a Web3.0 website!
- 【电赛训练】红外光通信装置 2013年电赛真题
- Mysql8.0 learning record 17 -create table
- Day06 branch structure and cycle (III)
猜你喜欢
Installing Oracle EE
Which method is good for the management of fixed assets of small and medium-sized enterprises?
MySQL optimization
【pytorch】nn. Crossentropyloss() and nn NLLLoss()
Imitation of Baidu search results top navigation bar effect
MapReduce编程基础
jeecg 重启报40001
Implementation and application of queue
3D打印Arduino 四轴飞行器
Microcomputer principle - bus and its formation
随机推荐
Day06 branch structure and cycle (III)
I use flask to write the website "one"
[pytorch] 2.4 convolution function nn conv2d
【pytorch】nn. AdaptiveMaxPool2d
Key points of NFT supervision and overseas policies
dsPIC30F6014a LCD 方块显示
3D printing Arduino four axis aircraft
OSPF - virtual link details (including configuration commands)
Flink interview questions
【电赛训练】红外光通信装置 2013年电赛真题
The fixed assets management system enables enterprises to dynamically master assets
2.3 【pytorch】数据预处理 torchvision.datasets.ImageFolder
Ranking list of domestic databases in February, 2022: oceanbase regained the "three consecutive increases", and gaussdb is expected to achieve the largest increase this month
Structure de l'arbre - - - arbre binaire 2 traversée non récursive
Imitation of Baidu search results top navigation bar effect
Shell script case in statement
【pytorch】nn. Crossentropyloss() and nn NLLLoss()
Design and manufacture of simple digital display electronic scale
Shell脚本-特殊变量:Shell $#、$*、[email protected]、$?、$$
足球篮球体育比赛比分直播平台源码/app开发建设项目