Home > Article > Web Front-end > How to use valueof method in JavaScript
The valueof method in JavaScript is used to return the original value of the Boolean object. Its usage syntax is "booleanObject.valueOf()", and the return value is the original Boolean value of the booleanObject.
The operating environment of this article: windows7 system, javascript version 1.8.5, Dell G3 computer.
How to use the valueof method in JavaScript?
JavaScript valueOf() method
Its definition and usage
The valueOf() method returns the original value of a Boolean object.
Syntax
booleanObject.valueOf()
Return value: the original Boolean value of booleanObject.
Throws: If the object calling this method is not Boolean, a TypeError exception is thrown.
Usage example:
In this example, we will create a Boolean object and use valueOf() to get the original value of this object:
<script type="text/javascript"> var boo = new Boolean(false) document.write(boo.valueOf()) </script>
Output:
false
Recommended study: "javascript basic tutorial"
The above is the detailed content of How to use valueof method in JavaScript. For more information, please follow other related articles on the PHP Chinese website!