Javascript Boolean valueOf() method is used to return a boolean value, either true or false, depending on the value of the boolean object.
Syntax
boolean.valueOf()
Parameters
It doesn’t accept any parameter.
Return Value
It returns a boolean value, either true or false.
Example 1: How to Use JavaScript Boolean valueOf() Method
let data = new Boolean(79);
console.log(data.valueOf());
let data2 = new Boolean("askjavascript");
console.log(data2.valueOf());
Output
true
true
Example 2: Boolean object with value 0
let data3 = new Boolean(0);
console.log(data3.valueOf());
Output
false
Example 3: Boolean object with value -1
let data4 = new Boolean(-1);
console.log(data4.valueOf());
Output
true
Example 4: Boolean object with value 1
let data5 = new Boolean(1);
console.log(data5.valueOf());
Output
true
Example 5: Boolean object with true and false value
let data6 = new Boolean(true);
console.log(data6.valueOf());
let data7 = new Boolean(false);
console.log(data7.valueOf());
Output
true
false
Example 6: Boolean object with conditional expression
let age = 24;
let isAdult = new Boolean(age >= 18);
let result = isAdult.valueOf();
console.log(result);
true
Example 7: Boolean object with Empty String
let data8 = new Boolean("");
console.log(data8.valueOf());
Output
false
Example 8: Boolean object with complex value
let data9 = new Boolean(2 + 4kl);
console.log(data9.valueOf());
Output
SyntaxError: Invalid or unexpected token
Browser Compatibility
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
That’s it!
Related posts
JavaScript Boolean() Constructor

Krunal Lathiya is a seasoned Computer Science expert with over eight years in the tech industry. He boasts deep knowledge in Data Science and Machine Learning. Versed in Python, JavaScript, PHP, R, and Golang. Skilled in frameworks like Angular and React and platforms such as Node.js. His expertise spans both front-end and back-end development. His proficiency in the Python language stands as a testament to his versatility and commitment to the craft.