Boolean 2/4
Boolean Data Type
We use the typeof
operator to check the data type of variables, for example.
9
1
2
3
4
let isRaining = true;
console.log(typeof isRaining);
// or like this
console.log(typeof(isRaining));
1234let isRaining = true; console.log(typeof isRaining); // or like this console.log(typeof(isRaining));
As you can see in the above code we declared a variable named isRaining
with the value of true
, and its data type is boolean
as expected.
Uppgift
Swipe to start coding
Declare a variable with the name isSunRises
and set its value as true
. Then check the type of isSunRises
by using typeof()
and display the output.
Lösning
9
1
2
let isSunRises = true;
console.log(typeof(isSunRises));
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 3. Kapitel 16
single
9
1
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal