Surya JS Journey

Learn JavaScript through concepts, code, and guided practice.

A focused workspace for concept study, interactive examples, visual explanations, and challenge solving.

Core JavaScriptBeginner

Data Types

JavaScript has primitive and reference data types, and knowing the difference affects comparison, copying, and mutation.

The main primitive types are string, number, bigint, boolean, undefined, symbol, and null. Objects, arrays, and functions are reference types. A strong grasp of JavaScript data types helps you understand how values are stored, passed around, and checked in real programs.

Explanation

The main primitive types are string, number, bigint, boolean, undefined, symbol, and null. Objects, arrays, and functions are reference types. A strong grasp of JavaScript data types helps you understand how values are stored, passed around, and checked in real programs.

Key Points

  • Primitive values are copied by value.
  • Objects and arrays are reference types and can be mutated through shared references.
  • `typeof null` is a historical JavaScript quirk and returns `"object"`.

Common Mistakes

  • Treating arrays as a primitive value instead of an object reference.
  • Relying only on `typeof` when you actually need to detect arrays or null.
  • Assuming copied object variables are independent copies.

Practice Workspace

data-types.js

Edit the code, run it in the browser, and inspect the console output below. Reset restores the original snippet for this page.

Editor

3 lines

Output

0 entries

Mode

practice

Workspace Notes

Changes stay local until you run the code. Reset restores the original snippet immediately for another pass.

Live editing

Safe to change before every run.

Fast reset

Return to the original starter instantly.

data-types.js
3 linesMonaco Editor
Loading...

Editor Actions

Use the editor to explore the example, then run it to inspect the console.

Console0 entries

Run the code to see output here.

Expected Output

number
object
true

Continue in Playground

Open this concept example in the shared playground to keep experimenting without leaving the broader workspace flow.

Open in Playground