JavaScript Variables & Types

Explore JavaScript variables, data types, and type coercion through interactive code exercises.

Category: Programming · v1.0.0
Step 1 of 4

Step 1: Declaring Variables

JavaScript has three ways to declare variables:

  • let — block-scoped, can be reassigned
  • const — block-scoped, cannot be reassigned
  • var — function-scoped (older, avoid in modern code)

Try it out — run the code, then experiment by changing values:

About This Lab

Variables are the building blocks of any program. In this lab, you'll learn how to declare variables with let, const, and var, understand JavaScript's core data types (strings, numbers, booleans, arrays, objects), and see how type coercion works. Each step includes a live code editor so you can experiment and see results instantly.

How It Works

  1. Read the explanation for each concept
  2. Experiment with the code in the editor
  3. Click 'Run Code' to execute and see output
  4. Try modifying the examples to deepen your understanding
  5. Complete the final quiz to test your knowledge