1️⃣ Q: What is the difference between
let, const, and var?A:
-
var: Function-scoped, hoisted, can be redeclared. -
let: Block-scoped, not hoisted like var, can't be redeclared in same scope. -
const: Block-scoped, must be assigned at declaration, cannot be reassigned.2️⃣ Q: What are JavaScript data types?
A:
- Primitive types: string, number, boolean, null, undefined, symbol, bigint
- Non-primitive: object, array, function
Type coercion: JS automatically converts between types in operations (
'5' + 2 → '52')3️⃣ Q: How does DOM Manipulation work in JS?
A:
The DOM (Document Object Model) represents the HTML structure. JS can access and change elements using:
-
document.getElementById() -
document.querySelector() -
element.innerText, element.innerHTML, element.style etc.4️⃣ Q: What is event handling in JavaScript?
A:
It allows reacting to user actions like clicks or key presses.
Example:
document.getElementById("btn").addEventListener("click", () => {
alert("Button clicked!");
});5️⃣ Q: What are arrow functions?
A:
A shorter syntax for functions introduced in ES6.
const add = (a, b) => a + b;
💬 Double Tap ❤️ For More