Home > Web Front-end > JS Tutorial > valueOf() function and toString() function usage

valueOf() function and toString() function usage

巴扎黑
Release: 2017-07-22 15:22:50
Original
1327 people have browsed it

valueOf(): If any primitive value exists, returns the primitive value that best fits the object type.

toString(): Return the original value of the object in string form.

This The two methods are generally called implicitly by JS to meet different operating conditions.


Give me an example: Look at the picture ( Don't worry about the two undefined), the colors of true returned by the two methods are different! Because toString() returns a string, and valueOf() returns the original value.


##END


The above is the detailed content of valueOf() function and toString() function usage. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template