The Wayback Machine - https://web.archive.org/web/20240118170354/https://www.geeksforgeeks.org/javascript-boolean-reference/
Open In App
Related Articles

JavaScript Boolean Reference

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

JavaScript Boolean is a datatype that returns either true or false In JavaScript, a boolean is used as a function to get the value of a variable, object, conditions, expressions, etc in terms of true or false

Syntax:

Boolean(variable/expression) 
 

Example: If the operands are equal, the equal to operator == returns true

Javascript




<script>
    console.log(15 == 15)
    console.log(15 == 11)
</script>


Output:

true
false

The complete list of JavaScript Boolean has listed below:

JavaScript Boolean Constructor: A constructor gets called when an object is created using the new keyword.

Constructor Descriptions Examples
Boolean() Create Boolean objects or return primitive values of type boolean.
Try

JavaScript Boolean Properties: A JavaScript property is a member of an object that associates a key with a value.

  • Instance Property: An instance property is a property that has a new copy for every new instance of the class.

Instance Properties Descriptions Examples
constructor Add a new property and methods to all Boolean instances.
Try

JavaScript Boolean Methods: Methods are actions that can be performed on objects.

  • Instance Method: If the method is called on an instance of a boolean then it is called an instance method.

Instance Methods Descriptions Examples
valueOf() Returns the value of boolean object.
Try

toString() Returns a string according to the Boolean value.
Try

Learn to code easily with our course Coding for Everyone. This course is accessible and designed for everyone, even if you're new to coding. Start today and join millions on a journey to improve your skills!

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore.
Last Updated : 23 May, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads
Complete Tutorials