当前位置:网站首页>Object.prototype.toString.call()的原理
Object.prototype.toString.call()的原理
2022-07-28 20:15:00 【大鸡腿最好吃】
let a={
a:1
}
let b=[2,3]
console.log(a.toString())
console.log(b.toString())
//[object Object],输出了a的数据类型
//2,3 把数组内的值转化为了字符串
js其实是重写了某些数据类型的toString方法,所以才会造上面的情况,array有其对应的toString方法,就近调用了
let a={
a:1
}
let b=[2,3]
delete Array.prototype.toString
console.log(a.toString())
console.log(b.toString())
这样子就会输出 [object Object] [object Array]
优雅点的方法就是,让你要判断的变量的数据去调用Object.prototype.toString的方法,这样就可以去准确的判断变量类型
边栏推荐
- 中国农业工程学会农业水土工程专业委员会-第十二届-笔记
- 基于Xception-TD的中华传统刺绣分类模型构建
- Mesh data generation function meshgrid
- Open earphone which air conduction earphone with good sound quality and recognized sound quality is recommended
- ESP8266-Arduino编程实例-深度休眠与唤醒
- RHCSA第一天
- Lt7911d type-c/dp to Mipi scheme is mature and can provide technical support
- 开放式耳机哪个品牌好、性价比最高的开放式耳机排名
- MATLAB从入门到精通 第1章 MATLAB入门
- 迪赛智慧数——折线图(堆叠面积图):2022年不同职业人群存款额占月收入比例排名
猜你喜欢

For the first time, Chinese scientists used DNA to construct convolutional artificial neural network, which can complete 32 types of molecular pattern recognition tasks, or be used for biomarker signa

第 8 篇:创建摄像机类

Msfvenom makes master and controlled terminals

Rhcsa first day

C语言入门【详细】

系统分析师

网格数据生成函数meshgrid

KubeVela 1.4.x 官方文档

kali里的powersploit、evasion、weevely等工具的杂项记录

节省70%的显存,训练速度提高2倍!浙大&阿里提出在线卷积重新参数化OREPA,代码已开源!(CVPR 2022 )
随机推荐
How is nanoid faster and more secure than UUID implemented? (glory Collection Edition)
Esp8266 Arduino programming example - timer and interrupt
How does MySQL archive data?
从 Web3到Web2.5,是倒退还是另辟蹊径?
90. 子集 II
Introduction to C language [detailed]
Rhcsa first day
For the next generation chromebook, MediaTek launched new chipsets mt8192 and mt8195
B+ tree height calculation of MySQL
Hold high the two flags of 5g and AI: Ziguang zhanrui Market Summit is popular in Shencheng
KubeEdge发布云原生边缘计算威胁模型及安全防护技术白皮书
ESP8266-Arduino编程实例-SPIFFS及数据上传(Arduino IDE和PlatformIO IDE)
How to skillfully use assertion + exception handling classes to make the code more concise! (glory Collection Edition)
LeetCode·581.最短无序连续子数组·双指针
kali里的powersploit、evasion、weevely等工具的杂项记录
Research on intangible cultural heritage image classification based on multimodal fusion
HYDAC溢流阀DB08A-01-C-N-500V
kingbase中指定用户默认查找schema,或曰用户无法使用public schema下函数问题
标准C语言学习总结10
Oracle triggers