Category: javascript
Variables
Published on 29 Jun 2026
Explanation
Variables store values in JavaScript. The keywords var, let, and const are used to declare variables.
Code:
let name = 'John'; const age = 25;
Explanation
JavaScript supports primitive data types such as String, Number, Boolean, Undefined, and Null.
Code:
let city = 'Chennai'; let score = 95; let active = true;
Explanation
The typeof operator returns the data type of a variable.
Code:
console.log(typeof 'Hello'); console.log(typeof 100);
Explanation
Objects and Arrays are non-primitive data types used to store collections of data.
Code:
const student = { name: 'John', age: 22 };
const skills = ['HTML', 'CSS'];
Explanation
Variables declared with let can be reassigned, while const variables cannot.
Code:
let count = 1; count = 2; const country = 'India';