🚀 𝗡𝗲𝘄 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗕𝗹𝗼𝗴 𝗗𝗿𝗼𝗽! 🔗✨ We're excited to share the next chapter in our Functional JavaScript series — “𝗙𝘂𝗻𝗰𝘁𝗶𝗼𝗻 𝗖𝗼𝗺𝗽𝗼𝘀𝗶𝘁𝗶𝗼𝗻 𝗶𝗻 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁: 𝗕𝘂𝗶𝗹𝗱𝗶𝗻𝗴 𝗜𝗻𝘁𝘂𝗶𝘁𝗶𝗼𝗻 𝗧𝗵𝗿𝗼𝘂𝗴𝗵 𝗣𝗿𝗮𝗰𝘁𝗶𝗰𝗲”, written by Anju Karanji! 💜🧠 If 𝗣𝗮𝗿𝘁 𝟭 explored how functions transform behaviour, 𝗣𝗮𝗿𝘁 𝟮 𝗴𝗼𝗲𝘀 𝗱𝗲𝗲𝗽𝗲𝗿 - into how functions can be chained, layered, and orchestrated to build elegant pipelines of logic. No theory without practice here - Anju walks step-by-step from simple function chaining → to writing your own compose() → to solving real LeetCode problems using composition to simplify complex logic. 🔂⚙️ 🔍 𝗪𝗵𝗮𝘁 𝘁𝗵𝗶𝘀 𝗽𝗮𝗿𝘁 𝗰𝗼𝘃𝗲𝗿𝘀: 🎯 What composition really means (beyond the textbook definition) 🧱 How to think in transformations rather than steps 🔄 Right-to-left evaluation & function flows 🧩 Applying composition to real algorithm challenges If you’re leveling up in 𝗥𝗲𝗮𝗰𝘁, 𝗳𝗿𝗼𝗻𝘁𝗲𝗻𝗱 𝗮𝗿𝗰𝗵𝗶𝘁𝗲𝗰𝘁𝘂𝗿𝗲, or just want cleaner, more expressive code - this is a 𝘮𝘶𝘴𝘵-𝘳𝘦𝘢𝘥. 📰 𝗥𝗲𝗮𝗱 𝘁𝗵𝗲 𝗳𝘂𝗹𝗹 𝗮𝗿𝘁𝗶𝗰𝗹𝗲: https://lnkd.in/d_diSSTA 💌 𝗦𝘂𝗯𝘀𝗰𝗿𝗶𝗯𝗲 𝗳𝗼𝗿 𝘂𝗽𝗱𝗮𝘁𝗲𝘀: https://lnkd.in/gDA5t-yP #FrontendQueens #WomenInTech #JavaScript #FunctionalProgramming #React #WebDevelopment #TechBlog ✨
Frontend Queens’ Post
More Relevant Posts
-
🚀 JavaScript Tip of the Day — Currying & Function Composition Most developers know about higher-order functions… but have you explored currying yet? 😎 🧠 What is Currying? Currying transforms a function that takes multiple arguments into a sequence of functions, each taking one argument. 💻 Example: function add(a) { return function(b) { return a + b; }; } console.log(add(2)(3)); // Output: 5 ✅ This means you can reuse and partially apply functions easily. Example: const add10 = add(10); console.log(add10(5)); // 15 console.log(add10(20)); // 30 ⚡ Why use it? Enhances code reusability Makes your functions more modular & composable Great for functional programming patterns 🧩 Bonus: Function Composition Combine multiple small functions into one powerful operation: const multiply = (x) => x * 2; const square = (x) => x * x; const compose = (f, g) => (x) => f(g(x)); console.log(compose(square, multiply)(3)); // (3*2)^2 = 36 🎯 Pro Tip: Currying + Composition = Clean, predictable, and reusable code — hallmarks of a great JavaScript developer. #JavaScript #Angular #WebDevelopment #Frontend #CodingTips #FunctionalProgramming #Developers #JSInterview #MEANStack
To view or add a comment, sign in
-
🧠 What Is the Call Stack in JavaScript? If you’ve ever wondered how JavaScript keeps track of what’s running, meet the Call Stack — the brain behind function execution. 🔍 How It Works The call stack is a data structure that works on a Last In, First Out (LIFO) principle — meaning the last function that goes in is the first one to come out. Since JavaScript is single-threaded, it executes one task at a time using this stack. Here’s how it flows 👇 1️⃣ Function Call: When a function is invoked, it’s pushed onto the top of the stack. 2️⃣ Execution: If it calls another function, that new one gets pushed on top. 3️⃣ Completion: When a function finishes, it’s popped off, and JavaScript moves back to the previous one. This continues until the stack is empty. 📦 Example in Action function greet() { console.log("Hello"); } function welcome() { greet(); console.log("Welcome!"); } welcome(); 🧩 Call Stack Flow: welcome() is pushed. Inside welcome(), greet() is called → pushed. greet() logs “Hello” → popped. welcome() logs “Welcome!” → popped. And the stack is empty again ✅ ⚠️ Stack Overflow If functions keep calling themselves recursively without a stop condition, the stack grows endlessly — leading to a “Maximum call stack size exceeded” error. 💥 That’s what we call a Stack Overflow. 💡 Why It Matters Understanding the call stack helps you: Debug errors like Maximum call stack size exceeded Trace function execution order Write better recursive functions Grasp asynchronous behavior (callbacks, promises, async/await)
To view or add a comment, sign in
-
🚀 New Blog Alert! Ever changed a nested value in JavaScript and wondered why your original object also changed? 😅 That’s the hidden magic (and pain) behind shallow vs deep copy in JavaScript. In my latest Medium article, I’ve broken down: 🧠 How JavaScript handles memory (stack vs heap) 🔍 Why shallow copies share references ⚙️ How deep copy truly works under the hood 💡 Real-world examples using structuredClone(), Object.assign(), and lodash.cloneDeep() 👉 Read here: https://lnkd.in/d9VdByK6 #JavaScript #WebDevelopment #Coding #DeepCopy #ShallowCopy #Frontend #MERN #ShubhamDeveloper
To view or add a comment, sign in
-
🚀 What's New in JavaScript (2025 Edition)? | Real-World Uses & Examples As a dev, staying ahead with JavaScript is absolutely essential—and 2025 brings features that make coding snappier, safer, and more fun! 🌟 Latest JavaScript Features (With Real-Life Examples) 1. Promise.try(): Cleaner Async Code Start a promise chain from any block of code—even if it throws errors! ```js function risky() { return Promise.try(() => { // Might throw an error, but handled! const item = mayThrowSync(); return asyncFetch(item); }); } ``` 💡 Use case: Any real-time data fetch where some logic might throw—your async flows become bulletproof. --- 2. Set Operations (union, intersection, etc.): Native math on sets—easier data manipulation! ```js const backend = new Set(['Node', 'Express']); const frontend = new Set(['React', 'Node']); const fullstack = backend.union(frontend); // Set { 'Node', 'Express', 'React' } ``` 💡 Use case: Feature toggles, permissions management, deduping user actions—less boilerplate! --- 3. Math.f16round(): Fast "Rounded" Numbers Safely convert numbers to 16-bit floats (think graphics and games!) ```js const lowResourceVal = Math.f16round(2.68); // => 2.6875 ``` 💡 Use case: Real-time graphics, animations, or games where memory and speed matter. --- 4. Real-Time Apps with WebSockets & Async Modern JS (with async/await and Socket.IO) powers live dashboards, chat, and collaboration features! ```js // Node.js real-time server (Socket.IO) io.on('connection', socket => { socket.on('message', data => { // Broadcast instantly to all clients! io.emit('message', data); }); }); ``` 💡 Use case: Messaging apps, live dashboards, multi-user editing tools (like Google Docs). --- 5. TypeScript Integration: TypeScript keeps surging! Write safer, scalable JS—now used industry-wide for large codebases. --- 🧑💻 Takeaway: JavaScript in 2025 is about real-time, safer code, and developer joy. Keeping up lets you ship features faster and with confidence. What's YOUR favorite new JS trick this year? Drop an example or challenge below! #JavaScript #WebDevelopment #ES2025 #TypeScript #RealTime #NodeJS #Frontend #Coding #DevCommunity
To view or add a comment, sign in
-
Demystifying the Prototype in JavaScript If there’s one concept that confuses most developers (even experienced ones), it’s the Prototype. Unlike traditional class-based languages, JavaScript uses prototypal inheritance — meaning objects can inherit directly from other objects. Every JS object has a hidden reference called its prototype, and this is what makes inheritance possible. 🔹 How It Works When you access a property like obj.prop1: 1️⃣ JS first checks if prop1 exists on the object itself. 2️⃣ If not, it looks at the object’s prototype. 3️⃣ If still not found, it continues up the prototype chain until it either finds it or reaches the end. So sometimes a property seems to belong to your object — but it actually lives further down the chain! Example const person = { firstname: "Default", lastname: "Default", getFullName() { return this.firstname + " " + this.lastname; } }; const john = Object.create(person); john.firstname = "John"; john.lastname = "Doe"; console.log(john.getFullName()); // "John Doe" Here’s what happens: JS looks for getFullName on john. Doesn’t find it → checks person (its prototype). Executes the method with this referring to john. Key Takeaways The prototype is just a hidden reference to another object. Properties are looked up the prototype chain until found. The this keyword refers to the object calling the method, not the prototype. Avoid using __proto__ directly — use Object.create() or modern class syntax. One-liner: The prototype chain is how JavaScript lets one object access properties and methods of another — simple, flexible, and core to the language. If you found this helpful, follow me for more bite-sized explanations on JavaScript, React, and modern web development #JavaScript #WebDevelopment #Frontend #React #TypeScript #Coding #LearningInPublic #SoftwareEngineering #TechEducation #WebDevCommunity
To view or add a comment, sign in
-
💡 Ever changed a copy of an object… and accidentally changed the original too? If you’ve worked with JavaScript, you know this painful trap all too well! Let’s clarify the difference between shallow copy and deep copy, and see how modern JS handles it. 🔹 Shallow Copy A shallow copy duplicates only the top-level properties. Nested objects or arrays are still shared. const original = { name: "Alice", details: { age: 25 } }; const shallowCopy = { ...original }; shallowCopy.details.age = 30; console.log(original.details.age); // 30 → original object changed! ✅ Top-level copied. ⚠️ Nested objects still reference the same memory. 🔹 Deep Copy A deep copy duplicates everything, including nested objects, so changes don’t affect the original. 1️⃣ Using JSON.stringify() + JSON.parse() const original = { name: "Alice", details: { age: 25 } }; const deepCopy = JSON.parse(JSON.stringify(original)); deepCopy.details.age = 30; console.log(original.details.age); // 25 → safe! ⚠️ Limitation: Doesn’t handle Dates, Maps, Sets, functions, or circular references. 2️⃣ Using structuredClone() (Modern JS) const original = { name: "Alice", details: { age: 25 } }; const deepCopy = structuredClone(original); deepCopy.details.age = 30; console.log(original.details.age); // 25 → safe! ✅ Handles most types, including Date, Map, Set, etc. ⚠️ Available in modern browsers & Node.js v17+. #JS #JavaScript #WebDevelopment #DeepCopy #ShallowCopy #CodingTips #Programming
To view or add a comment, sign in
-
🪢 JS by Design #2 — Creational Patterns in JavaScript Creational patterns define how objects are created — giving structure, flexibility, and control over instantiation. In JavaScript, these patterns evolved as the language matured — from simple functions and closures to powerful class-based features. Let’s explore how JS creates, organizes, and protects objects 👇 1️⃣ The Constructor Pattern One of the earliest and most fundamental creational patterns in JavaScript. Constructors provided a way to create multiple objects with shared structure and behavior using the new keyword. 🔒 Private Fields (modern solution) In modern JavaScript, privacy is built into classes with #privateFields. These fields are truly private — inaccessible outside the class, enforced by the language itself. It’s a clean, performant evolution of what early developers simulated with naming conventions or WeakMaps. << WeakMap >> Before #privateFields, WeakMaps were the go-to technique for true privacy in objects. They allowed data to be associated with specific instances without exposing it publicly — and without preventing garbage collection. 💡 Constructors laid the foundation for JavaScript’s object-oriented patterns — and private fields finally completed the picture of safe, encapsulated object creation. 🧩 2️⃣ The Module Pattern The Module Pattern marked a shift toward encapsulation and modular design. It uses closures to define private variables and functions, exposing only what’s meant to be public. This was a major step forward — functions became “factories” that could create organized, isolated modules without leaking to the global scope. Within this pattern, two important variations emerged: ✨ Revealing Module Pattern A refinement that makes the public API explicit. Instead of deciding what to expose throughout the module, you “reveal” it at the end — mapping private methods to public names. This improved readability and clarity without changing how closures handled privacy. 📦 3️⃣ ES Modules Then came the game changer: ES6 brought native module syntax. With import and export, each file gained its own lexical scope — finally solving global leakage at the language level. Where older patterns simulated modularity, ES Modules implemented it natively. This standardized structure simplified dependency management and became the new default for building scalable applications. 🧩 Next in the JS by Design series: Singleton and Prototype Patterns — mastering instance control and inheritance the smart way. #JSbyDesign #JavaScript #DesignPatterns #FrontendDevelopment #WebDevelopment #CleanCode
To view or add a comment, sign in
-
Let’s understand Loops and Conditions in EJS Template Files (Backend Series) When rendering data dynamically in EJS (Embedded JavaScript Templates), you often need to loop through arrays or use conditional logic to display content smartly, just like you would in JavaScript. EJS allows you to write pure JavaScript syntax directly inside your HTML files using special tags: • <% %> for logic (like loops or conditions) • <%= %> for output (to display values) Here’s how it works step by step: 1️⃣ Looping through data: If your backend sends an array of users like res.render("users", { users: ["Moeez", "Ali", "Sara"] }); You can display them dynamically in your EJS file: <ul> <% users.forEach(user => { %> <li><%= user %></li> <% }) %> </ul> Each item from the array is rendered as a list element, no manual repetition needed. 2️⃣ Using conditions: You can easily handle scenarios where data might or might not exist. <% if (users.length > 0) { %> <p>Total Users: <%= users.length %></p> <% } else { %> <p>No users found</p> <% } %> This ensures your UI responds to backend logic dynamically and cleanly. 3️⃣ Why it matters: • Keeps templates clean and logic-driven. • Reduces repetitive HTML. • Lets you manage data directly in the view layer. • Perfect for rendering lists, tables, dashboards, or dynamic content. EJS basically turns your HTML into a smart, data-aware view, making your backend responses look like complete web pages instead of static output. #Nodejs #Expressjs #EJS #TemplateEngine #BackendDevelopment #WebDevelopment #ServerSideRendering #FullStackDeveloper #JavaScript #NodeDeveloper #WebApps #Coding #LearningNodejs #SoftwareEngineer
To view or add a comment, sign in
-
🔥 Day 12 — The Mind-Bending World of JavaScript Functions ⚙️ Function Declarations, Expressions, Anonymous Functions, Named Expressions they all look harmless… but inside the JS engine, their memory behavior can surprise even experienced devs 🤯 When JavaScript prepares your code, hoisting, scoping, and execution order all come into play 🧩 And that’s where things get interesting 👇 🔷 Function Declaration → completely hoisted → works even before the line runs JS loads the entire function into memory during the creation phase. That’s why calling it early still succeeds. 🔶 Function Expression → treated like a variable → works only after assignment During memory setup, it’s simply undefined. JS assigns the function only when execution actually reaches that line. 🌀 Named Function Expression → the function has its own inner name Great for debugging or recursion, but that internal name is not available outside, leading to reference errors if used directly. 🟡 Anonymous Functions → no name, no identity Mostly used as callbacks, inside expressions, or passed around into other functions. 📌 Parameters vs Arguments Parameters → placeholders in the function definition. Arguments → real values supplied during the call. 🚀 First-Class Functions → JS treats functions like regular values You can return them, pass them, store them, and move them around freely. This power drives callbacks, higher-order functions, async patterns — basically modern JS. ⚡ Arrow Functions → minimal syntax + lexical this Compact, expressive, and perfect for array methods and functional-style code. JavaScript functions aren’t just code blocks… 👉 They define how hoisting behaves 👉 They shape closures and scope 👉 They form the backbone of async and reactive programming 🧠✨
To view or add a comment, sign in
-
-
Why You Should Avoid Using new Number(), new String(), and new Boolean() in JavaScript In JavaScript, there is an important distinction between primitive values and object wrappers. Consider the following example: let a = 3; // primitive number let b = new Number(3); // Number object console.log(a == b); // true (type coercion) console.log(a === b); // false (different types) This inconsistency occurs because new Number(), new String(), and new Boolean() create objects, not primitive values. Although they appear similar, they can cause subtle and hard-to-detect bugs in equality checks and logical comparisons. Common Issues Confusing equality checks (== vs ===) Unintended behavior in conditionals or truthy/falsey evaluations Inconsistent data handling across the codebase Recommended Best Practices Always use literals or function calls for primitive values: // Correct usage let x = 3; let y = "Hello"; let z = true; // Safe conversions Number("3"); // → 3 (primitive) String(123); // → "123" Boolean(0); // → false Use constructors like Date, Array, Object, and Function only when you intend to create objects. For Working with Dates Instead of relying solely on the Date object, consider modern and reliable alternatives: Intl.DateTimeFormat for formatting Temporal API (in modern JavaScript runtimes) for date and time arithmetic Key Takeaway If you encounter new Number(), new String(), or new Boolean() in your codebase, it is often a sign of a potential bug. Use literals for primitives, and reserve constructors for actual objects. #JavaScript #WebDevelopment #SoftwareEngineering #ProgrammingBestPractices #CleanCode #FrontendDevelopment #NodeJS #TypeScript #Developers
To view or add a comment, sign in
Explore related topics
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