If you think semicolons don’t matter in JavaScript…? Click “more” before you scroll ... Skipping semicolons feels harmless… 👀 Until this happens 👇 const arr = [1, 2, 3] (function () { console.log("Hello 👋") })() 👉 Error: arr is not a function 😳 👉 Why? JavaScript thinks you're calling the array as a function Because there’s no semicolon before the IIFE 👉 Fix: const arr = [1, 2, 3]; 👉 Small symbol… big problem 😬 This is due to Automatic Semicolon Insertion (ASI) ⚡ Follow for more simple dev concepts 🚀 #JavaScript #Developers #WebDevelopment #Coding #Debugging #Relatable
JavaScript Semicolon Gotcha: Understanding ASI
More Relevant Posts
-
💡 JavaScript Tricky Question let a = 'hello'; a[0] = 'H'; console.log(a); 👉 Output: `hello` ✅ Explanation: Strings in JavaScript are **immutable** (cannot be changed). Even though it looks like we’re modifying `a[0]`, JavaScript ignores it. So the original string stays the same. 🔹 To change it, you must create a new string: a = 'H' + a.slice(1); #JavaScript #WebDevelopment #Frontend #Coding #JSConcepts
To view or add a comment, sign in
-
Built a little browser game over the weekend using just vanilla JavaScript. No frameworks, no libraries — one HTML file. Move your cursor to destroy enemies, survive boss waves, grab power-ups. Runs at 60fps with particle effects and procedural audio. Sometimes the best way to sharpen your skills is to build something fun. Try it: https://lnkd.in/gQGEcv-v #JavaScript #WebDev #CreativeCoding
To view or add a comment, sign in
-
-
🚀 JavaScript Problem-Solving Practice 💻 Today, I worked on improving my logic building skills with some interesting problems 👇 🔹 Minimum Coins Problem Used slice() + reduce() to find the minimum number of elements forming a target sum. 🔹 Array Transformation Replaced even indices with minimum value and sorted odd indices using sort(). 🔹 First Non-Repeating Character Used an object (frequency count) to find the first unique character in a string. 💡 Key Learnings: ✔️ Better understanding of slice(), reduce(), sort() ✔️ Improved array & string manipulation ✔️ Strengthened problem-solving approach Consistency is the key 🔑✨ #JavaScript #ProblemSolving #CodingPractice #FrontendDevelopment
To view or add a comment, sign in
-
setTimeout does nothing inside the JavaScript engine. It's a label. A facade. When you call it, JS hands the work off to a browser feature - the actual timer lives outside JavaScript entirely. The browser runs it independently while JS continues on to the next line. All the features we think of as "JavaScript" - timers, network requests, DOM interactions - are actually browser APIs. JS just has labels that trigger them. This is how JS avoids blocking. It doesn't wait. It delegates. The result comes back later, through a controlled channel called the callback queue. Next: the event loop - the single mechanism that controls when deferred code is allowed back into JavaScript. #JavaScript #WebDevelopment #Programming #SoftwareEngineering
To view or add a comment, sign in
-
🚀 Day 963 of #1000DaysOfCode ✨ Difference Between var, let & const in JavaScript These three look similar… but behave very differently in real-world code. In today’s post, I’ve broken down the differences between `var`, `let`, and `const` in a simple and practical way, so you can understand when and why to use each of them. From scope and hoisting to re-declaration and mutability, these concepts directly impact how your code behaves — and are often the reason behind many unexpected bugs. I’ve also explained common mistakes developers make while using them, so you can avoid those pitfalls in your own projects. If you’re writing modern JavaScript, having clarity on this is absolutely essential. 👇 Which one do you use the most — `var`, `let`, or `const`? #Day963 #learningoftheday #1000daysofcodingchallenge #FrontendDevelopment #WebDevelopment #JavaScript #React #CodingCommunity #JSBasics
To view or add a comment, sign in
-
🚀 Mastering the Sliding Window Pattern in JavaScript One of the most powerful techniques for solving array problems efficiently is the Sliding Window + Deque approach. Today, I implemented the classic “Maximum in Sliding Window” problem in O(n) time 👇 🔍 Problem: Given an array and a window size k, return the maximum value in each window as it slides from left to right. 💡 Key Insight: Instead of recomputing the max for each window (which is expensive), we maintain a Deque (double-ended queue) that: Stores indices (not values) Keeps elements in decreasing order Ensures the front always holds the max ⚡ Result: Efficient solution with linear time complexity — each element is processed once. 📚 I’m currently building a collection of algorithm patterns in JavaScript: 👉 https://lnkd.in/ej4fNeZs #JavaScript #Algorithms #DataStructures #CodingInterview #SoftwareEngineering #100DaysOfCode
To view or add a comment, sign in
-
-
JS Pop Quiz: Did we just overwrite the Admin?! Let’s see who really understands JavaScript memory allocation! 👨💻👩💻 Look at the code snippet from @codewithsarir. We have a user1 object. We assign it to user2, and then change user2's role to 'Guest'. Question: What does console.log(user1.role) actually print? A) 'Admin' (Because we only changed user2) B) 'Guest' (Because they share the same reference) C) undefined D) It throws a TypeError Hint: Think about how JavaScript handles Objects versus Primitive types like strings. Does = make a copy, or just point to the same address? 🤔 Drop your guess in the comments before you test it in your IDE! 👇 Hashtags: #JavaScript #CodingQuiz #WebDesign #ProgrammerLife #Developers #LearnToCode #JS #Frontend #creators #codinglife #programmer
To view or add a comment, sign in
-
-
The Spread (...) vs Rest (...) operators may look the same, but their purpose is completely different: 👉 Spread → Expands values 👉 Rest → Collects values This simple concept is widely used in: ✔️ React state updates ✔️ Function arguments ✔️ Clean and modern JS code I’ve broken it down into a visual sketchnote to make it easier to remember 🎯 Save it for later & share with someone learning JavaScript! #JavaScript #WebDevelopment #Frontend #Coding #LearnToCode #100DaysOfCode #Developers #chaicode #chaiaurcode Chai Aur Code #spreadoperators #restoperators
To view or add a comment, sign in
-
-
#Javascript Built a Simple Number Guessing Game using JavaScript I created a small project to strengthen my JavaScript fundamentals. Features: • Random number generation (1–10) • User input validation • “Too high” / “Too low” feedback • Attempt counter • Reset functionality • Clean black & white UI This project helped me understand: DOM manipulation Event handling Conditional logic User interaction handling #Application link:https://lnkd.in/gPwysN_b Raviteja T Abdul Rahman 10000 Coders
To view or add a comment, sign in
-
Every function you call in JavaScript gets pushed onto a structure called the call stack. That's how JS knows where to go back. Whatever sits on top of the stack is where execution is right now. When the function returns, it gets popped off - and the item below it is back on top, telling JS exactly where to return to. Without this, calling a function from the middle of another function would leave JS completely lost. There would be no "go back to where you were." One side effect: the call stack has limited space. If a function calls itself infinitely with no stopping condition, you get a stack overflow. The name makes perfect sense once you know what it actually is. Next: JS borrows the browser's timer and network - but the browser doesn't hand results back through the call stack. How does it communicate? #JavaScript #WebDevelopment #Programming #SoftwareEngineering
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
😱🎉