Js Inter View
Js Inter View
Let's begin your JavaScript preparation with structured and deep concepts,
especially for interviews.
✅ 1. JavaScript Overview
🔹 What is JavaScript?
JavaScript is a scripting language used to create dynamic and interactive web content like
sliders, form validation, animations, and much more. It runs in the browser and can also be used on
the server via Node.js.
Non-primitive:
• Object (including Array, Function, Date, etc.)
✅ ✅ ❌
Hoisting Hoisted (initialized as undefined) Hoisted (not initialized) Same as let
✅ ❌ ❌
Reassignable Yes Yes No
Redeclarable Yes No No
3. What is hoisting?
Hoisting is JavaScript’s default behavior of moving declarations to the top of the current scope
during compilation.
console.log(a); // undefined
var a = 5;
✅ Next Topics:
Would you like me to continue with:
• JavaScript OOP (Object, Class, Inheritance)?
• Array methods (map, filter, reduce)?
• Asynchronous JS (Promise, async/await, fetch)?
• Practical coding questions?
Let me know what you want to focus on next — I’ll guide step-by-step.
Great Aryan! Let's continue with JavaScript Interview Prep, covering each core concept with
examples and explanations.
🔹 What is a Class?
Introduced in ES6, it provides a blueprint for creating objects.
class Car {
constructor(brand) {
this.brand = brand;
}
start() {
console.log(`${this.brand} started`);
}
}
const myCar = new Car("Toyota");
myCar.start();
🔹 Inheritance
class Vehicle {
drive() {
console.log("Driving...");
}
}
class Bike extends Vehicle {
wheelie() {
console.log("Doing wheelie!");
}
}
const myBike = new Bike();
myBike.drive();
myBike.wheelie();
✅ 2. Array Methods
🔸 map() – transforms each element
const nums = [1, 2, 3];
const squares = nums.map(n => n * n); // [1, 4, 9]
✅ 3. Asynchronous JavaScript
🔹 Callbacks
function greet(callback) {
console.log("Hello");
callback();
}
greet(() => console.log("Goodbye"));
🔹 Promises
const promise = new Promise((resolve, reject) => {
resolve("Data loaded");
});
🔹 async/await
async function fetchData() {
let res = await fetch("https://api.example.com");
let data = await res.json();
console.log(data);
}
🔹 Check Palindrome
function isPalindrome(str) {
return str === str.split("").reverse().join("");
}
🔹 FizzBuzz
for (let i = 1; i <= 15; i++) {
let output = "";
if (i % 3 === 0) output += "Fizz";
if (i % 5 === 0) output += "Buzz";
console.log(output || i);
}