🚀 Preparing for a JavaScript Interview (L1 & L2 Rounds)? Passing a JavaScript interview isn't just about coding; it’s about articulating the "How" and the "Why." If you are preparing for an L1 (Junior) or L2 (Mid-level) role, these are the 55 core concepts you need to master. I've categorized them to help you study more effectively: 🔹 The Fundamentals Difference between let, var, and const? What are the different datatypes in JS? == vs === (Strict equality)? Is JS dynamically or statically typed? Null vs Undefined? What is the Temporal Dead Zone? Hoisting explained. Typeof operator usage. Output of 3 + 2 + "7"? (The classic coercion trap!) 🔹 Arrays & Objects Map vs Filter? Map vs forEach? Slice vs Splice? Find vs findIndex? Object.keys vs values vs entries? Object.freeze vs Object.seal? Shallow Copy vs Deep Copy? Destructuring basics. Ways to create an Object in JS? 🔹 Advanced Functions & Scope Closure (The most asked question!). Higher Order Functions (HOF)? Pure vs Impure functions? Pass by Value vs Pass by Reference? Call, Apply, and Bind? The behavior of the this keyword? Limitations of Arrow Functions? IIFE (Immediately Invoked Function Expressions). Generator functions? 🔹 Async JS & Performance Callbacks vs Promises? Promise.all vs allSettled vs any vs race? How does the Callstack work? SetTimeout vs SetInterval? Debouncing vs Throttling? What are Interceptors? How do you optimize application performance? 🔹 ES6+, Browser & Architecture Key features of ES6? Spread vs Rest operators? Prototypes and Prototypal Inheritance? Polyfills? Tree Shaking? CORS (Cross-Origin Resource Sharing)? Authentication vs Authorization? JS vs TypeScript? 🔹 Storage & DOM LocalStorage vs SessionStorage? IndexedDB vs SessionStorage? What are Cookies? Event Bubbling vs Event Capturing? What is eval() and why is it dangerous? 🔹 Logic & Principles SOLID Principles? DRY (Don't Repeat Yourself)? KISS (Keep It Simple, Stupid)? YAGNI (You Ain't Gonna Need It)? 💡 Pro-Tip: Don't just memorize definitions. Open your console and try to explain these to yourself out loud. Which of these do you find the hardest to explain in an interview? Let’s discuss in the comments! 👇 #JavaScript #WebDevelopment #Frontend #InterviewPrep #Coding #ProgrammingTips #ProjectIDX
JavaScript Interview Prep: 55 Core Concepts for L1 & L2 Roles
More Relevant Posts
-
2 days crash JavaScript prep for interview. I’d split it cleanly: Day 1 → JavaScript (deep fundamentals) Day 2 → Framework / Library + machine coding Because if JavaScript reasoning is weak, no framework knowledge will save you. Day 1: JavaScript (go deep, not wide) These are the high-ROI JavaScript topics I would focus on. Not to memorize but to be able to explain, reason, and handle follow-ups. Execution & Scope - Execution context & call stack - var, let, const (scope + hoisting + TDZ) - Lexical scope - Closures (real bugs, not definitions) Functions & this - this binding (default, implicit, explicit, new) - call, apply, bind - Arrow functions vs normal functions - Function currying & partial application (conceptually) Async JavaScript - Event loop (call stack, task queue, microtasks) - Promises & chaining - async / await (error handling, sequencing) - Race conditions & stale closures - setTimeout, setInterval, requestAnimationFrame Data & References - == vs ===, truthy / falsy values - Object & array references - Deep vs shallow copy - Array methods (map, filter, reduce, find, some, every) ES6+ Core - Destructuring (edge cases & defaults) - Rest vs spread - Map, Set, WeakMap, WeakSet (why they exist) Browser & Runtime (JS-centric) - DOM events & event delegation - Debouncing vs throttling - Memory leaks in JavaScript (closures, listeners, DOM) - Why some things cannot be polyfilled You don’t need to master everything here. But for each topic, you should be able to answer: Why does this exist? Where does this break? What happens if the interviewer changes one condition? That’s Day 1 done properly. Day 2 then becomes easier. Framework concepts, React patterns, and machine coding sit on top of this foundation. If Day 1 is weak, Day 2 collapses quickly. My eBook will save you weeks of scattered prep. 📘 300+ JS and ReactJS questions 📘 60 System Design Question (HLD and LLD) 👉✅️Grab ebook here: https://lnkd.in/g9hdUJkf That’s how you go from writing UI to building robust, scalable, and performant frontend systems. #FrontendInterview #WebDevelopment #JavaScript #ReactJS #CodingTips #FrontendEngineer #TechCareers
To view or add a comment, sign in
-
🚀 Advanced JavaScript Interview Questions 🔹 Execution & Internals 1️⃣ How does the JavaScript Engine work? (Call Stack, Heap) 2️⃣ Explain Execution Context and its phases 3️⃣ What is the Event Loop? Explain with microtask & macrotask queues 4️⃣ Difference between Call Stack and Task Queue 5️⃣ What is Temporal Dead Zone (TDZ)? 6️⃣ How does Garbage Collection work in JavaScript? 🔹 Scope, Closures & Hoisting 7️⃣ Explain Lexical Scope 8️⃣ How do Closures work internally? 9️⃣ Real-world use cases of closures 🔟 What is Hoisting? Why are let and const hoisted differently? 1️⃣1️⃣ How does scope differ in var, let, and const? 🔹 this, call, apply, bind 1️⃣2️⃣ What is the value of this in different contexts? 1️⃣3️⃣ How does this behave in arrow functions? 1️⃣4️⃣ Difference between call(), apply(), bind() (with use cases) 1️⃣5️⃣ Can you implement bind() polyfill? 🔹 Asynchronous JavaScript 1️⃣6️⃣ Promise chaining vs async/await 1️⃣7️⃣ How does async/await work internally? 1️⃣8️⃣ What happens when a Promise is rejected and not handled? 1️⃣9️⃣ Difference between Promise.all, Promise.allSettled, Promise.race, Promise.any 2️⃣0️⃣ How to handle multiple API calls efficiently? 🔹 Memory & Performance 2️⃣1️⃣ What are memory leaks in JavaScript? 2️⃣2️⃣ Common causes of memory leaks 2️⃣3️⃣ How to optimize JavaScript performance? 2️⃣4️⃣ Debouncing vs Throttling (with examples) 🔹 Objects & Prototypes 2️⃣5️⃣ What is Prototype and Prototype Chain? 2️⃣6️⃣ Difference between proto and prototype 2️⃣7️⃣ How does inheritance work in JavaScript? 2️⃣8️⃣ Difference between Object.freeze(), seal(), and preventExtensions() 🔹 ES6+ Advanced Concepts 2️⃣9️⃣ What are Generators? 3️⃣0️⃣ What are Iterators? 3️⃣1️⃣ What is Symbol and why was it introduced? 3️⃣2️⃣ What is WeakMap and WeakSet? 3️⃣3️⃣ Difference between Map vs Object 3️⃣4️⃣ What is Optional Chaining? 🔹 Arrays & Functional Programming 3️⃣5️⃣ How does reduce() work internally? 3️⃣6️⃣ Difference between map(), filter(), reduce() in terms of performance 3️⃣7️⃣ Why is immutability important? 3️⃣8️⃣ How do you deep clone an object? 🔹 DOM & Browser 3️⃣9️⃣ Event bubbling vs capturing 4️⃣0️⃣ Event delegation – why and when to use it? 4️⃣1️⃣ Reflow vs Repaint 4️⃣2️⃣ How does the browser render a webpage? 🔹 Security & Best Practices 4️⃣3️⃣ What is XSS and how can it be prevented? 4️⃣4️⃣ What is CORS? 4️⃣5️⃣ How do you secure sensitive data in JavaScript? 🌐 Learn More 👉 Follow: Wipzent Tech PVT LTD 👉 Website: https://www.wipzent.com #JavaScript #JavaScriptInterviewQuestions #JavaScriptConcepts #WebDevelopment #FrontendDevelopment #FullStackDevelopment #Programming #Coding #JSInterview #InterviewPreparation #WebDev #SoftwareDevelopment #DeveloperCommunity #LearnJavaScript #JavaScriptTips #TechCareers #CodeNewbie
To view or add a comment, sign in
-
-
50 #JavaScript Interview Questions (All in One Post) 1. What is the difference between var, let, and const? 2. How does JavaScript handle hoisting? 3. What is the Temporal Dead Zone (TDZ)? 4. Explain closures with a real-life example (e.g., private counter or module pattern). 5. What is the difference between == and ===? (Bonus: When might loose equality be useful?) 6. What are all the JavaScript data types (primitives + objects)? 7. What is NaN and how do you reliably check for it? 8. What is the event loop in JavaScript? Describe the call stack, Web APIs, task queues. 9. Explain microtasks vs macrotasks with examples. 10. What is the difference between synchronous and asynchronous code? 11. What are promises and why were they introduced (callback hell killer)? 12. Difference between async/await and .then() chaining? Pros/cons? 13. What happens if a promise is neither resolved nor rejected (pending forever)? 14. What is callback hell and how do modern patterns avoid it? 15. What is the purpose of setTimeout and setInterval? How accurate are they? 16. How does 'this' work in different contexts (global, object, constructor, strict mode)? 17. What is the difference between arrow functions and regular functions (this, arguments, constructor)? 18. What is function currying? Write a simple curry example. 19. What are higher-order functions? Give 3 array method examples. 20. Explain call(), apply(), and bind() with use cases. 21. What is prototypal inheritance? 22. Difference between Object.freeze() and Object.seal()? 23. What is the prototype chain? How does lookup work? 24. What are shallow copy vs deep copy? When does it matter? 25. How do you clone an object in JavaScript (shallow & deep methods)? 26. What is destructuring (object & array)? Nested example? 27. What is the spread operator (...) and rest parameter? Differences? 28. What are template literals and tagged templates? 29. What is optional chaining (?.) and when to use it? 30. What is nullish coalescing (??) vs logical OR (||)? 31. Difference between map(), filter(), and reduce()? When to choose each? 32. What is debouncing vs throttling? Implement a debounce function. 33. What is memoization? Why & how to implement it? 34. What is event delegation? Why is it better than attaching listeners to each element? 35. Difference between for...in and for...of? When to use each? 36. What is strict mode ('use strict')? What bugs does it prevent? 37. Difference between undefined and null? (typeof surprises?) 38. What are IIFEs (Immediately Invoked Function Expressions)? Modern alternatives? 39. What is a pure function? Why prefer them? 40. What are side effects in JavaScript? Examples? Rest are in comments Follow Ankit Sharma for more such insights. #JavaScript #JSInterview #Frontend #WebDevelopment #CodingInterview #Developers #LearnJavaScript #InterviewPrep #ES6 #AsyncJavaScript #UttarPradeshTech #TechJobs2026
To view or add a comment, sign in
-
-
40 #JavaScript Interview Questions 1. What is the difference between var, let, and const? 2. How does JavaScript handle hoisting? 3. What is the Temporal Dead Zone (TDZ)? 4. Explain closures with a real-life example (e.g., private counter or module pattern). 5. What is the difference between == and ===? (Bonus: When might loose equality be useful?) 6. What are all the JavaScript data types (primitives + objects)? 7. What is NaN and how do you reliably check for it? 8. What is the event loop in JavaScript? Describe the call stack, Web APIs, task queues. 9. Explain microtasks vs macrotasks with examples. 10. What is the difference between synchronous and asynchronous code? 11. What are promises and why were they introduced (callback hell killer)? 12. Difference between async/await and .then() chaining? Pros/cons? 13. What happens if a promise is neither resolved nor rejected (pending forever)? 14. What is callback hell and how do modern patterns avoid it? 15. What is the purpose of setTimeout and setInterval? How accurate are they? 16. How does 'this' work in different contexts (global, object, constructor, strict mode)? 17. What is the difference between arrow functions and regular functions (this, arguments, constructor)? 18. What is function currying? Write a simple curry example. 19. What are higher-order functions? Give 3 array method examples. 20. Explain call(), apply(), and bind() with use cases. 21. What is prototypal inheritance? 22. Difference between Object.freeze() and Object.seal()? 23. What is the prototype chain? How does lookup work? 24. What are shallow copy vs deep copy? When does it matter? 25. How do you clone an object in JavaScript (shallow & deep methods)? 26. What is destructuring (object & array)? Nested example? 27. What is the spread operator (...) and rest parameter? Differences? 28. What are template literals and tagged templates? 29. What is optional chaining (?.) and when to use it? 30. What is nullish coalescing (??) vs logical OR (||)? 31. Difference between map(), filter(), and reduce()? When to choose each? 32. What is debouncing vs throttling? Implement a debounce function. 33. What is memoization? Why & how to implement it? 34. What is event delegation? Why is it better than attaching listeners to each element? 35. Difference between for...in and for...of? When to use each? 36. What is strict mode ('use strict')? What bugs does it prevent? 37. Difference between undefined and null? (typeof surprises?) 38. What are IIFEs (Immediately Invoked Function Expressions)? Modern alternatives? 39. What is a pure function? Why prefer them? 40. What are side effects in JavaScript? Examples? #JavaScript #JSInterview #Frontend #WebDevelopment #CodingInterview
To view or add a comment, sign in
-
𝗘𝗻𝗱-𝗼𝗳-𝗬𝗲𝗮𝗿 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗖𝗵𝗮𝗹𝗹𝗲𝗻𝗴𝗲: 𝟮𝟱 𝗤𝘂𝗲𝘀𝘁𝗶𝗼𝗻𝘀 𝗘𝘃𝗲𝗿𝘆 𝗗𝗲𝘃𝗲𝗹𝗼𝗽𝗲𝗿 𝗠𝘂𝘀𝘁 𝗞𝗻𝗼𝘄 Before this year ends, test how solid your JavaScript fundamentals really are. No tutorials. No Google. Just you vs concepts. 🔹 Fundamentals 1️⃣ What are primitive and non-primitive data types? 2️⃣ Difference between var, let, and const? 3️⃣ What are truthy and falsy values? Name all falsy values. 4️⃣ What is type coercion? Give an example. 5️⃣ == vs === — what’s the real difference? 🔹 Scope & Execution 6️⃣ What is hoisting in JavaScript? 7️⃣ Global scope vs function scope vs block scope 8️⃣ What is the execution context? 9️⃣ What is the call stack? 🔟 What is lexical scope? 🔹 Functions & Closures 1️⃣1️⃣ What is a closure? Explain with a real-world example 1️⃣2️⃣ Normal functions vs arrow functions 1️⃣3️⃣ The this keyword — behavior in different contexts 1️⃣4️⃣ What are higher-order functions? 1️⃣5️⃣ What is function currying? 🔹 Arrays & Objects 1️⃣6️⃣ map vs filter vs reduce 1️⃣7️⃣ How do you remove duplicates from an array? 1️⃣8️⃣ Shallow copy vs deep copy 1️⃣9️⃣ How do you merge two objects? 2️⃣0️⃣ What is object destructuring? 🔹 Asynchronous JavaScript 2️⃣1️⃣ What is callback hell? How do you avoid it? 2️⃣2️⃣ Promises vs async/await 2️⃣3️⃣ What is the event loop? 2️⃣4️⃣ setTimeout vs setInterval vs requestAnimationFrame 2️⃣5️⃣ Microtasks vs macrotasks 🎯 Last-Day Challenge Rules ✔ Answer without Google ✔ Explain concepts in your own words ✔ Mark weak areas and revise ✔ End the year strong in JavaScript 📌 Save this for interview prep 🔁 Repost to challenge other developers 𝗜 𝗵𝗮𝘃𝗲 𝗽𝗿𝗲𝗽𝗮𝗿𝗲𝗱 𝗖𝗼𝗺𝗽𝗹𝗲𝘁𝗲 𝗜𝗻𝘁𝗲𝗿𝘃𝗶𝗲𝘄 𝗣𝗿𝗲𝗽𝗮𝗿𝗮𝘁𝗶𝗼𝗻 𝗚𝘂𝗶𝗱𝗲 𝗳𝗼𝗿 𝗙𝗿𝗼𝗻𝘁𝗲𝗻𝗱 𝗗𝗲𝘃𝗲𝗹𝗼𝗽𝗲𝗿. 𝗚𝗲𝘁 𝘁𝗵𝗲 𝗚𝘂𝗶𝗱𝗲 𝗵𝗲𝗿𝗲 👉 https://lnkd.in/dygKYGVx #JavaScript #Frontend #WebDevelopment #InterviewPreparation #JSBasics #Programming #SoftwareEngineering #DeveloperJourney
To view or add a comment, sign in
-
Commonly asked JavaScript interview questions. 𝗖𝗼𝗿𝗲 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 1. What is the difference between var, let, and const in JavaScript? 2. What are closures in JavaScript, and how do they work? 3. What is the this keyword in JavaScript, and how does it behave in different contexts? 4. What is a JavaScript promise, and how does it handle asynchronous code? 5. What is the event loop, and how does JavaScript handle asynchronous operations? 6. What is hoisting in JavaScript, and how does it work? 7. What are JavaScript data types, and how do you check the type of a variable? 8. What is the difference between null and undefined in JavaScript? 9. What is a callback function, and how is it used? 10. How do you manage errors in JavaScript? 𝗔𝘀𝘆𝗻𝗰 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 11. What is the difference between setTimeout() and setInterval()? 12. How do JavaScript promises work, and what is the then() method? 13. What is async/await, and how does it simplify asynchronous code in JavaScript? 14. What are the advantages of using async functions over callbacks? 15. How do you handle multiple promises simultaneously? 𝗙𝗮𝗻𝗰𝘆 𝗙𝗲𝗮𝘁𝘂𝗿𝗲𝘀 𝗶𝗻 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 16. What are higher-order functions in JavaScript, and can you provide an example? 17. What is destructuring in JavaScript, and how is it useful? 18. What are template literals in JavaScript, and how do they work? 19. How does the spread operator work in JavaScript? 20. What is the rest parameter in JavaScript, and how does it differ from the arguments object? 𝗢𝗯𝗷𝗲𝗰𝘁𝘀 𝗮𝗻𝗱 𝗔𝗿𝗿𝗮𝘆𝘀 21. What is the difference between an object and an array in JavaScript? 22. How do you clone an object or array in JavaScript? 23. What are object methods like Object.keys(), Object.values(), and Object.entries()? 24. How does the map() method work in JavaScript, and when would you use it? 25. What is the difference between map() and forEach() in JavaScript? 𝗦𝗽𝗲𝗰𝗶𝗮𝗹 𝗧𝗵𝗲𝗼𝗿𝘆 26. What is event delegation in JavaScript, and why is it useful? 27. What are JavaScript modules, and how do you import/export them? 28. What is the prototype chain in JavaScript, and how does inheritance work? 29. What is bind(), call(), and apply() in JavaScript, and when do you use them? 30. How does JavaScript handle equality comparisons with == and ===? 𝗖𝗼𝗻𝗰𝗲𝗽𝘁𝘀 𝗶𝗻 𝗙𝗿𝗼𝗻𝘁𝗲𝗻𝗱 𝗗𝗲𝘃𝗲𝗹𝗼𝗽𝗺𝗲𝗻𝘁 31. What is the Document Object Model (DOM), and how does JavaScript interact with it? 32. How do you prevent default actions and stop event propagation in JavaScript? 33. What is the difference between an event object and a custom event in JavaScript? 34. How do you optimize performance in JavaScript applications? ----------------------------------- Join devs on • 𝗙𝗿𝗼𝗻𝘁𝗲𝗻𝗱 𝗖𝗶𝗿𝗰𝗹𝗲 𝗯𝘆 𝗦𝗮𝗸𝘀𝗵𝗶 → https://lnkd.in/d45J2fuv • 𝗙𝗿𝗼𝗻𝘁𝗲𝗻𝗱 𝗧𝗼𝗱𝗮𝘆 → https://lnkd.in/dK94iu7Y Follow Sakshi Gawande for more such content 💓
To view or add a comment, sign in
-
✍️ JavaScript Handwritten Notes That Actually Help You Understand JS In a world full of tutorials, reels, and cheat sheets… Handwritten notes still work best when you want real understanding. While preparing for interviews and working on real projects, I realized one thing: 👉 Writing JavaScript concepts by hand forces you to slow down, think, and connect ideas. That’s why I created JavaScript Handwritten Notes — focused on clarity, depth, and interviews. 📘 What These Handwritten Notes Cover 🔹 JavaScript Fundamentals • Data types (primitive vs non-primitive) • var, let, const — scope & hoisting • Truthy & falsy values • Type coercion (== vs ===) 🔹 Execution & Memory Model • How JavaScript code is executed • Execution context & call stack • Hoisting explained visually • Scope chain & lexical environment 🔹 Functions & Closures • Function declaration vs expression • Arrow functions & this behavior • Closures (with real-world examples) • Higher-order functions 🔹 Asynchronous JavaScript • Callbacks & callback hell • Promises — states & chaining • async / await behind the scenes • Event loop (microtasks vs macrotasks) 🔹 Objects, Prototypes & OOP • Object creation patterns • Prototypal inheritance • this, call, apply, bind • Classes vs constructor functions 🔹 Arrays & Important Methods • map, filter, reduce (deep dive) • Shallow vs deep copy • Common JS interview programs 🧠 Why Handwritten Notes Work ✔ Concepts stay longer in memory ✔ Easy to revise before interviews ✔ Great for last-minute prep ✔ Helps you explain clearly in interviews Interviewers don’t test syntax. They test how well you understand what’s happening under the hood. 🎯 Who Are These Notes For? • Beginners struggling with JavaScript • Frontend developers preparing for interviews • Anyone who wants to strengthen JS fundamentals 📌 Final Thought If JavaScript feels confusing, don’t switch tutorials — switch your learning method. Pick a pen ✍️ Write it down Understand it once, properly. 𝑆𝑎𝑣𝑒 𝑡ℎ𝑖𝑠 𝑝𝑜𝑠𝑡 📌 𝑆ℎ𝑎𝑟𝑒 𝑖𝑡 𝑤𝑖𝑡ℎ 𝑠𝑜𝑚𝑒𝑜𝑛𝑒 𝑙𝑒𝑎𝑟𝑛𝑖𝑛𝑔 𝐽𝑎𝑣𝑎𝑆𝑐𝑟𝑖𝑝𝑡 🚀 𝗜 𝗵𝗮𝘃𝗲 𝗽𝗿𝗲𝗽𝗮𝗿𝗲𝗱 𝗖𝗼𝗺𝗽𝗹𝗲𝘁𝗲 𝗜𝗻𝘁𝗲𝗿𝘃𝗶𝗲𝘄 𝗣𝗿𝗲𝗽𝗮𝗿𝗮𝘁𝗶𝗼𝗻 𝗚𝘂𝗶𝗱𝗲 𝗳𝗼𝗿 𝗙𝗿𝗼𝗻𝘁𝗲𝗻𝗱 𝗗𝗲𝘃𝗲𝗹𝗼𝗽𝗲𝗿. 𝗚𝗲𝘁 𝘁𝗵𝗲 𝗚𝘂𝗶𝗱𝗲 𝗵𝗲𝗿𝗲 👉 https://lnkd.in/dygKYGVx 𝗜’𝘃𝗲 𝗯𝘂𝗶𝗹𝘁 𝟴+ 𝗿𝗲𝗰𝗿𝘂𝗶𝘁𝗲𝗿-𝗿𝗲𝗮𝗱𝘆 𝗽𝗼𝗿𝘁𝗳𝗼𝗹𝗶𝗼 𝘄𝗲𝗯𝘀𝗶𝘁𝗲𝘀 𝗳𝗼𝗿 𝗙𝗿𝗼𝗻𝘁𝗲𝗻𝗱 𝗗𝗲𝘃𝗲𝗹𝗼𝗽𝗲𝗿𝘀. 𝗚𝗲𝘁 𝘁𝗵𝗲 𝗽𝗼𝗿𝘁𝗳𝗼𝗹𝗶𝗼𝘀 𝗵𝗲𝗿𝗲 👉 https://lnkd.in/drqV5Fy3 #JavaScript #JavaScriptNotes #HandwrittenNotes #FrontendDeveloper #WebDevelopment #InterviewPreparation #Programming #SoftwareEngineer
To view or add a comment, sign in
-
Module 2: JavaScript – A Quick Refresher (What I Learned) In this module, I refreshed my understanding of JavaScript fundamentals, which are essential for working effectively with Node.js. The focus was on revisiting how JavaScript works, what it is used for, and the core syntax needed to write clean and functional code. JavaScript Overview (My Understanding) JavaScript is a weakly typed, object-oriented, and very versatile programming language. Being weakly typed means I don’t have to explicitly define data types—JavaScript automatically handles types like numbers, strings, and booleans. Its object-oriented nature allows data and behavior to be grouped logically into objects, making code more organized and reusable. JavaScript is also versatile because it can run both in the browser and directly on a server or PC, enabling it to handle a wide range of tasks. Core JavaScript Features I Revisited Variables (var) I learned that variables can be created using the var keyword, although it is now considered outdated and not recommended for modern JavaScript development. Functions Functions are defined using the function keyword and may or may not return a value. The return statement exits the function and optionally sends a value back to where the function was called. Functions are executed by adding parentheses () after the function name. Modern (Next-Gen) JavaScript Syntax • let I use let when I expect the value of a variable to change over time. • const I use const when the value assigned to a variable should never be reassigned. This helps make my code safer and more predictable. Arrow Functions I learned another way to write functions using arrow functions, which are more concise and commonly used in modern JavaScript. Example: const fetch = () => {}; When an arrow function contains only one expression, I can omit both the return keyword and curly braces: const add = (a, b) => a + b; Objects Objects are unordered collections of key-value pairs used to group related data. Properties represent data, while methods represent functions inside the object. I also learned how the "this" keyword works—it refers to the surrounding object and allows access to its properties and methods. Arrays Arrays are ordered collections of items, where each item is accessed using an index starting from 0. Arrays can contain any data type. I also learned about built-in array methods like map, which allows me to transform data and returns a new array without modifying the original one.
To view or add a comment, sign in
-
Mutable vs Immutable in JavaScript is one of those concepts that seems simple, but interviewers love to twist it. • Immutable means the value itself cannot be directly modified • Mutable means the value itself can be modified In JavaScript, all primitive types are immutable: String, Number, Boolean, Null, Undefined, Symbol, BigInt So when you do: let a = 10; a = 20; - It may look like 'a' changed, but what actually happens is that a new value is created and the variable is reassigned. - The old value remains untouched and may later be garbage-collected. - This is also why strings behave the way they do. - You can read characters using an index, but you can’t modify them. - Any “change” to a string actually creates a new string behind the scenes. - Strings are not mutable arrays — they’re immutable primitives. let str = "immutable"; str[0] = "i"; // nothing happens Objects are different. Objects are mutable, and arrays are objects in JavaScript: arr[0] = 10 → works arr.push(4) → modifies the same array in memory Here’s an important distinction: • Mutation (same object, same memory) let obj = { x: 1 }; obj.x = 2; • Reassignment (new object, new reference) let obj = { x: 1 }; obj = { x: 2 }; Even with const, this rule stays the same. const obj = { x: 1 }; obj.x = 2; // allowed → mutation obj = { x: 2 }; // error → reassignment not allowed const prevents reassignment, not mutation. You can’t point the variable to a new object, but you can change the existing object’s properties. Because objects are mutable by default, JavaScript gives us: • Object.seal() → cannot add/remove properties, but values can change • Object.freeze() → cannot add, remove, or change anything (also applies to arrays) Takeaway : • Primitives are immutable. Reassignment creates a new value. • Objects and arrays are mutable. Mutation changes the same value in memory. #FrontendDevelopment #JavaScript #JavaScriptInterview #InterviewPrep #WebDevelopment #Mutability
To view or add a comment, sign in
-
Controlling `this` in JavaScript: Call vs. Apply vs. Bind. 🎮 One of the most common interview questions for mid-level developers is: "𝑊ℎ𝑎𝑡 𝑖𝑠 𝑡ℎ𝑒 𝑑𝑖𝑓𝑓𝑒𝑟𝑒𝑛𝑐𝑒 𝑏𝑒𝑡𝑤𝑒𝑒𝑛 𝐶𝑎𝑙𝑙, 𝐵𝑖𝑛𝑑, 𝑎𝑛𝑑 𝐴𝑝𝑝𝑙𝑦?" They all do the same core job: They allow you to manually set what `this` refers to inside a function. But they do it in slightly different ways. 𝐇𝐞𝐫𝐞 𝐢𝐬 𝐭𝐡𝐞 𝟏𝟎-𝐬𝐞𝐜𝐨𝐧𝐝 𝐛𝐫𝐞𝐚𝐤𝐝𝐨𝐰𝐧: 1️⃣ 𝐂𝐚𝐥𝐥 & 𝐀𝐩𝐩𝐥𝐲 (𝐓𝐡𝐞 𝐈𝐦𝐦𝐞𝐝𝐢𝐚𝐭𝐞 𝐈𝐧𝐯𝐨𝐤𝐞𝐫𝐬) Both of these execute the function 𝑖𝑚𝑚𝑒𝑑𝑖𝑎𝑡𝑒𝑙𝑦. The only difference is how they handle arguments. • 𝐂𝐚𝐥𝐥: Passes arguments individually (comma-separated). • 𝑀𝑛𝑒𝑚𝑜𝑛𝑖𝑐: 𝐂all = 𝐂ommas. • 𝐀𝐩𝐩𝐥𝐲: Passes arguments as a single Array. • 𝑀𝑛𝑒𝑚𝑜𝑛𝑖𝑐: 𝐀pply = 𝐀rray. 2️⃣ 𝐁𝐢𝐧𝐝 (𝐓𝐡𝐞 𝐏𝐥𝐚𝐧𝐧𝐞𝐫) • 𝐁𝐢𝐧𝐝: Does NOT execute the function immediately. • Instead, it returns a 𝐧𝐞𝐰 𝐟𝐮𝐧𝐜𝐭𝐢𝐨𝐧 𝐜𝐨𝐩𝐲 with the `this` context permanently locked (bound) to the object you specified. You can then call this new function whenever you want later. 𝐖𝐡𝐲 𝐢𝐬 𝐭𝐡𝐢𝐬 𝐮𝐬𝐞𝐟𝐮𝐥? It allows "Method Borrowing." You can use a method from one object (like a helper function) and use it on a completely different object, just by changing the `this` context! Check out the syntax comparison below! 👇 Which one do you use most often? I find `bind` essential for passing methods into React components or event listeners! #JavaScript #WebDevelopment #CodingInterviews #SoftwareEngineering #Frontend #JSConcepts
To view or add a comment, sign in
-
More from this author
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