0% found this document useful (0 votes)
3 views5 pages

Js Inter View

This document provides a comprehensive overview of JavaScript, covering its core concepts, interview questions, object-oriented programming, array methods, and asynchronous JavaScript. Key topics include data types, variable declarations, closures, event handling, and practical coding challenges. The document also offers guidance on further topics to explore in JavaScript preparation for interviews.

Uploaded by

Aryan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views5 pages

Js Inter View

This document provides a comprehensive overview of JavaScript, covering its core concepts, interview questions, object-oriented programming, array methods, and asynchronous JavaScript. Key topics include data types, variable declarations, closures, event handling, and practical coding challenges. The document also offers guidance on further topics to explore in JavaScript preparation for interviews.

Uploaded by

Aryan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Great Aryan!

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.

✅ 2. Core JavaScript Interview Questions & Answers


1. What are the data types in JavaScript?
Primitive types:
• String, Number, Boolean, BigInt, Null, Undefined, Symbol

Non-primitive:
• Object (including Array, Function, Date, etc.)

2. What is the difference between var, let, and const?


Feature var let const
Scope Function-scoped Block-scoped Block-scoped

✅ ✅ ❌
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;

4. What is closure in JS?


A closure is a function that remembers variables from its outer scope, even after that scope has
closed.
function outer() {
let count = 0;
return function inner() {
count++;
console.log(count);
}
}
const counter = outer();
counter(); // 1
counter(); // 2

5. What is the difference between == and ===?


• == compares value after type coercion.

• === compares value and type (strict equality).


'5' == 5 // true
'5' === 5 // false

6. What are arrow functions?


Arrow functions provide a shorter syntax and do not bind their own this.
const add = (a, b) => a + b;

7. What is the DOM?


DOM (Document Object Model) is a tree-like structure that represents the HTML structure of a
webpage.

8. Difference between null and undefined


Feature null undefined
Meaning Assigned empty value Variable not assigned yet
Type Object Undefined

9. What is event bubbling and capturing?


• Bubbling: Event propagates from child to parent.
• Capturing: Event propagates from parent to child.
element.addEventListener('click', handler, true); // capturing
element.addEventListener('click', handler, false); // bubbling
10. What is a callback function?
A function passed as an argument to another function, to be executed later.
function greet(name, callback) {
console.log("Hello", name);
callback();
}
greet("Aryan", () => console.log("Welcome!"));

✅ 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.

✅ 1. JavaScript Object-Oriented Programming (OOP)


🔹 What is an Object in JavaScript?
An object is a collection of key-value pairs.
const person = {
name: "Aryan",
age: 22,
greet() {
console.log("Hello, " + this.name);
}
};
person.greet(); // Hello, Aryan

🔹 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]

🔸 filter() – selects elements that match condition


const even = nums.filter(n => n % 2 === 0); // [2]

🔸 reduce() – accumulates result


const sum = nums.reduce((acc, n) => acc + n, 0); // 6

🔸 find() – first matching value


const val = nums.find(n => n > 1); // 2

🔸 forEach() – executes a function for each item


nums.forEach(n => console.log(n));

✅ 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");
});

promise.then(data => console.log(data)); // Data loaded

🔹 async/await
async function fetchData() {
let res = await fetch("https://api.example.com");
let data = await res.json();
console.log(data);
}

✅ 4. Practical Coding Questions


🔹 Reverse a String
function reverse(str) {
return str.split("").reverse().join("");
}

🔹 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);
}

Would you like next:


• DOM and Event Handling questions?
• JS Execution Context, Hoisting, and Scope?
• JS Project-based Questions (like Login validation, Search bar)?
Let me know — we’ll continue smartly.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy