+ 16
What is the difference between toString() and valueOf()?
var x =123; (100+23).toString() //returns 123 (100+23).valueOf() //returns 123 this two method what exactly define?
3 ответов
+ 13
thank you ☺
+ 2
toString() coherses the data to a string and valueOf() returns the value of the string (if used in the context of the example)
so toString() will return “123” and valueOf() will return 123