Skip to main content

Javascript Data types

According to ECMAScript standard Javascript has seven data types. Six data types that are primitives and one is non primitive

This are the primitive datatype

  1. Boolean. true and false.
  2. null. A special keyword denoting a null value. Because JavaScript is case-sensitive, null is not the same as Null, NULL, or any other variant.
  3. undefined. A top-level property whose value is undefined.
  4. Number. 42 or 3.14159.
  5. String. “Howdy”
  6. Symbol (new in ECMAScript 2015). A data type whose instances are unique and immutable.

And non primitive is Object

The undefined value behaves as false when used in a Boolean context but in numeric context it behave like NaN

var myVal;

console.log(typeof myVal);//"undefined"
// In boolean context

if(!myVal) console.log("I am undefined");//"I am undefined"

// In numeric context

console.log(myVal * 4);//NaN