Home  >  Article  >  Web Front-end  >  How to use valueof method in JavaScript

How to use valueof method in JavaScript

藏色散人
藏色散人Original
2021-09-03 17:16:143704browse

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.

How to use valueof method in JavaScript

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!

Statement:
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