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!