JavaScript Data types

Beginner
6 min read
Updated: Nov 2026

Definition and Usage

JavaScript values are either primitives (string, number, boolean, null, undefined, symbol, bigint) or Objects (including arrays and functions).

JavaScript Syntax

JavaScript
console.log(typeof "hi");
console.log(typeof 1);
console.log(typeof true);
console.log(typeof undefined);
console.log(typeof Symbol());
console.log(typeof 1n);
console.log(typeof null);
Try it Editor

How It Works

  1. typeof. Reports the type tag.
  2. null quirk. typeof null is "object" for historical reasons.

Examples

Example 1 — Objects and arrays

Both are objects.

JavaScript
console.log(typeof {});
console.log(typeof []);
console.log(Array.isArray([]));
Try it Editor

How It Works

  1. Use Array.isArray for arrays.

Example 2 — Functions

Callable objects.

JavaScript
console.log(typeof function () {});
Try it Editor

How It Works

  1. typeof distinguishes functions.

Example 3 — See coercion

Types convert in operations.

JavaScript
console.log("5" * "2");
Try it Editor

How It Works

  1. Strings become numbers for *.

Frequently Asked Questions

Seven: string, number, bigint, boolean, undefined, symbol, null.
No. Primitives are not objects, though they can be temporarily wrapped for methods.

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful