💡 JavaScript Interview Insight What gets hoisted: variables or functions? 🤔 ✅ Both! But not in the same way 👇 Function declarations are fully hoisted — you can call them before they’re defined. Variables declared with var are hoisted too, but only the declaration, not the value (they’re initialized as undefined). let and const are hoisted but remain in the Temporal Dead Zone, so you can’t access them before declaration. 🧠 Tip: Understand hoisting to avoid those “undefined” bugs! #JavaScript #FrontendDevelopment #CodingTips
JavaScript Hoisting: Variables vs Functions
More Relevant Posts
-
🚀 Day 792 of #800DaysOfCode 🧠 Understanding Mutation Observer in JavaScript Interviews Ever faced a JavaScript interview question that asked how to detect changes in the DOM without constantly polling it? That’s where Mutation Observer steps in — one of those underrated yet powerful browser features every developer should know. In today’s post, I’ve covered a JavaScript interview question focused on Mutation Observer — including a clear explanation of what it is, how it works, and how to implement it with an example. If you’ve got interviews lined up, this post will help you strengthen your understanding of DOM manipulation and browser APIs. 💬 Have you ever used Mutation Observer in a project? Let’s talk about it in the comments 👇 #Day792 #800DaysOfCode #JavaScript #WebDevelopment #FrontendDevelopment #InterviewPrep #CodingCommunity #CodeQuality #TechLearning #LearnToCode
To view or add a comment, sign in
-
Deep JavaScript Series Have you ever seen your function run before it even exists? It's surprising, right? That’s **Hoisting** in action. JavaScript scans your file first, stores functions and variables in memory, and then runs the code. `var` appears as undefined, while `let` and `const` remain hidden in the temporal dead zone until they are declared. JavaScript doesn’t time travel; it just behaves like it does. #JavaScript #WebDev #Frontend #interview #inteviewTips
To view or add a comment, sign in
-
-
🚀 Day 4 of my 4 Days – 4 JavaScript Questions Challenge! Once in a while, you’ll face this classic interview question: 💭 "What is a Prototype in JavaScript?" I remember the first time I was asked this — I completely blanked out 😅 But you don’t have to! Here’s how you can confidently explain it in your next interview 👇 In JavaScript, every function automatically gets a prototype property, which is an empty object by default. This prototype object is used to add properties and methods that can be shared across all instances created by that function (when used as a constructor with new). function Person(name) { this.name = name; } // Adding a method to prototype Person.prototype.greet = function() { console.log("Hello, " + this.name); }; const user1 = new Person("Anurag"); const user2 = new Person("Sachin"); user1.greet(); // Hello, Anurag user2.greet(); // Hello, Sachin Both objects share the same method via the prototype — making it memory-efficient and powerful. 💪 #JavaScript #FrontendDevelopment #WebDevelopment #JSChallenge #LearningByCoding #UIDeveloper #TechJourney #CodingCommunity
To view or add a comment, sign in
-
#Javascript #Linkedin #interviewpractices #simpleanswer What is Prototype? Ans: When an object doesn’t have a property or method, it will look into its prototype to find it. So prototype helps share methods between objects without copying them again and again. In short: Prototype is like a shared storage of properties and methods for objects.
To view or add a comment, sign in
-
-
💡 🧠 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗔𝗿𝗿𝗮𝘆.𝗽𝗿𝗼𝘁𝗼𝘁𝘆𝗽𝗲.𝗺𝗮𝗽() — 𝗘𝘅𝗽𝗹𝗮𝗶𝗻𝗲𝗱 + 𝗣𝗼𝗹𝘆𝗳𝗶𝗹𝗹 𝗜𝗺𝗽𝗹𝗲𝗺𝗲𝗻𝘁𝗮𝘁𝗶𝗼𝗻⚙️ Ever wondered how the map() method works behind the scenes? 👇 🔍 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗺𝗮𝗽()? The map() method in JavaScript is used to transform each element of an array and return a new array — without modifying the original one. ⚡ 𝗛𝗼𝘄 𝗶𝘁 𝘄𝗼𝗿𝗸𝘀: 🧩 It takes a callback function as an argument. 🔁 Executes that function on each element of the array. 🎯 Returns a new array with the transformed results. Example 👇 const numbers = [1, 2, 3]; const doubled = numbers.map(num => num * 2); console.log(doubled); // [2, 4, 6] 💬 𝗜𝗻 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗜𝗻𝘁𝗲𝗿𝘃𝗶𝗲𝘄𝘀 🎤 Sometimes, interviewers ask you to implement the polyfill for the map() method to test your understanding of: -> Prototype chaining 🧬 -> Callback execution 🔁 -> Return behavior 🎯 💭 Implementing polyfills helps you truly understand how built-in methods work internally — not just how to use them. If you’re preparing for a JavaScript interview, this is one of the must-practice questions 💼 ✨ 𝗪𝗵𝗮𝘁 𝗮𝗿𝗲 𝘆𝗼𝘂𝗿 𝗳𝗮𝘃𝗼𝗿𝗶𝘁𝗲 𝗽𝗼𝗹𝘆𝗳𝗶𝗹𝗹𝘀? Comment below 👇 #JavaScript #FrontendDevelopment #WebDevelopment #CodingChallenge #JavaScriptInterview #ReactJS #FrontendEngineer #100DaysOfCode #Polyfill
To view or add a comment, sign in
-
-
📌How do call(), apply(), and bind() work in JavaScript, and when would you use each of them? ✨ My Thought Process: These three methods are used to explicitly set the value of this when invoking a function. 🔹 call() -Invokes the function immediately -Passes arguments individually func.call(thisArg, arg1, arg2); 🔹 apply() -Also invokes the function immediately -Passes arguments as an array func.apply(thisArg, [arg1, arg2]); 🔹 bind() -Returns a new function with this bound permanently -Does not execute the function immediately const newFunc = func.bind(thisArg); 💡 Use Cases: Borrowing methods across objects Event handlers with fixed context Delayed execution (with bind) 📌 Pro Tip: Prefer bind() for React event handlers to ensure the correct this context inside components. #JavaScript #InterviewQuestion #CallApplyBind #FrontendTips #100DaysOfFrontend
To view or add a comment, sign in
-
*** List of 20 most asked JavaScript interview questions:*** 1. What are the different data types in JavaScript? 2. What is the difference between var, let, and const? 3. What is the difference between == and ===? 4. What is hoisting in JavaScript? 5. What are closures in JavaScript? 6. What is the difference between null and undefined? 7. What are arrow functions and how are they different from normal functions? 8. What does this keyword refer to in JavaScript? 9. What is the difference between function declaration and function expression? 10. What is a promise in JavaScript? 11. What is event bubbling and event capturing? 12. What is async/await and how does it work? 13. What is the event loop in JavaScript? 14. What is the difference between synchronous and asynchronous JavaScript? 15. What are higher-order functions in JavaScript? 16.What is the difference between deep copy and shallow copy? 17. What is destructuring in JavaScript? 18. What is prototypal inheritance? 19. What is the difference between map() and forEach()? 20. What are JavaScript modules and how do you use them? #FrontendInterview #JavaScript #FrontendDeveloper #CodingInterview #WebDevelopment #ReactJS #JavaScriptTips
To view or add a comment, sign in
-
This tiny newline can break your JavaScript code😱 #coding #javascript #frontend This JavaScript short explains one of the most confusing return statement bugs caused by Automatic Semicolon Insertion (ASI). Learn why the same-looking functions return different results — and how to avoid this hidden trap in your code. Perfect for JavaScript interviews, beginners, and advanced devs who want to understand JS deeply. #JavaScript #CodingShorts #JSInterview #TheDeveloperSchool #JavaScript #CodingShorts #TheDeveloperSchool #WebDevelopment #JSInterview #FrontendDeveloper #FullStackDeveloper #JavaScriptTips #LearnCoding #CodeShorts #ProgrammingShorts #TechInterview
To view or add a comment, sign in
-
#Day1Nov #dailylearning Today I learned an important JavaScript concept that often confuses beginners — the difference between undefined and null. ✨ undefined → means a variable has been declared but not assigned a value yet. 🪄 Example: let a; console.log(a); // undefined ✨ null → means a variable is intentionally set to “no value” by the programmer. 🪄 Example: let b = null; console.log(b); // null 📘 In short: undefined = JavaScript’s default “empty” null = Developer’s intentional “empty” This small difference can help avoid big bugs during coding and interviews! 🚀 #Masaiverse #JavaScript #LearningJourney #WebDevelopment #MasaiSchool.
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