JavaScript Tutorial Part 4 – Primitives

JavaScript Tutorial For Beginners

Learning Curve Books:
Follow on Twitter:

There are 7 primitive data types in JavaScript (object may or may not be a primitive per se, but it is often used in the discussion of primitive data types in JavaScript.) EcmaScript6 adds a new primitive data type called Symbol.

var a = undefined;
console.log(typeof(a)); // “undefined”

a = “Hello there.”;
console.log(typeof(a)); // “string”
console.log(a.valueOf()); // “Hello there.”

a = 75;
console.log(typeof(a)); // “number”
console.log(a.valueOf()); // 75

a = true;
console.log(typeof(a)); // “boolean”

a = null;
console.log(typeof(a)); // “object” (“null”-object)

a = {a:1}; // object literal
console.log(typeof(a)); // “object”

a = Symbol(); // EcmaScript6
console.log(typeof(a)); // “symbol”

Probably related keywords:
JavaScript primitives / primitive types / javascript primitive types and reference types / primitive data type / primitive data types / JavaScript primitive types vs objects

Self-education + Computer Literacy
For next generation of teachers,
artists, coders, designers, and makers of things:
Learning Curve Books:

Original source

4 thoughts on “JavaScript Tutorial Part 4 – Primitives

Leave a Reply