# DAY 2 JAVASCRIPT CORE CONCEPTS CHEATSHEET

Introduction Welcome to Day 2 of your JavaScript learning journey! Today, we’ll dive deep into the Core Concepts of JavaScript that every beginner must know before building real-world projects. Mastering these basics will make your coding life easier and help you understand advanced topics faster. 1. VARIABLES IN JAVASCRIPT Variables are containers used to store data values. Declaring Variables: var name = "Dhanian"; // Old way let age = 25; // Modern & Recommended const country = "Kenya"; // Cannot be changed Keyword Usage Can Reassign var Avoid using Yes let Recommended Yes const Recommended No (constant) 2. DATA TYPES IN JAVASCRIPT JavaScript has 8 basic data types: String → Text → "Hello" Number → 123, 45.6 Boolean → true or false Undefined → Value not assigned Null → Empty or unknown Object → Complex data Symbol → Unique identifiers BigInt → Large integers Example: let name = "Dhanian"; // String let age = 25; // Number let isOnline = true; // Boolean let city; // Undefined let car = null; // Null 3. OPERATORS IN JAVASCRIPT Type Example Meaning Arithmetic + - * / % Math operations Assignment = += -= Assign values Comparison == === != Compare values Logical && Example: let a = 10; let b = 5; console.log(a + b); // 15 console.log(a > b); // true console.log(a == 10); // true 4. CONDITIONAL STATEMENTS Make decisions in your code. if / else if / else let age = 18; if (age >= 18) { console.log("You are an adult."); } else { console.log("You are a minor."); } 5. SWITCH STATEMENT let day = "Monday"; switch(day) { case "Monday": console.log("Start of the week"); break; case "Friday": console.log("Weekend loading..."); break; default: console.log("Just another day"); } 6. LOOPS IN JAVASCRIPT Loops help us repeat tasks. for loop for(let i = 1; i

Apr 10, 2025 - 06:36
 0
# DAY 2 JAVASCRIPT CORE CONCEPTS CHEATSHEET

Introduction

Welcome to Day 2 of your JavaScript learning journey!

Today, we’ll dive deep into the Core Concepts of JavaScript that every beginner must know before building real-world projects.

Mastering these basics will make your coding life easier and help you understand advanced topics faster.

1. VARIABLES IN JAVASCRIPT

Variables are containers used to store data values.

Declaring Variables:

var name = "Dhanian";  // Old way
let age = 25;          // Modern & Recommended
const country = "Kenya"; // Cannot be changed
Keyword Usage Can Reassign
var Avoid using Yes
let Recommended Yes
const Recommended No (constant)

2. DATA TYPES IN JAVASCRIPT

JavaScript has 8 basic data types:

  • String → Text → "Hello"
  • Number → 123, 45.6
  • Boolean → true or false
  • Undefined → Value not assigned
  • Null → Empty or unknown
  • Object → Complex data
  • Symbol → Unique identifiers
  • BigInt → Large integers

Example:

let name = "Dhanian";  // String
let age = 25;          // Number
let isOnline = true;   // Boolean
let city;              // Undefined
let car = null;        // Null

3. OPERATORS IN JAVASCRIPT

Type Example Meaning
Arithmetic + - * / % Math operations
Assignment = += -= Assign values
Comparison == === != Compare values
Logical &&

Example:

let a = 10;
let b = 5;

console.log(a + b);   // 15
console.log(a > b);   // true
console.log(a == 10); // true

4. CONDITIONAL STATEMENTS

Make decisions in your code.

if / else if / else

let age = 18;

if (age >= 18) {
  console.log("You are an adult.");
} else {
  console.log("You are a minor.");
}

5. SWITCH STATEMENT

let day = "Monday";

switch(day) {
  case "Monday":
    console.log("Start of the week");
    break;
  case "Friday":
    console.log("Weekend loading...");
    break;
  default:
    console.log("Just another day");
}

6. LOOPS IN JAVASCRIPT

Loops help us repeat tasks.

for loop

for(let i = 1; i <= 5; i++) {
  console.log(i);
}

while loop

let i = 1;
while(i <= 5) {
  console.log(i);
  i++;
}

7. FUNCTIONS IN JAVASCRIPT

Functions perform specific tasks.

Function Declaration

function greet() {
  console.log("Hello World");
}

greet();

Function with Parameters

function add(a, b) {
  return a + b;
}

console.log(add(5, 3));  // 8

8. ARRAYS IN JAVASCRIPT

Arrays store multiple values in one variable.

let fruits = ["Mango", "Banana", "Apple"];

console.log(fruits[0]);  // Mango

Array Methods

fruits.push("Orange");   // Add item
fruits.pop();            // Remove last item
console.log(fruits.length); // Count items

9. OBJECTS IN JAVASCRIPT

Objects store data in key-value pairs.

let person = {
  name: "Dhanian",
  age: 25,
  country: "Kenya"
};

console.log(person.name);  // Dhanian

10. JAVASCRIPT OUTPUT METHODS

Method Usage
console.log() Output to console
alert() Popup alert box
document.write() Write to HTML

EXTRA RESOURCE FOR YOU!

Get the Complete JavaScript Ebook

For Beginners to Advanced → With Code Examples & Projects!