💡 Quick JS Trick: Group Anagrams Want to group words that are anagrams of each other? Use sorting & a Map — super clean and efficient: ✅ How it works: 🔹 Sort letters in each word → same letters = same key. 🔹 Use a Map to group words by this key. 🔹 Return all grouped values. ✨ Benefits: ✅ Simple ✅ Fast ✅ Works for any list of strings #JavaScript #CodingTips #Algorithms #DataStructures #CleanCode #WebDevelopment #JSChallenge
Group Anagrams with JavaScript Sorting and Map
More Relevant Posts
-
Most JavaScript problems aren't about writing code — they're about understanding what it's actually doing. When you're debugging something subtle or trying to reason about performance, the issue usually isn't syntax. It's what's happening under the hood. JavaScript in Depth by James Snell is built for that layer. It focuses on how JavaScript actually works: how engines execute your code, how runtimes interact with system APIs, and why certain behaviors show up in real-world applications. It's not a step-by-step guide. It's a way to build the mental model behind the language, so you can troubleshoot more effectively, revisit edge cases with confidence, and make better use of AI-generated code instead of treating it as a black box. Explore the book: https://hubs.la/Q04bjmfM0
To view or add a comment, sign in
-
-
🚀 From Arrays to Efficiency: Mastering Set in JavaScript Today I solved the “Unique Rows in Boolean Matrix” problem using one simple yet powerful concept — Set. At first glance, the problem looks like a typical nested loop challenge. But instead of going brute force, I leveraged Set to achieve a clean and optimal solution. 💡 Key Idea: Convert each row into a string and store it in a Set to automatically handle duplicates. ✨ Why this is powerful: Eliminates duplicates in O(1) lookup time Avoids unnecessary nested loops Keeps the solution clean and readable 📊 Complexity: Time: O(n × m) Space: O(n × m) 🔥 Takeaway: Sometimes, the difference between an average solution and an optimal one is just knowing the right data structure. Today it was Set. Tomorrow, it could be something else. 💬 Curious: Where else have you used Set to simplify a problem? #JavaScript #DSA #CodingInterview #WebDevelopment #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
Still using complex RegExp for URL matching in JavaScript? There’s a cleaner way. The URLPattern API makes it easy to match routes, extract params, and validate URLs using readable patterns instead of hard-to-maintain regex. Useful for: • custom routers • analytics tracking • access control rules • microfrontend routing • extracting dynamic route params Cleaner syntax. Fewer bugs. Better readability. Worth adding to your modern JavaScript toolkit. #javascript #webdevelopment #frontenddevelopment #modernjavascript #webdevtips #softwareengineering #browserapis #codingtips #devcommunity #reactjs #microfrontend
To view or add a comment, sign in
-
-
Today I finally understood how JavaScript actually stores data in memory — and it changed the way I look at code. Earlier, I used to just write variables and functions without thinking much about what’s happening behind the scenes. But now it makes a lot more sense: Primitive values (like numbers, strings, booleans) are stored directly in memory Reference types (like arrays and objects) are stored differently — the variable holds a reference, not the actual value That’s why things like this behave unexpectedly sometimes: Copying objects doesn’t create a real copy Changing one reference can affect another Understanding this cleared up a lot of confusion I had while debugging. Still learning, but this felt like a small breakthrough Hitesh Choudhary Piyush Garg Chai Code #JavaScript #WebDevelopment #100DaysOfCode #LearningInPublic
To view or add a comment, sign in
-
-
What is the difference between shallow copy and deep copy? Copying objects in JavaScript is not always what it seems. A `shallow copy` duplicates only the first level. Nested objects are still shared by reference. A `deep copy` duplicates everything recursively. Why did this happen? - The top-level object was copied - But `address` still points to the same reference To fully isolate data, a deep copy is required. Understanding this is critical when: - Managing state - Avoiding unintended mutations - Debugging shared data issues The behaviour is subtle — but the impact is everywhere. #Frontend #JavaScript #WebDevelopment #SoftwareEngineering
To view or add a comment, sign in
-
-
JavaScript's Date object was broken in 1995. It took 31 years to fix it. ES2026 finally did it. 🎉 The Temporal API is here — and it's just the start of what ES2026 ships. Here's every feature that changes how you write JS: 🗓️ Temporal API — immutable, timezone-aware dates. Drop Moment.js for good. 🔒 using + await using — automatic resource cleanup. No more forgotten try/finally blocks. Files, DB connections, streams — all closed automatically when scope exits. ➕ Math.sumPrecise() — floating point math that actually works. [1e20, 0.1, -1e20].reduce((a,b)=>a+b) = 0 ❌ Math.sumPrecise([1e20, 0.1, -1e20]) = 0.1 ✅ ✅ Error.isError() — reliable error detection across iframes and VM contexts. instanceof Error was never trustworthy. ⚡ Array.fromAsync() — collect async iterables in one line. The async equivalent of Array.from. 🗺️ Map.getOrInsert() — upsert without the boilerplate. No more has() → set() → get() chains. 🔢 Uint8Array Base64/Hex methods — built-in binary encoding. No more btoa() gymnastics. 🔗 Iterator.concat() — chain iterators lazily. No intermediate arrays. I broke down every feature with before/after code in my article. Which feature are you most excited about? Drop a comment 👇 #JavaScript #ES2026 #ECMAScript #WebDev #Frontend #Programming #100DaysOfBlogging
To view or add a comment, sign in
-
Subject - Common mistake while using fetch in JavaScript Many beginners (including me) try to do this: const data = await fetch('https://lnkd.in/gNBBq58S'); const json = await JSON.stringify(data); 🚫 This is wrong because fetch() returns a Response object, not actual JSON data. ✅ Correct approach: const data = await fetch('https://lnkd.in/gNBBq58S'); const json = await data.json(); ✔️ Lesson: Always use .json() to extract data from the response. Small mistake, but important for real-world projects. #javascript #webdevelopment #frontend #coding #learninpublic
To view or add a comment, sign in
-
-
In JavaScript: 𝐯𝐚𝐥𝐮𝐞 == 𝐧𝐮𝐥𝐥 is one of the few places where 𝐥𝐨𝐨𝐬𝐞 𝐞𝐪𝐮𝐚𝐥𝐢𝐭𝐲 is intentional. Under the hood, the == operator follows the 𝐀𝐛𝐬𝐭𝐫𝐚𝐜𝐭 𝐄𝐪𝐮𝐚𝐥𝐢𝐭𝐲 𝐂𝐨𝐦𝐩𝐚𝐫𝐢𝐬𝐨𝐧 algorithm. It includes a special rule: if one value is 𝐧𝐮𝐥𝐥 and the other is 𝐮𝐧𝐝𝐞𝐟𝐢𝐧𝐞𝐝, it returns 𝐭𝐫𝐮𝐞, without further type coercion. So: 𝐮𝐧𝐝𝐞𝐟𝐢𝐧𝐞𝐝 == 𝐧𝐮𝐥𝐥 // true On the other hand, === uses 𝐒𝐭𝐫𝐢𝐜𝐭 𝐄𝐪𝐮𝐚𝐥𝐢𝐭𝐲 𝐂𝐨𝐦𝐩𝐚𝐫𝐢𝐬𝐨𝐧, which checks both type and value with no exceptions: 𝐮𝐧𝐝𝐞𝐟𝐢𝐧𝐞𝐝 === 𝐧𝐮𝐥𝐥// false That’s why this pattern works: if (value == null) { // catches both null and undefined } It’s not “loose” by accident, it’s a deliberate shortcut baked into the language.
To view or add a comment, sign in
-
-
👉 If you're writing modern JavaScript, these 10 underrated features can instantly improve your code 👇 💡 Optional Chaining ("?.") → Stop “cannot read property of undefined” errors 💡 Nullish Coalescing ("??") → Smarter defaults (without breaking "0" or """") 💡 Array.at() → Clean way to access last elements 💡 structuredClone() → Proper deep copy (no hacks) 💡 Promise.any() → First successful API wins 💡 Object.hasOwn() → Safer property checks 💡 replaceAll() → Replace all matches without regex 💡 Top-Level Await → Cleaner async code in modules 💡 Logical Assignment ("||=", "&&=", "??=") → Write less, do more 💡 WeakMap / WeakSet → Memory-efficient data handling 🔥 These aren’t “advanced” features — They’re modern JavaScript essentials in 2026. --- 💬 Curious — Which one are you already using in production? And which one is new for you? --- #JavaScript #WebDevelopment #Frontend #FullStackDeveloper #Coding #SoftwareEngineering #TechJobs
To view or add a comment, sign in
-
There's always something to gain from going back to the fundamentals. Between client projects and building out systems, I've been carving out time to sharpen my JavaScript. Recently covered: → Primitive vs Reference Data Types → Number, Null, Undefined, BigInt, and Symbols → The typeof operator → Ternary operators → Introduction to Object Destructuring None of this is glamorous. But the designers and developers who write clean, predictable code are almost always the ones who took the fundamentals seriously. Still a few more concepts on the list. Sharing the progress as I go. #JavaScript #WebDevelopment #Webflow #LearningInPublic
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