#2 Hash Tables in JavaScript: Object, Map and WeakMap JavaScript gives us a few different ways to store and look up key-value data. Object, Map, and WeakMap all solve similar problems, but they do so in slightly different ways. In this article, we’ll look at how each of them works, when to use them, and why Object is often treated as a hash-table-like structure in everyday JavaScript code. Here’s the link to the post: https://lnkd.in/d-YPraiU #javascript #node #interview
Mariusz Najwer’s Post
More Relevant Posts
-
𝗦𝗽𝗿𝗲𝗮𝗱 𝗩𝗦 𝗥𝗲𝘀𝘁 𝗢𝗽𝗲𝗿𝗮𝘁𝗼𝗿𝘀 𝗜𝗻 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 You've seen ... in JavaScript and wondered what it does. The same syntax is used for two purposes: - Spread operator expands values - Rest operator collects values Understanding this difference is crucial for writing clean JavaScript. The spread operator is used to expand elements from arrays or objects. It spreads elements individually and creates a shallow copy, avoiding mutation. The rest operator is used to collect multiple values into one. It gathers everything into an array. Here are key differences: - Purpose: Spread expands, Rest collects - Usage: Spread on the right, Rest on the left - Output: Spread gives individual elements, Rest gives an array Mastering spread vs rest helps you write cleaner code, handle data efficiently, and solve interview problems confidently. Source: https://lnkd.in/gmFfBhXX
To view or add a comment, sign in
-
One small pattern I really like in JavaScript/TypeScript: return data.items .slice(offset, offset + limit) .map(({ id, firstName, lastName, companyId }) => ({ id, firstName, lastName, companyId, })); Why this is clean: • slice(offset, offset + limit) → handles pagination in a single, readable step • map(...) → transforms data immediately, returning only what’s needed • Object destructuring → avoids repetitive item.id, item.firstName, etc. • No mutations → everything is predictable and functional It’s concise, readable, and does exactly what it needs — nothing more. Sometimes clean code is just about using the right built-in methods. #JavaScript #TypeScript #CleanCode #javascript #remote
To view or add a comment, sign in
-
Day 18/100 JavaScript Type Conversion Implicit conversion = hidden behavior Explicit conversion = controlled logic Great developers don’t just write code They remove uncertainty from systems That’s what I practiced today Database ID Mismatch example #100DaysOfCode #Theodinproject #javascript #webDev
To view or add a comment, sign in
-
-
🚀🔥 Mastering JavaScript String Methods & Real-Time Problems 🔥🚀 🚀Today I focused on strengthening my String fundamentals + problem-solving skills 💻🧠 ✨ What I Practiced: 🔹 Clean user input by removing unwanted spaces 🔹 Case-insensitive comparisons (real login scenarios) 🔹 Searching words inside strings 🔹 Extracting specific parts of strings (like usernames, substrings) 🔹 Converting data types (string ↔ number) 🔹 Working with arrays from strings 💡 Real-Time Use Cases I Solved: ✅ Email username extraction ✅ File type validation (.html check) ✅ Password masking using symbols ✅ Replacing spaces for URL-friendly strings ✅ Checking word existence in sentences 🧠 Logic-Based Problems Covered: 🔸 Reverse a string (without built-in methods) 🔸 Check palindrome 🔸 Count vowels in a string 🔸 Find frequency of characters 🔸 First repeating & non-repeating character 🔸 Remove duplicate characters 🔸 Check anagrams 🔸 String compression (aaabbc → a3b2c1) 🔸 Reverse case transformation (hELLO wORLD) 🔥 Key Learnings: ✔️ Strings are immutable (operations return new values) ✔️ Combining multiple methods is powerful ✔️ Logic building is more important than memorizing methods ✔️ Writing generic solutions is crucial for interviews #JavaScript #WebDevelopment #FrontendDeveloper #CodingJourney #ProblemSolving #DSA #LearningInPublic #CareerGrowth #TechJourney
To view or add a comment, sign in
-
🚀 Understanding Recursion + Finding Maximum in Nested Arrays (JavaScript) Today I practiced a powerful concept in JavaScript — recursion with nested arrays — and used it to solve a real problem: 👉 Find the maximum number from a deeply nested array 💡 Example: [1, 0, 7, [2, 5, [10], 4]] 🔍 Approach I followed: ✅ Step 1: Used recursion to flatten the nested array If the element is a number → push into result If it’s an array → call the same function again ✅ Step 2: After flattening, used a loop to find the maximum value 🧠 Key Learnings: • Each recursive call creates its own memory (execution context) • Data is temporarily stored in the call stack • The return keyword helps pass results back step by step • Without capturing the returned value, recursion results can be lost • Breaking problems into smaller parts makes complex logic easier ⚡ Final Output: 👉 Maximum number: 10 💬 This exercise really helped me understand: How recursion works internally How data flows through function calls Difference between primitive and reference types #JavaScript #Recursion #ProblemSolving #WebDevelopment #CodingJourney
To view or add a comment, sign in
-
Day 23/100 of JavaScript Today’s topic : "this" keyword "this" refers to the object that is currently executing the function But its value depends on how the function is called, not where it is written 🔹In object method const user = { name: "Apsar", greet() { console.log(this.name); } }; user.greet(); // Apsar 🔹In regular function function show() { console.log(this); } show(); // global object (or undefined in strict mode) 🔹Arrow function const obj = { name: "Apsar", greet: () => { console.log(this.name); } }; obj.greet(); // undefined 👉 Arrow functions don’t have their own "this", they inherit it 🔹call, apply, bind function greet() { console.log(this.name); } const user = { name: "Apsar" }; greet.call(user); #Day23 #JavaScript #100DaysOfCode
To view or add a comment, sign in
-
A common misconception in JavaScript: “Objects are copied.” Let’s test that: let obj1 = { name: "John" }; let obj2 = obj1; obj2.name = "Doe"; console.log(obj1.name); // "Doe" At first, this feels unexpected. But here’s what’s really happening: JavaScript doesn’t copy the object. It copies the reference to that object. So both obj1 and obj2 point to the same memory location. That’s why changing one reflects in the other. This is one of the most common concepts tested in interviews — often with tricky variations. Understanding this clearly means you won’t rely on guesses anymore. 👉 I’ve broken this and similar concepts step-by-step in the full video (link in comments)
Why JavaScript Objects Don’t Actually “Copy”
To view or add a comment, sign in
-
𝗦𝗽𝗿𝗲𝗮𝗱 𝗩𝗦 𝗥𝗲𝘀𝘁 𝗢𝗽𝗲𝗿𝗮𝘁𝗼𝗿𝘀 𝗜𝗻 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 You've seen ... in JavaScript and wondered what it does. The same syntax is used for two purposes: - Spread operator expands values - Rest operator collects values Understanding this difference is crucial for writing clean JavaScript. The spread operator expands elements from arrays or objects. It's like opening a box and taking everything out. It spreads elements individually and creates a shallow copy, avoiding mutation. The rest operator collects multiple values into one. It's like gathering everything into a box. All arguments are collected into an array. Here are the key differences: - Spread operator expands values - Rest operator collects values - Spread operator is used on the right side, rest operator on the left side - Spread operator outputs individual elements, rest operator outputs an array You can use spread and rest operators to merge arrays, remove properties from objects, and more. Mastering spread and rest operators helps you write cleaner code, handle data efficiently, and solve interview problems confidently. Source: https://lnkd.in/gmFfBhXX
To view or add a comment, sign in
-
Made a visual to understand Linked Lists in JavaScript at a glance. Internal structure, Big O trade-offs, and when to use them — all in one diagram. #JavaScript #DataStructures #Algorithms #SoftwareEngineering
To view or add a comment, sign in
-
-
Day 11 of My JavaScript Journey 🚀 Today, I learned about objects in JavaScript. Objects are used to store data in key-value pairs, making it easier to organize related information. Example: const user = { name: "John", age: 25 }; Objects are written using curly brackets {}. I also learned how to retrieve and update data in objects using: • Dot notation: user.name • Bracket notation: user["name"] Both methods allow you to access and modify object properties. One thing I realized: Objects are powerful for structuring data in a more meaningful way. Key takeaway: Understanding objects is essential for working with real-world data in JavaScript. #JavaScript #WebDevelopment #LearningInPublic #100DaysOfCode
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