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
Understanding JavaScript Hoisting: A Deep Dive
More Relevant Posts
-
💡 Master JavaScript Promises in One Read Promises are the backbone of modern async JavaScript — yet many developers struggle with chaining, error handling, and multiple promise methods. This quick, interview-focused PDF covers it all: ✅ Core concepts & states ✅ .then(), .catch(), .finally() explained ✅ Chaining rules with real examples ✅ Promise.all(), Promise.any(), and more Perfect for sharpening your async foundations and interview prep. 📘 Download the full guide below 👇 #JavaScript #FrontendDevelopment #AsyncProgramming #WebDev #InterviewPrep
To view or add a comment, sign in
-
Tell me about JavaScript 𝗽𝗿𝗶𝗺𝗶𝘁𝗶𝘃𝗲 𝘁𝘆𝗽𝗲𝘀: In JavaScript there are 7 primitive types: 𝗻𝘂𝗹𝗹, 𝘂𝗻𝗱𝗲𝗳𝗶𝗻𝗲𝗱, 𝘀𝘁𝗿𝗶𝗻𝗴, 𝗻𝘂𝗺𝗯𝗲𝗿, 𝗯𝗼𝗼𝗹𝗲𝗮𝗻, 𝘀𝘆𝗺𝗯𝗼𝗹, 𝗯𝗶𝗴𝗶𝗻𝘁. All primitive types are 𝗶𝗺𝗺𝘂𝘁𝗮𝗯𝗹𝗲, that is, they cannot be altered. They don't have methods, but they behave like they do. When properties are accessed on primitives, JavaScript 𝗮𝘂𝘁𝗼-𝗯𝗼𝘅𝗲𝘀 the value into a wrapper object. It makes possible to run some operations over the value, like 𝘁𝗼𝗙𝗶𝘅𝗲𝗱 in Number or 𝗰𝗵𝗮𝗿𝘁𝗔𝘁 in String. The object is discarded right after the operation completes. When passing a primitive value to a 𝗳𝘂𝗻𝗰𝘁𝗶𝗼𝗻, a copy of the value will be passed. This means that the original value and the value passed through the function have different space in memory. Use the comments if you have some addition or a simpler way to explain this. #javascript #techinterview #jobinterview #question #interviewquestion
To view or add a comment, sign in
-
-
"this" in JavaScript isn’t what you think it is. It doesn’t mean “this function”, it means “the object that called the function.” That’s why "this" changes depending on how the function is called. Arrow functions don’t have their own this. They inherit it from their parent scope, perfect for callbacks, but confusing inside classes and objects. That’s why in React or classes you often see .bind(this) in event handlers because without it, "this" gets lost when the function runs. So next time "this" is undefined, remember, It’s not you. It’s JavaScript being… JavaScript. #this #javascript
To view or add a comment, sign in
-
Favor functional components with Hooks. Cleaner syntax, easier logic, better readability. Class components are history. React Hooks changed everything. 🎣 #React #ReactHooks #FunctionalComponents #FrontendDevelopment #JavaScript
To view or add a comment, sign in
-
💡 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
To view or add a comment, sign in
-
Is 𝗲𝘃𝗲𝗿𝘆𝘁𝗵𝗶𝗻𝗴 in JavaScript an object? I see many developers say that, but that's not accurate. Primitive types essentially aren't objects, although they behave like. Each primitive value has its own wrapper object. When you run some operations like .𝘁𝗼𝗨𝗽𝗽𝗲𝗿𝗖𝗮𝘀𝗲() on a string, or .𝘁𝗼𝗙𝗶𝘅𝗲𝗱() on a number, the engine immediately creates a wrapper object to make it possible. The object is discarded right after the operation completes, and it returns a new value (without changing the original value), since primitive values are immutable. This process is called Autoboxing. #javascript #techinterview #interview
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
-
-
When you realize JavaScript doesn’t need much convincing to turn an array into a string 😄 Sometimes the “lazy” way is also the smart way join() is explicit and clearer, but knowing how implicit conversions work can make your code more flexible and efficient. #JavaScript #CodeTips #WebDevelopment #CodingHumor #DeveloperLife #CleanCode #ProgrammingTips #JSShortcuts
To view or add a comment, sign in
-
-
⚡ Imagine You’re in a JavaScript Interview... The interviewer asks: 🧠 “Can you explain what shimming means in JavaScript — and when you’d actually use it?” Here’s how you can answer 👇 💡 What is a Shim in JavaScript? ✅ A Shim (also known as a Polyfill) is a piece of code that adds support for newer JavaScript features in older browsers or environments that don’t natively support them. ✅ It’s like giving old browsers a “compatibility upgrade” without changing their core engine. 📘 In simple words: “A shim is a fallback implementation for a feature that doesn’t exist in the runtime environment.” 🧩 Example ✅ Let’s say older browsers don’t support Array.prototype.includes(). You can shim it manually like this: if (!Array.prototype.includes) { Array.prototype.includes = function (value) { return this.indexOf(value) !== -1; }; } ⚙️ Shims vs Polyfills ✅ ConceptPurposeShimAdds missing functionality by defining a method that didn’t exist before. ✅ PolyfillA more advanced shim — mimics modern API behavior to match newer ECMAScript specs. #javascript #react #interviewquestion #interviewprep #softwareengineer #frontend #developer
To view or add a comment, sign in
-
💡 JavaScript Challenge: Check if Two Words Are Anagrams Here’s a simple yet powerful JavaScript solution to check if two strings are anagrams of each other 💻 🔍 What’s an Anagram? An anagram is a word formed by rearranging the letters of another — for example: 👉 listen → silent ✅ 👉 hello → world ❌ 🧠 Logic Behind the Code: Compare lengths of both strings. Count occurrences of each character in the first string. Decrease the count for each character in the second string. If all counts match, they’re anagrams! #JavaScript #CodingChallenge #100DaysOfCode #WebDevelopment #ProblemSolving
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