🚨 JavaScript Interview Question What will be the output? const obj = { name: "Frontend", regularFunc: function () { console.log(this.name); }, arrowFunc: () => { console.log(this.name); } }; obj.regularFunc(); obj.arrowFunc(); Both functions are inside the same object. But the output is different. This question tests understanding of: • this binding • Arrow functions vs regular functions • Execution context in JavaScript Many developers assume both will print the same value. What do you think the output will be? #JavaScript #FrontendInterview #ReactJS #FrontendDeveloper #JavaScriptConcepts #ProductBasedCompany
JavaScript this binding in arrow functions vs regular functions
More Relevant Posts
-
🚀 **JavaScript Interview Question** What will be the output of this code? ```js const obj = { a: { b: 0 } }; const v1 = obj?.a?.b || 42; const v2 = obj?.a?.b ?? 42; console.log(v1, v2); ``` 🤔 **Think before you scroll...** --- #JavaScript #Frontend #WebDevelopment #CodingInterview #ReactJS
To view or add a comment, sign in
-
🚨 JavaScript Async Interview Question What will be the output? async function test() { console.log("1"); setTimeout(() => { console.log("2"); }, 0); await Promise.resolve(); console.log("3"); } console.log("4"); test(); console.log("5"); This question tests understanding of: • Call Stack • Async/Await behavior • Microtask queue (Promises) • Macrotask queue (setTimeout) • JavaScript Event Loop Many developers get the order wrong the first time. What do you think the output will be? #JavaScript #FrontendInterview #AsyncJavaScript #EventLoop #ReactJS #FrontendDeveloper #ProductBasedCompany
To view or add a comment, sign in
-
🚀 Day 6 – Frontend Interview Series 🔥 Topic: Promises (Async JavaScript) 💡 What is a Promise? A Promise in JavaScript is an object that represents the result of an asynchronous operation (like API calls, timers, file reading). 👉 It has 3 states: Pending ⏳ Resolved (Fulfilled) ✅ Rejected ❌ 📦 Basic Example const myPromise = new Promise((resolve, reject) => { let success = true; if (success) { resolve("Task completed!"); } else { reject("Task failed!"); } }); myPromise .then((res) => console.log(res)) .catch((err) => console.log(err)); ⚡ Why Promises? 👉 To avoid callback hell 👉 To handle async code in a clean way 👉 Better readability & chaining #JavaScript #ReactJS #FrontendDeveloper #InterviewPrep #AsyncJS
To view or add a comment, sign in
-
🔥 Tricky JavaScript Async/Await Interview Question 🔥 What will be the output of this code? 👇 async function test() { try { console.log("1"); await Promise.reject("Error"); console.log("2"); } catch (e) { console.log("3"); } finally { console.log("4"); } } test(); console.log("5"); 💬 Drop your answer before checking 👇 #JavaScript #FrontendDevelopment #AsyncAwait #Promises #WebDevelopment #InterviewPreparation #ReactJS #CodingInterview #EventLoop #JavaScriptTips #SoftwareEngineering
To view or add a comment, sign in
-
🚨JavaScript Interview Question What will be the output? function greet(name) { if (name === undefined) { console.log("Hello, guest!"); } else { console.log("Hello, "+ name); } greet(); greet("Anas"); greet("Anas", "How are you?"); Looks simple... but there's a twist What will be the output? Why does the last call behave differently? Bonus: How does JavaScript handle extra arguments? #JavaScript #FrontendInterview #WebDevelopment #CodingInterview #ProductBasedCompany
To view or add a comment, sign in
-
Day 3 of my Interview Preparation 🚀 Today I revised some important JavaScript concepts: • What is React? • What is JSX? • Props in React • useState Hook (State management) • Event Handling in React • React Functional Components Consistent learning every day to improve my skills in **JavaScript, React.js, and Web Development**. #javascript #reactjs #webdevelopment #frontenddeveloper #learninginpublic #100daysofcode
To view or add a comment, sign in
-
15 JavaScript interview questions. Promises & Async/Await. Answer karo comments mein 👇 Promises Q1. What is a Promise in JavaScript and why does it exist? Q2. What is the difference between resolve and reject? Q3. What does .then() return? Q4. What is the difference between .catch() and the second argument of .then()? Q5. What does .finally() do? Async/Await Q6. What is async/await and how does it relate to Promises? Q7. What does an async function always return? Q8. Can you use await outside an async function? Q9. What happens if you don't use try/catch with async/await? Q10. What is the difference between sequential and parallel async calls? Promise Methods Q11. What is the difference between Promise.all and Promise.allSettled? Q12. What is Promise.race and when would you use it? React Connection Q13. Why can't useEffect callback be directly async? Q14. What is the standard loading/error/data pattern in React? Q15. What is the difference between async errors and sync errors in React? Full answers + code on GitHub 👇 https://lnkd.in/dj72-XEi #JavaScript #JStoReact #InterviewPrep #WebDevelopment #Frontend #ReactJS #30DayChallenge #JavaScriptTips #FrontendDeveloper #100DaysOfCode
To view or add a comment, sign in
-
🚨 JavaScript Async Interview Question What will be the output? console.log("Start"); setTimeout(() => { console.log("Timeout 1"); }, 0); Promise.resolve() .then(() => { console.log("Promise 1"); }) .then(() => { console.log("Promise 2"); }); setTimeout(() => { console.log("Timeout 2"); }, 0); console.log("End"); Looks simple… But many developers get the order wrong. Because JavaScript doesn’t execute async code the way we intuitively expect. This question tests your understanding of: • Call Stack • Microtask Queue • Macrotask Queue • JavaScript Event Loop What do you think the output will be? #JavaScript #FrontendInterview #EventLoop #ReactJS #FrontendDeveloper #ProductBasedCompany
To view or add a comment, sign in
-
Most developers use JavaScript. Only a few actually understand it deeply. That’s the difference between getting rejected and getting selected in frontend interviews. If you want to stand out, these JavaScript concepts are non-negotiable 👇 🧠 Execution Context, Call Stack & Hoisting 🔒 Closures, Scope & Lexical Environment ⚡ Async JavaScript (Promises, Async/Await, Fetch) 🔁 Event Loop, Microtasks & Callback Queue 🧩 Objects, Prototypes & this keyword 🛠️ Call, Apply, Bind 📦 Arrays (map, filter, reduce) 🚀 ES6+ (Destructuring, Spread, Modules) 🌐 DOM Manipulation & Event Delegation 🔥 Debouncing & Throttling 🧪 Error Handling & Memory Management You need strong JavaScript fundamentals. Master this → You’re already ahead of most developers. #javascript #frontenddeveloper #webdevelopment #reactjs #coding #developers #100DaysOfCode
To view or add a comment, sign in
-
-
One of the most common JavaScript interview questions: "Why does setTimeout with 0ms delay not run immediately?" Most developers cannot answer this correctly. Here is the full explanation: JavaScript is single-threaded. It can only do one thing at a time. The Event Loop is how it manages everything else. The execution order is always the same: 1 — Synchronous code runs first All regular code on the Call Stack executes immediately. 2 — Microtasks run second Promises, async/await — these run before anything else once the Call Stack is empty. 3 — Macrotasks run last setTimeout, setInterval, DOM events — these wait until ALL microtasks are done. This is why setTimeout with 0ms still runs after a Promise. The Promise is a microtask. setTimeout is a macrotask. Microtasks always win. Understanding this prevents real bugs in production — async state updates, race conditions, unexpected render order. Save this post for your next async debugging session. Have you ever been confused by JavaScript async order? Drop a comment below. #JavaScript #WebDevelopment #Frontend #SoftwareEngineering #AsyncJavaScript
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development