In JavaScript there are 5 different data types that can contain values:

There are 6 types of objects:

And 2 data types that cannot contain values:

1. The typeof Operator

You can use the typeof operator to find the data type of a JavaScript variable.

typeof "Kaarthik"             // Returns "string"
typeof 3.14                   // Returns "number"
typeof NaN                    // Returns "number"
typeof false                  // Returns "boolean"
typeof [1,2,3,4]              // Returns "object"
typeof {name:'Jon', age:34}   // Returns "object"
typeof new Date()             // Returns "object"
typeof function () {}         // Returns "function"
typeof myCar                  // Returns "undefined" *
typeof null                   // Returns "object"

2. Type Coercion