Essential JavaScript
Introduction
JavaScript Basics
Numbers
Strings
Logic
Variables
Loops
Objects
Arrays
Going Further
Essential JavaScript
Introduction
JavaScript Basics
Numbers
Strings
Logic
Variables
Loops
Objects
Arrays
Going Further
Boolean Values
You've probably heard that computers think in ones and zeroes. This is true.
In the black-and-white world of computers, we have a type of data that can be only one of two values: true
or false
. These are called Boolean values.
Try running this code in the editor:
true
Notice how it doesn't throw an error, but returns true
as the result? Both true
and false
are JavaScript keywords.
Remember that JavaScript only recognizes certain keywords as valid code. Any of these words would throw an error:
test
correct
wrong
Many aspects of programming are built on Boolean values. We can make something happen only if a condition is true
or false
. We can use these values to represent on/off switches in user settings or app configuration.
Now that you know what a Boolean value is, we can start working with them.
Learning Goals
I know what a Boolean value is
I know the two keywords for creating a Boolean value
Code Editor
Click "Run Code" to execute your JavaScript in a secure sandbox and see the output below.
Console Output
0 output lines