DEV Community

Cover image for My First Steps in JavaScript: A Simple Breakdown
Harini
Harini

Posted on

My First Steps in JavaScript: A Simple Breakdown

For the last two days, I’ve been learning the basics of JavaScript, and it has been really fun and easy to understand. These topics may look simple, but they are the building blocks for everything we will write in the future. So I wanted to share what I learned in a clear and beginner-friendly way.

1. Variables in JavaScript
Variables are like containers that store information.
In JavaScript, we mostly use three ways to create them:

let

  • Used for values that can change later.
let age = 20;
age = 21;
Enter fullscreen mode Exit fullscreen mode

const

  • Used when the value should not be changed.
const PI = 3.14;

Enter fullscreen mode Exit fullscreen mode

var

  • The old way of declaring variables.
  • Not recommended now because it creates confusion with scope.

2. Data Types in JavaScript
JavaScript has two main groups of data types.
Primitive Types

  • String → "Hello"
  • Number → 23, 45.6
  • Boolean → true or false
  • Null → empty value
  • Undefined → no value assigned
  • BigInt → very large numbers
  • Symbol → unique values

Non-Primitive Types

  • Object
  • Array
  • Function

3. Undefined vs Null
Two things that confused me at first but now feel very clear.

undefined

  • Means a variable exists but has no value yet.
let x;
console.log(x); // undefined

Enter fullscreen mode Exit fullscreen mode

null

  • Means intentionally empty. We set it manually when something should have no value.
let data = null;

Enter fullscreen mode Exit fullscreen mode

Top comments (0)