当前位置:网站首页>JS judge the data types object.prototype.tostring.call and typeof
JS judge the data types object.prototype.tostring.call and typeof
2022-07-26 09:38:00 【Bean sprouts don't eat beans】
Take a little note ~
Object.prototype.toString.call and typeof Both are used to judge the data type , The former is more specific to judge the data type , What is returned is string or array , The latter is just a return type .
When we use typeof When judging the data type , It is difficult to distinguish and compare two data types . such as : Use typeof Detection array or null The data types returned during are object, But use Object.prototype.toString.call You can distinguish which is an array , Which number null.
In a nutshell Object.prototype.toString.call You can return data types more specifically .
console.log(Object.prototype.toString.call("aaa")); // [object String]
console.log(typeof "aaa"); //string
console.log(Object.prototype.toString.call([123])); // [object Array]
console.log(typeof [123]); // object
console.log(toString.call(null)); //[object Null]
console.log(typeof null); // object
function a() {
console.log(" function ");
}
console.log(Object.prototype.toString.call(a)); // [object Function]
console.log(typeof a); // function
边栏推荐
- IIS网站配置
- Source code analysis of object wait notify notifyAll
- 高斯消元的应用
- Gauss elimination for solving XOR linear equations
- Calling DLL to start thread
- 面试突击68:为什么 TCP 需要 3 次握手?
- Process32first returns false, error x message 24
- POJ 1012 Joseph
- R语言ggplot2可视化: 将图例标题(legend title)对齐到ggplot2中图例框的中间(默认左对齐、align legend title to middle of legend)
- Great reward for interview questions
猜你喜欢
随机推荐
E. Two Small Strings
服务器、客户端双认证
PHP一次请求生命周期
一种分布式深度学习编程新范式:Global Tensor
Double authentication of server and client
Fiddler download and installation
cocoapods的安装和使用
matlab simulink实现模糊pid对中央空调时延温度控制系统控制
Solve "note: one or more layouts are missing the layout_width or layout_height attributes."
Add DLL
[untitled]
Windows下Redis哨兵模式搭建
Antd treeselect gets the value of the parent node
“互联网+”时代的现代医学
(2) Hand eye calibration of face scanner and manipulator (eye out of hand: nine point calibration)
Audio and video knowledge
高斯消元求解异或线性方程组
系统安装Serv-U后IIS出错提示:HRESULT:0x80070020
antd TreeSelect获取父节点的值
PMM(Percona Monitoring and Management )安装记录





![[Online deadlock analysis] by index_ Deadlock event caused by merge](/img/67/0a02ad248c3ab21d3240e12aa23313.png)


