Answers for "js is boolean"

4

js is boolean

if (typeof variable === "boolean"){
  // variable is a boolean
}
Posted by: Guest on June-09-2020
0

js Boolean()

// falsy values: false, 0, -0, 0n, null, undefined, NaN, and the empty string ""
console.log(Boolean(false)) // false
console.log(Boolean(0)) // false
console.log(Boolean(-0)) // false
console.log(Boolean(0n)) // false
console.log(Boolean(null)) // false
console.log(Boolean(undefined)) // false
console.log(Boolean(NaN)) // false
console.log(Boolean("")) // false
console.log(typeof Boolean("")) // boolean

// truthy values: true, 1, -1, 1n, -1n, Infinity, -Infinity, " ", {}, []
console.log(Boolean(true)) // true
console.log(Boolean(1)) // true
console.log(Boolean(-1)) // true
console.log(Boolean(1n)) // true
console.log(Boolean(-1n)) // true
console.log(Boolean(Infinity)) // true
console.log(Boolean(-Infinity)) // true
console.log(Boolean(" ")) // true
console.log(Boolean({})) // true
console.log(Boolean([])) // true
console.log(typeof Boolean([])) // boolean
Posted by: Guest on August-23-2021
0

boolean javascript

var a = 2;
var b =  3;
var c =  2;
(a == b) // returns false
(a == c) //returns true
Posted by: Guest on July-25-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language