当前位置:网站首页>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
边栏推荐
- ES6-const本质与完全不可改实现(Object.freeze)
- SDN_简单总结
- Key points of NFT supervision and overseas policies
- FAQ | FAQ for building applications for large screen devices
- NoSQL数据库的安装和使用
- Is it safe to dig up money and make new shares
- [ESP nanny level tutorial preview] crazy node JS server - Case: esp8266 + MQ Series + nodejs local service + MySQL storage
- Flink interview questions
- js重写自己的函数
- R language observation log (part24) -- initialization settings
猜你喜欢

Which method is good for the management of fixed assets of small and medium-sized enterprises?

Learning practice: comprehensive application of cycle and branch structure (II)

How to manage fixed assets well? Easy to point and move to provide intelligent solutions

js作用域链与闭包

Football and basketball game score live broadcast platform source code /app development and construction project

Structure de l'arbre - - - arbre binaire 2 traversée non récursive

I use flask to write the website "one"

dsPIC30F6014a LCD 方块显示

Daily practice of C language - day 80: currency change

An overview of the design of royalties and service fees of mainstream NFT market platforms
随机推荐
【ESP 保姆级教程】疯狂毕设篇 —— 案例:基于阿里云、小程序、Arduino的WS2812灯控系统
js变量提升(hoisting)
MT7628K eCos开发入门
delete和delete[]引发的问题
[ESP nanny level tutorial preview] crazy node JS server - Case: esp8266 + DHT11 +nodejs local service + MySQL database
dsPIC30F6014a LCD 方块显示
Design and manufacture of simple digital display electronic scale
Principle and application of single chip microcomputer timer, serial communication and interrupt system
【pytorch学习】torch.device
R language observation log (part24) -- initialization settings
Which method is good for the management of fixed assets of small and medium-sized enterprises?
[pytorch learning] torch device
3D printing Arduino four axis aircraft
[ESP nanny level tutorial] crazy completion chapter - Case: gy906 infrared temperature measurement access card swiping system based on the Internet of things
[pytorch] softmax function
2.2 【pytorch】torchvision. transforms
How to launch circle of friends marketing and wechat group activities
Daily office consumables management solution
美团2022年机试
Shell script -read command: read data entered from the keyboard