JavaScript Fundamentals in Interviews: Destructuring and Rest Parameters

Hey Devs, 🚨 Thought-provoking fundamental questions from an interview Years of experience don’t protect you from fundamental questions in interviews. Recently during an interview, I was asked a couple of simple yet thought-provoking JavaScript questions. They weren’t complex problems, but they really tested whether I truly understand the fundamentals. The interviewer framed the questions like this: const person = { name: "Jeff", age: 26 }; 🧠 Question 1 If I destructure the object like this: const { a, b } = person; 👉 What will be the values of **a** and **b**? Then came the follow-up question… 👉 **WHY?** --- 🧠 Question 2 Now imagine the object has multiple key-value pairs. How would you capture the remaining properties during destructuring? const { a, b, ...rest } = person; console.log(rest); 👉 What would be the **output**? And again the interviewer asked: 👉 **WHY?** --- Questions like these may look simple, but when asked in interviews they really test **how deeply we understand JavaScript fundamentals**. 📌 A good reminder for everyone: Irrespective of experience, **fundamentals play a pivotal role in helping us stand out in interviews.** Curious to know from fellow developers 👇 Would you have answered these instantly? #JavaScript #FrontendDevelopment #ReactJS #WebDevelopment #InterviewExperience #Programming #Learning #Fundamentals

To view or add a comment, sign in

Explore content categories