当前位置:网站首页>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
边栏推荐
- Mise en œuvre simple de l'équilibrage de la charge par nacos
- Understand shallow replication and deep replication through code examples
- 【ESP 保姆级教程 预告】疯狂Node.js服务器篇 ——案例:ESP8266 + DHT11 +NodeJs本地服务+ MySQL数据库
- How to launch circle of friends marketing and wechat group activities
- ES6-const本质与完全不可改实现(Object.freeze)
- Shell script case in statement
- Niuke monthly race 22- collect pieces of paper
- [ESP nanny level tutorial] crazy completion chapter - Case: chemical environment system detection based on Alibaba cloud and Arduino, supporting nail robot alarm
- Bird recognition app
- Redis source code learning (29), compressed list learning, ziplist C (II)
猜你喜欢
Ape anthropology topic 20 (the topic will be updated from time to time)
Football and basketball game score live broadcast platform source code /app development and construction project
nacos服务配置和持久化配置
Error org apache. catalina. core. StandardContext. FilterStart start filter exception
[pytorch] 2.4 convolution function nn conv2d
dsPIC30F6014a LCD 方块显示
Microcomputer principle - bus and its formation
队列的实现和应用
3D printing Arduino four axis aircraft
I use flask to write the website "one"
随机推荐
js原型陷阱
[pytorch learning] torch device
Tree structure --- binary tree 1
钓鱼识别app
Implementation and application of queue
2.4 激活函数
Structure de l'arbre - - - arbre binaire 2 traversée non récursive
FAQ | FAQ for building applications for large screen devices
Short circuit operator lazy evaluation
Mise en œuvre simple de l'équilibrage de la charge par nacos
[ESP nanny level tutorial] crazy completion chapter - Case: chemical environment system detection based on Alibaba cloud and Arduino, supporting nail robot alarm
Is it safe to dig up money and make new shares
JS原型链
Flink interview questions
Redis source code learning (29), compressed list learning, ziplist C (II)
NiO zero copy
2.3 【kaggle数据集 - dog breed 举例】数据预处理、重写Dataset、DataLoader读取数据
How to launch circle of friends marketing and wechat group activities
短路运算符惰性求值
【pytorch】nn.CrossEntropyLoss() 与 nn.NLLLoss()