当前位置:网站首页>Differences between JS valueof and toString
Differences between JS valueof and toString
2022-07-01 09:18:00 【su27_ 0101】
- valueOf Returns the object itself 、
- toString Returns the object description string
obj = new Object(); // {}
obj.toString(); // '[object Object]'
obj.valueOf() == obj // true
toString Is to convert an object into a string ;
valueOf Is to convert an object into a value of basic data
valueOf Biased towards arithmetic ,toString Tend to show .
1、 In object conversion ( for example :alert(a)), Will call... First toString Method , If not rewritten toString Will call valueOf Method , If neither method is overridden , Press Object Of toString Output .
2、 When the string type is forcibly converted, the... Will be called first toString Method , When forced to a number, call... First valueOf.
3、 In the case of arithmetic operators ,valueOf Has a higher priority than toStri
边栏推荐
- Design and manufacture of simple digital display electronic scale
- 【pytorch】softmax函数
- PR training notes
- Preparing for the Blue Bridge Cup -- bit operation
- js变量提升(hoisting)
- Summary of reptile knowledge points
- Shell script case in statement
- The fixed assets management system enables enterprises to dynamically master assets
- 【ESP 保姆级教程 预告】疯狂Node.js服务器篇 ——案例:ESP8266 + DS18B20温度传感器 +NodeJs本地服务+ MySQL数据库
- In the middle of the year, where should fixed asset management go?
猜你喜欢
2.3 【kaggle数据集 - dog breed 举例】数据预处理、重写Dataset、DataLoader读取数据
OSPF - virtual link details (including configuration commands)
[interview brush 101] linked list
3D printing Arduino four axis aircraft
队列的实现和应用
MySQL optimization
Installation and use of NoSQL database
Understanding and implementation of AVL tree
Nacos service configuration and persistence configuration
Imitation of Baidu search results top navigation bar effect
随机推荐
Naoqi robot summary 28
NiO zero copy
OSPF - virtual link details (including configuration commands)
【ESP 保姆级教程】疯狂毕设篇 —— 案例:基于物联网的GY906红外测温门禁刷卡系统
[pytorch] 2.4 convolution function nn conv2d
phpexcel 里 获取某一列的列表 获取某一列的字母
Shell script -if else statement
pcl_ Viewer command
LogBack
Redis source code learning (29), compressed list learning, ziplist C (II)
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
Youqitong PE toolbox [vip] v3.7.2022.0106 official January 22 Edition
[ESP nanny level tutorial] crazy completion chapter - Case: chemical environment system detection based on Alibaba cloud and Arduino, supporting nail robot alarm
js valueOf 与 toString 区别
Shell script -read command: read data entered from the keyboard
Vsync+ triple cache mechanism +choreographer
Bird recognition app
Implementation and application of queue
【pytorch】nn. Crossentropyloss() and nn NLLLoss()
js this丢失问题分析 及 解决方案