Loading

Quipoin Menu

Learn • Practice • Grow

java-script / Variables
interview

Q1. What is a Variable in JavaScript?
A variable is a container used to store data values. It allows developers to store, update, and reuse data in a program.

Example
let name = "John";
console.log(name);

Output
John

Here, name is a variable that stores the value "John".


Q2. How Do You Declare Variables in JavaScript?
JavaScript provides three keywords to declare variables:
  • var
  • let
  • const
Example
var age = 20;
let city = "London";
const country = "UK";

Each keyword has different behavior and usage rules.


Q3. What is Variable Scope?
Scope defines where a variable can be accessed in the program.

Types of Scope

1. Global Scope
Variable cna be accessed anywhere.
let name = "Alex";


2. Block Scope
Variable can only be accessed inside a block { }.
{
    let age = 25;
}


Q4. What is Variable Initialization?
Initialization means assigning a value to a variable when it is declared.

Example
let score = 100;

Here:
  • score → Variable name
  • 100 → Assigned value