Surya JS Journey
Learn JavaScript through concepts, code, and guided practice.
A focused workspace for concept study, interactive examples, visual explanations, and challenge solving.
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.
Editor Actions
Use the editor to explore the example, then run it to inspect the console.
Run the code to see output here.
Expected Output
number
object
trueContinue in Playground
Open this concept example in the shared playground to keep experimenting without leaving the broader workspace flow.
Open in PlaygroundRelated Concepts
Type Coercion
Type coercion is JavaScript converting one value type into another during operations or comparisons.
Objects
Objects store related data and behavior as key-value pairs and are one of JavaScript’s core building blocks.
Arrays and Methods
Arrays hold ordered collections of values, and their built-in methods make transformation and iteration much easier.