Hackforge Academy

Category: react

Variables in javascript

Published on 23 Jun 2026

Explanation

Variables are used to store data in JavaScript. The keywords var, let, and const are used to declare variables. Modern JavaScript primarily uses let and const.

Code:

let name = 'Praveen';
const company = 'HackForge Academy';
console.log(name, company);

Explanation

JavaScript supports several primitive data types including String, Number, Boolean, Undefined, Null, and BigInt.

Code:

let username = 'John';
let age = 25;
let isActive = true;
let city;
let salary = null;

Explanation

The typeof operator is used to determine the data type of a variable at runtime.

Code:

console.log(typeof 'Hello');
console.log(typeof 100);
console.log(typeof true);

Explanation

JavaScript also supports complex data types such as Objects and Arrays, which can store collections of related data.

Code:

const student = {
  name: 'John',
  age: 22
};

const skills = ['HTML', 'CSS', 'JavaScript'];

Explanation

Variables can be updated when declared with let, while const variables cannot be reassigned after initialization.

Code:

let score = 50;
score = 75;

const country = 'India';
// country = 'USA'; // Error

๐Ÿš€ Learn Spring Boot with real-world projects

๐Ÿ’ก Build REST APIs step by step

๐Ÿง  Improve backend development skills

๐ŸŽฏ Get career-ready practical training

Join Our Free WhatsApp Community

Direct access to niche-specific mentors and peers on WhatsApp.

๐Ÿ

Python Community

Discuss Django, FastAPI, AI integration, and automation scripts with 15k+ developers.

Join Python Community
โš›๏ธ

React Community

Master Next.js, Framer Motion, and State Management. Share your latest UI components.

Join React Community
โ˜•

Java Community

Deep dives into Spring Boot, Microservices architecture, and high-performance backend ops.

Join Java Community