TypeScript boolean

TypeScript boolean object:

A TypeScript Boolean object can represents two values “true” or “false”.

How to create TypeScript boolean object:

  • By using boolean literals.
  • By using Boolean() constructor.

Syntax:

Var b1:boolean = true;
var b2:boolean = new Boolean(value);

Example:

function booleanTest(bVar:boolean):void{
  console.log(bVar.valueOf()); 
}
var boolean1:boolean=new Boolean(true);
var boolean2:boolean=new Boolean(false); 
var boolean3:boolean=true;
booleanTest(boolean1);
booleanTest(boolean2);
booleanTest(boolean3);