Understanding the types in JavaScript

TypeScript adds a rich type system to JavaScript. Before we start to use this rich type system, we need to learn what types we have in JavaScript.

Primitive types in JavaScript #

JavaScript does have some basic primitive types, but what are they?

The JavaScript code below outputs the types of four variables with various kinds of values. We’d hope for string, number, boolean, and date to be output … but is this the case? Run the code and find out.

Get hands-on with 1200+ tech skills courses.