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

How to use valueof method in JavaScript

藏色散人
Release: 2023-01-07 11:47:14
Original
3709 people have browsed it

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()
Copy after login

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>
Copy after login

Output:

false
Copy after login

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!

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