60. Difference Between Synchronous and Asynchronous Programming
Synchronous : Executes line by line
Asynchronous : Executes independently
Example:
setTimeout(() => {
console.log("Hello");
}, 2000);
🧠 61. What is Promise in JavaScript?
Promise handles asynchronous operations.
States:
• Pending
• Resolved
• Rejected
Example:
const promise = new Promise((resolve, reject) => {
resolve("Success");
});
🧠 62. What are async and await?
Used to simplify asynchronous code.
Example:
async function getData() {
const response = await fetch(url);
}
🧠 63. What is setTimeout?
Runs code after specific delay.
Example:
setTimeout(() => {
console.log("Hello");
}, 3000);
🧠 64. Difference Between map(), filter(), and reduce()
Method : Purpose
map() : Transform array
filter() : Filter array
reduce() : Reduce array to single value
Example:
const nums = [1,2,3];
nums.map(n => n * 2);
🧠 65. What is Destructuring?
Extract values from arrays or objects.
Example:
const person = {
name: "Deepak"
};
const { name } = person;
🧠 66. What is Spread Operator?
Spread operator expands elements.
Example:
const arr1 = [1,2];
const arr2 = [...arr1, 3];
🧠 67. What is Rest Operator?
Collects multiple values into array.
Example:
function sum(...nums) {
console.log(nums);
}
🧠 68. What is Template Literal?
Template literals allow embedded expressions.
Example:
let name = "Narayan";
console.log(Hello ${name});
🧠 69. What is Optional Chaining?
Safely accesses nested properties.
Example:
user?.address?.city
🧠 70. Explain this Keyword
this refers to current object.
Example:
const user = {
name: "Radhe",
greet() {
console.log(this.name);
}
};
🧠 71. Difference Between Function Declaration and Function Expression
Declaration : Hoisted
Expression : Not fully hoisted
Example:
function test() {}
const demo = function() {};
🧠 72. What is Prototype?
Prototype allows inheritance in JavaScript.
Example:
function Person() {}
Person.prototype.age = 25;
🧠 73. What is Prototypal Inheritance?
Objects inherit properties from other objects.
Example:
child.proto = parent;
🧠 74. What is JSON?
JSON stands for: 👉 JavaScript Object Notation
Used for data exchange.
Example:
{
"name": "Sanyam",
"age": 26
}
🧠 75. Difference Between localStorage and sessionStorage
localStorage : Permanent
Shared across tabs
sessionStorage : Temporary
Limited to tab
🧠 76. What is NaN?
NaN means: 👉 Not a Number
Example:
console.log("abc" / 2);
🧠 77. What are Truthy and Falsy Values?
Falsy Values:
• false
• 0
• ""
• null
• undefined
• NaN
Everything else is truthy.
🧠 78. What is Debounce?
Debounce limits repeated function calls.
Used in:
• Search bars
• Resize events
Example:
function debounce(fn, delay) {}
🧠 79. What is Throttle?
Throttle limits execution rate.
Example:
function throttle(fn, limit) {}
**🧠 80.
What is Currying?**
Currying converts function with multiple arguments into nested functions.
Example:
function add(a) {
return function(b) {
return a + b;
};
}
Double Tap ❤️ For Part-4
Post #3757
2.97K
- ❤ 12