<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dev  on Medium]]></title>
        <description><![CDATA[Stories by Dev  on Medium]]></description>
        <link>https://medium.com/@dev786.1?source=rss-a764e3ced043------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4gLfYcj7xgDfSzYa4v_4Tg.png</url>
            <title>Stories by Dev  on Medium</title>
            <link>https://medium.com/@dev786.1?source=rss-a764e3ced043------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 17:16:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dev786.1/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The JavaScript Event Loop: A Deep Dive into Asynchronous Execution]]></title>
            <link>https://medium.com/@dev786.1/the-javascript-event-loop-a-deep-dive-into-asynchronous-execution-82a9ebd8aac7?source=rss-a764e3ced043------2</link>
            <guid isPermaLink="false">https://medium.com/p/82a9ebd8aac7</guid>
            <category><![CDATA[javascript-event-loop]]></category>
            <category><![CDATA[asynchronous-execution]]></category>
            <dc:creator><![CDATA[Dev ]]></dc:creator>
            <pubDate>Wed, 02 Sep 2026 07:48:28 GMT</pubDate>
            <atom:updated>2026-09-02T07:58:43.187Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>JavaScript is single-threaded, yet it handles millions of concurrent operations. The secret? The Event Loop.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Red_NcbkP78tCKAu9N1wVA.gif" /></figure><h3>What is the Event Loop?</h3><p>The Event Loop is the runtime mechanism that allows JavaScript — a single-threaded, synchronous language — to perform non-blocking asynchronous operations. It’s the orchestrator that moves callbacks between the call stack, Web APIs, and various task queues in a strict, repeatable order.</p><p>Without the event loop, a 30-second network request would freeze your entire browser tab. With it, your UI stays responsive while data loads in the background.</p><h3>The Four Actors</h3><p>Every async program in JavaScript is driven by four core components:</p><h3>1. Call Stack</h3><p>A LIFO (Last In, First Out) data structure that tracks function execution. When a function is called, it’s pushed onto the stack. When it returns, it’s popped off. JavaScript can only execute what’s on top of the stack.</p><p>JavaScript</p><pre>function first() {<br>  console.log(&#39;First&#39;);<br>  second();<br>}<br>function second() {<br>  console.log(&#39;Second&#39;);<br>}<br>first();<br>// Stack: [first] → [first, second] → [first] → []<br>// Output: First, Second</pre><h3>2. Web APIs / Node APIs</h3><p>Everything outside the JavaScript engine that handles async work: setTimeout, fetch, DOM events, file system I/O. Your code registers a task with these APIs, which execute in the background while JS continues running.</p><h3>3. Macrotask Queue (Task Queue)</h3><p>When a Web API finishes its work, the callback is pushed into the macrotask queue. This queue holds:</p><ul><li>setTimeout / setInterval callbacks</li><li>I/O completion callbacks</li><li>DOM event handlers</li><li>setImmediate (Node.js)</li></ul><h3>4. Microtask Queue</h3><p>A higher-priority queue for callbacks that need to run “as soon as possible”:</p><ul><li>Promise.then / catch / finally</li><li>queueMicrotask()</li><li>MutationObserver</li><li>await resumptions</li><li>process.nextTick (Node.js — runs even before standard microtasks)</li></ul><h3>The Golden Rule</h3><blockquote><em>If the call stack is empty, drain the microtask queue completely, then take one task from the macrotask queue and run it to completion — then repeat.</em></blockquote><p>This single rule governs every async program you write!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*3TD0-n1W8Fk_KDuj9ustfg.png" /></figure><p>Code Example: The Canonical Puzzle</p><pre>console.log(&#39;1: script start&#39;);        // 1<br><br>setTimeout(() =&gt; {<br>  console.log(&#39;5: setTimeout&#39;);        // 5<br>}, 0);<br><br>Promise.resolve()<br>  .then(() =&gt; {<br>    console.log(&#39;3: promise 1&#39;);       // 3<br>  })<br>  .then(() =&gt; {<br>    console.log(&#39;4: promise 2&#39;);       // 4<br>  });<br><br>queueMicrotask(() =&gt; {<br>  console.log(&#39;6: queueMicrotask&#39;);    // 6<br>});<br><br>console.log(&#39;2: script end&#39;);          // 2<br><br>// Output:<br>// 1: script start<br>// 2: script end<br>// 3: promise 1<br>// 6: queueMicrotask<br>// 4: promise 2<br>// 5: setTimeout</pre><h3>Step-by-Step Execution:</h3><ol><li>Lines 1 &amp; 2 run synchronously → script start, script end</li><li>setTimeout registers with Web API → callback queued as macrotask</li><li>Promise.resolve().then() registers microtask → promise 1</li><li>queueMicrotask() registers another microtask</li><li>Script ends → call stack empty</li><li>Drain microtasks: promise 1 runs, which registers promise 2 as a new microtask</li><li>Continue draining: queueMicrotask runs, then promise 2</li><li>Microtask queue empty → pick one macrotask: setTimeout callback runs</li></ol><h3>async/await Under the Hood</h3><p>async/await is syntactic sugar over Promises. Every await schedules the rest of the function as a microtask.</p><p>JavaScript</p><pre>async function fn() {<br>  console.log(&#39;2: before await&#39;);      // 2<br>  await Promise.resolve();<br>  console.log(&#39;4: after await&#39;);       // 4<br>}</pre><pre>console.log(&#39;1: start&#39;);               // 1<br>fn();<br>console.log(&#39;3: after fn&#39;);            // 3</pre><pre>// Output: 1, 2, 3, 4</pre><p>The await doesn&#39;t pause the main thread — it yields control, allowing the rest of the script to run, then resumes via the microtask queue.</p><h3>Browser vs Node.js: Key Differences</h3><p>Table</p><p>AspectBrowserNode.jsMacrotask phasesSingle task queue6 phases (timers, pending, idle, poll, check, close)Extra microtasksqueueMicrotask, Promisesprocess.nextTick (highest priority)setImmediate❌ Not available✅ Check phaseI/O handlingWeb APIslibuv thread pool</p><h3>The Famous Node.js Gotcha:</h3><p>JavaScript</p><pre>// At top level — ORDER IS NON-DETERMINISTIC<br>setTimeout(() =&gt; console.log(&#39;timeout&#39;), 0);<br>setImmediate(() =&gt; console.log(&#39;immediate&#39;));</pre><pre>// Inside I/O callback — immediate ALWAYS wins<br>const fs = require(&#39;fs&#39;);<br>fs.readFile(__filename, () =&gt; {<br>  setTimeout(() =&gt; console.log(&#39;timeout&#39;), 0);<br>  setImmediate(() =&gt; console.log(&#39;immediate&#39;));<br>  // Output: immediate, timeout<br>});</pre><p>Inside an I/O callback, the event loop is in the poll phase. The next phase is check (setImmediate), and only then does it wrap around to timers (setTimeout).</p><h3>Common Pitfalls</h3><h3>1. setTimeout(fn, 0) is NOT 0ms</h3><p>The HTML spec enforces a 4ms minimum for nested timeouts. Even un-nested, the callback must wait for the current stack to clear and microtasks to drain. Real-world latency: 4–10ms.</p><p>Fix: Use queueMicrotask() for true &quot;as soon as possible&quot; deferral.</p><h3>2. Microtask Starvation</h3><p>JavaScript</p><pre>function spin() {<br>  queueMicrotask(spin);<br>}<br>spin(); // Page hangs — no macrotask ever runs</pre><p>Recursive microtasks starve the event loop. Use setImmediate (Node) or setTimeout(fn, 0) (browser) to yield to macrotasks.</p><h3>3. Sequential await in Loops</h3><p>JavaScript</p><pre>// Slow: sequential<br>for (const id of userIds) {<br>  const user = await fetchUser(id); // Each await yields!<br>}</pre><pre>// Fast: parallel<br>const users = await Promise.all(userIds.map(fetchUser));</pre><h3>4. Forgetting the Script is a Task</h3><p>Your entire script is itself a macrotask. All synchronous code runs to completion before any queued callbacks fire.</p><h3>Best Practices</h3><p>Table</p><p>GoalUse ThisAvoid ThisImmediate UI updatesqueueMicrotasksetTimeout(fn, 0)Scheduled operationssetTimeout / setIntervalBusy-waiting loopsAnimation framesrequestAnimationFramesetTimeout for animationParallel async opsPromise.allawait inside for loopsCross-platform microtasksqueueMicrotaskprocess.nextTick (Node-only)</p><h3>Summary</h3><h4>Key Concepts</h4><ol><li>Single-threaded — One thing at a time</li><li>Non-blocking — Web APIs handle async operations</li><li>Call Stack — LIFO (Last In, First Out)</li><li>Callback Queue — FIFO (First In, First Out)</li><li>Event Loop — The coordinator between stack and queue</li><li>Microtasks vs Macrotasks — Promises (micro) vs setTimeout (macro)</li></ol><p>The Event Loop is deceptively simple:</p><ol><li>Run synchronous code on the call stack</li><li>When stack empties, drain all microtasks completely</li><li>Run one macrotask from the queue</li><li>Repeat forever</li></ol><p>Understanding this flow transforms async debugging from magic into mechanics. The next time you see an unexpected execution order, trace it through the four actors — you’ll know exactly why.</p><blockquote>The event loop doesn’t add complexity; it reveals the complexity that was always there.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82a9ebd8aac7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Roadmap to becoming an expert in MySQL]]></title>
            <link>https://medium.com/@dev786.1/roadmap-to-becoming-an-expert-in-mysql-fdf7d0ef9a13?source=rss-a764e3ced043------2</link>
            <guid isPermaLink="false">https://medium.com/p/fdf7d0ef9a13</guid>
            <dc:creator><![CDATA[Dev ]]></dc:creator>
            <pubDate>Thu, 16 Jan 2025 04:43:46 GMT</pubDate>
            <atom:updated>2025-01-16T04:43:46.321Z</atom:updated>
            <content:encoded><![CDATA[<h3>Phase 1: Fundamentals (1–3 months)</h3><ul><li>Learn basic SQL concepts: Understand SQL syntax, data types, and query structure.</li><li>Install and configure MySQL: Set up MySQL on your local machine or a virtual environment.</li><li>Understand MySQL data types: Learn about numeric, string, and date/time data types.</li><li>Practice basic queries: Learn SELECT, INSERT, UPDATE, and DELETE statements.</li><li>Study MySQL documentation: Familiarize yourself with official MySQL documentation.</li></ul><h3>Phase 2: Database Design and Management (3–6 months)</h3><ul><li>Learn database design principles: Understand normalization, denormalization, and data modeling.</li><li>Create and manage databases: Practice creating, modifying, and managing databases.</li><li>Understand indexing and optimization: Learn how to optimize database performance.</li><li>Study MySQL storage engines: Understand the differences between MyISAM, InnoDB, and other storage engines.</li><li>Practice database backup and recovery: Learn how to backup and recover databases.</li></ul><h3>Phase 3: Advanced Topics (6–12 months)</h3><ul><li>Learn MySQL programming: Study MySQL stored procedures, functions, and triggers.</li><li>Understand MySQL security: Learn about user management, access control, and encryption.</li><li>Study MySQL performance tuning: Learn how to optimize MySQL performance for large datasets.</li><li>Practice MySQL replication: Set up and manage MySQL replication.</li><li>Learn about MySQL clustering: Understand MySQL clustering and high availability.</li></ul><h3>Phase 4: Specialization (1–2 years)</h3><ul><li>Choose a specialization: Focus on a specific area, such as MySQL performance tuning, security, or data warehousing.</li><li>Study advanced topics: Dive deeper into your chosen specialization.</li><li>Practice and experiment: Apply your knowledge to real-world projects and experiments.</li><li>Join online communities: Participate in online forums and discussion groups.</li><li>Attend conferences and meetups: Network with other MySQL professionals.</li></ul><h3>Phase 5: Mastery (2–5 years)</h3><ul><li>Continuously learn and improve: Stay up-to-date with the latest MySQL features and best practices.</li><li>Share your knowledge: Write blog posts, create tutorials, or speak at conferences.</li><li>Mentor others: Help junior MySQL professionals improve their skills.</li><li>Participate in open-source projects: Contribute to MySQL-related open-source projects.</li><li>Pursue certifications: Consider obtaining MySQL certifications, such as the MySQL Developer or MySQL DBA certification.</li></ul><p>Remember, becoming an expert in MySQL takes time, dedication, and practice. Focus on building a strong foundation, staying up-to-date with the latest developments, and continuously improving your skills.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fdf7d0ef9a13" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Safe assignment operator (??=) and try...catch]]></title>
            <link>https://medium.com/@dev786.1/safe-assignment-operator-and-try-catch-a4723cfefbbd?source=rss-a764e3ced043------2</link>
            <guid isPermaLink="false">https://medium.com/p/a4723cfefbbd</guid>
            <dc:creator><![CDATA[Dev ]]></dc:creator>
            <pubDate>Thu, 31 Oct 2024 12:54:47 GMT</pubDate>
            <atom:updated>2026-09-02T08:13:12.464Z</atom:updated>
            <content:encoded><![CDATA[<p>The safe assignment operator (`??=`) and `try…catch` are both useful for handling potential errors or unexpected values, but they serve very different purposes and have distinct use cases. Here’s a look at how they compare:</p><p><strong>Purpose and Use Cases</strong></p><p>- Safe Assignment Operator (`??=`): Primarily used for setting default values to variables if they are `null` or `undefined`. It’s a shorthand way to handle “empty” or missing values and ensure that a variable has a fallback value. This operator doesn’t handle exceptions; it only checks if a variable is `null` or `undefined`.</p><p>- Try…Catch Block: Used to handle runtime errors and exceptions that occur during code execution. `try…catch` is useful when running code that might throw an error (e.g., trying to parse JSON data, working with external resources, performing network requests). This structure captures errors so that they don’t crash the entire program and lets you decide how to respond (log the error, retry, notify the user, etc.).</p><p><strong>Example Comparison</strong></p><p>To illustrate the difference, let’s say we’re working with a function that retrieves user data. We’ll compare how `??=` and `try…catch` can be used differently in this context.</p><p><strong>Safe Assignment Operator</strong></p><p>If we want to ensure that certain variables have default values, we can use the safe assignment operator:</p><p>```javascript<br>let userName = null;<br>userName ??= “Guest”; // Sets userName to “Guest” if it’s null or undefined<br>console.log(userName); // Output: Guest<br>```</p><p>This approach is simple, short, and efficient for assigning default values without needing complex checks.</p><p><strong>Try…Catch Block</strong></p><p>Now, if we’re retrieving user data from an API, there’s a possibility that the API call might fail (e.g., network error, server error). Here, `try…catch` would be appropriate:</p><p>try {<br> let response = await fetch(“<a href="https://api.example.com/userdata">https://api.example.com/userdata</a>&quot;);<br> let data = await response.json();<br> console.log(“User data:”, data);<br>} catch (error) {<br> console.error(“Failed to fetch user data:”, error); // Logs the error without crashing the program<br>}<br>```</p><p>The `try…catch` block allows us to handle the potential error from the network request gracefully, rather than letting it throw an unhandled error that could disrupt the program.</p><p><strong>Key Differences</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2l3ljwM4D_2iOIijbtcuAw.png" /></figure><p><strong>When to Use Which</strong></p><p><em>Use `??=` when you want to assign default values to variables that may be `null` or `undefined`.</em></p><p><em>Use `try…catch` when you need to handle potential runtime errors from unpredictable operations, such as network requests or parsing.</em></p><p>In summary, the safe assignment operator is a quick, clean way to assign default values for missing or empty variables, while `try…catch` offers a robust solution for handling a broader set of runtime errors and exceptions that could disrupt your program. Both have their place, and understanding the difference helps you apply them effectively in your code.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a4723cfefbbd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding the Safe Assignment Operator in Programming]]></title>
            <link>https://medium.com/@dev786.1/understanding-the-safe-assignment-operator-in-programming-82f44c127aa7?source=rss-a764e3ced043------2</link>
            <guid isPermaLink="false">https://medium.com/p/82f44c127aa7</guid>
            <dc:creator><![CDATA[Dev ]]></dc:creator>
            <pubDate>Thu, 31 Oct 2024 12:49:05 GMT</pubDate>
            <atom:updated>2024-10-31T12:53:04.138Z</atom:updated>
            <content:encoded><![CDATA[<p>The safe assignment operator is a tool that enhances code safety, readability, and clarity, especially when dealing with variables that might have `null` or `undefined` values. In this blog, we’ll explore the safe assignment operator, how it works, and the benefits it brings to your programming workflow. This operator is particularly handy in languages like JavaScript, C#, Kotlin, and PHP, where `null` values can lead to unexpected bugs or crashes if not managed correctly.</p><p><strong>What is the Safe Assignment Operator?</strong></p><p>The safe assignment operator, often represented as `??=`, allows you to assign a value to a variable **only if that variable is null or undefined**. It’s a shorthand way of checking if a variable has a `null` or `undefined` value and, if it does, assigning it a default value. Here’s an example to illustrate this in JavaScript:</p><p><strong>javascript</strong><br>let userAge;<br>userAge ??= 18; // Assigns 18 only if userAge is null or undefined<br>console.log(userAge); // Output: 18<br>```</p><p>In this example, the operator `??=` checks if `userAge` is `null` or `undefined`. Since it is undefined, the value `18` is assigned.</p><p><strong>Why Use the Safe Assignment Operator?</strong></p><p>The main reason to use the safe assignment operator is to **simplify null checks** in your code. Without it, you might have to write conditional statements or ternary operators to check if a variable has a value, which can make your code look cluttered. Here’s an example of how the safe assignment operator can improve readability:</p><p><strong>javascript</strong><br>// Without safe assignment operator<br>if (userAge == null) {<br> userAge = 18;<br>}</p><p>// With safe assignment operator<br>userAge ??= 18;<br>```</p><p>With the safe assignment operator, you reduce the amount of code and make your intent clearer.</p><p><strong>Key Benefits of the Safe Assignment Operator</strong></p><p>The safe assignment operator provides several benefits that streamline your code and reduce bugs:</p><p>1. **Code Readability**: By condensing null checks and assignments into a single line, code becomes more readable.<br>2. **Reduced Error-Prone Code**: It prevents potential errors by handling `null` and `undefined` values explicitly.<br>3. **Performance Improvement**: Since the safe assignment operator is designed for these cases, it can be more efficient than standard conditionals.</p><p><strong>Examples Across Languages</strong></p><p>The syntax and implementation of the safe assignment operator may vary between languages, but the underlying concept remains similar. Let’s look at some examples across languages:</p><p><strong>JavaScript</strong></p><p>let username = null;<br>username ??= “Guest”;<br>console.log(username); // Output: Guest<br>```</p><p><strong>Python (Using Conditional Assignment)</strong></p><p>While Python doesn’t directly support `??=`, you can mimic it:</p><p><strong>python</strong><br>username = None<br>username = username or “Guest”<br>print(username) # Output: Guest</p><p>In PHP, you can use the `??=` operator similarly:</p><p><strong>php</strong><br>$username = null;<br>$username ??= “Guest”;<br>echo $username; // Output: Guest<br>```</p><p><strong>Potential Pitfalls</strong></p><p>Although the safe assignment operator is powerful, it’s important to understand its limitations:</p><p>- **Only Works with Nullish Values**: The operator only checks for `null` or `undefined`. If a variable is `0`, `false`, or an empty string, it will not trigger assignment.<br>- **Compatibility Issues**: Older versions of JavaScript (before ES2020) and some languages may not support this operator, so verify compatibility if you are working in environments with legacy support.</p><p><strong>Conclusion</strong></p><p>The safe assignment operator is an efficient way to handle `null` and `undefined` values. By using `??=`, you can make your code cleaner, reduce redundancy, and avoid potential errors. Whether you’re working with JavaScript, PHP, or another language that supports this operator, integrating it into your code can help make your development process smoother and more effective.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82f44c127aa7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Here’s the explanation of Redux using a story]]></title>
            <link>https://medium.com/@dev786.1/heres-the-explanation-of-redux-using-a-story-0d55be900761?source=rss-a764e3ced043------2</link>
            <guid isPermaLink="false">https://medium.com/p/0d55be900761</guid>
            <dc:creator><![CDATA[Dev ]]></dc:creator>
            <pubDate>Sat, 26 Oct 2024 15:29:49 GMT</pubDate>
            <atom:updated>2026-09-02T06:12:32.240Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0aGp1pGNnPnYxQEHRnbWUg.png" /></figure><h3>What is the Redux Store?</h3><blockquote><em>The global state of an application is stored in an object tree within a single store — </em><a href="https://redux.js.org/understanding/thinking-in-redux/three-principles"><em>Redux docs</em></a><em>.</em></blockquote><p>Imagine life at Hirapur University, where students face various challenges:</p><p>The Problem: Disorganized Student Life</p><p>Students struggle with:</p><ul><li>Keeping track of assignments and deadlines</li><li>Managing multiple club memberships and events</li><li>Coordinating with teammates for group projects</li></ul><p>Enter the Student Union Board (Redux Store)</p><p>To simplify life, the Student Union Board introduces a centralized system (Redux Store) to manage student information.</p><p>The Three Principles</p><p>To maintain order, the Student Union Board establishes:</p><ul><li>Single Source of Truth: One authoritative record of student data.</li><li>Read-Only State: Students can’t change data directly; they must inform the Student Union Board.</li><li>Changes through Actions: Students send requests (actions) to update their information.</li></ul><p>Actions (Requests)</p><p>Students send actions to the Student Union Board, such as:</p><ul><li>“Add me to the Debate Club”</li><li>“Update my course schedule”</li><li>“Assign me to Group 3 for the Marketing Project”</li></ul><p>Reducers (Update Functions)</p><p>The Student Union Board uses specific rules (reducers) to update student information based on actions received.</p><p>Subscribers (Connected Departments)</p><p>Various departments (e.g., Academic Affairs, Student Life) subscribe to receive updates from the Student Union Board.</p><p>Hirapur University’s New Order</p><p>With the Student Union Board (Redux Store) in place:</p><ul><li>Student information is accurate and up-to-date.</li><li>Communication between departments improves.</li><li>Students focus on their studies and extracurricular activities.</li></ul><p>Redux in Code</p><p>In code, this translates to:</p><ul><li>Store: Student Union Board (centralized state management)</li><li>Actions: Requests sent to the store (e.g., joinDebateClub())</li><li>Reducers: Functions updating student information (e.g., updateClubMembership())</li><li>State: Single source of truth (student data)</li><li>Subscribers: Departments connected to the store, receiving updates</li></ul><p>This analogy should help illustrate Redux concepts in a relatable college setting.</p><pre>// Store (Student Union Board)<br>const store = createStore(reducer, initialState);<br><br>// Actions<br>const joinDebateClub = (studentId) =&gt; {<br>  return { type: &#39;JOIN_DEBATE_CLUB&#39;, studentId };<br>};<br><br>// Reducer (updateClubMembership)<br>const reducer = (state, action) =&gt; {<br>  switch (action.type) {<br>    case &#39;JOIN_DEBATE_CLUB&#39;:<br>      return { ...state, [action.studentId]: { ...state[action.studentId], debateClub: true } };<br>    default:<br>      return state;<br>  }<br>};<br><br>// Subscribers (Departments)<br>store.subscribe((state) =&gt; {<br>  console.log(&#39;Academic Affairs:&#39;, state);<br>  console.log(&#39;Student Life:&#39;, state);<br>});<br><br>// Dispatching an action<br>store.dispatch(joinDebateClub(&#39;12345&#39;));</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0d55be900761" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with Three.js]]></title>
            <link>https://medium.com/@dev786.1/getting-started-with-three-js-e37a351125f1?source=rss-a764e3ced043------2</link>
            <guid isPermaLink="false">https://medium.com/p/e37a351125f1</guid>
            <dc:creator><![CDATA[Dev ]]></dc:creator>
            <pubDate>Tue, 27 Aug 2024 04:28:30 GMT</pubDate>
            <atom:updated>2026-09-02T05:52:08.038Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*MtyS4-q8hTXwT3bYMMo3xQ.gif" /></figure><p>Three.js is a powerful JavaScript library for creating and rendering 3D graphics in the browser. With its easy-to-use API and extensive features, Three.js has become a popular choice for developers and designers looking to add 3D content to their web applications. In this blog post, we’ll take a beginner’s journey through the world of Three.js and explore its core concepts, features, and use cases.</p><p>Here is a simple example of how to create a first scene and add a cube using Three.js:</p><p>HTML:</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>	&lt;title&gt;My First Three.js Scene&lt;/title&gt;<br>	&lt;style&gt;<br>		body { margin: 0; }<br>		#canvas { width: 100%; height: 100vh; display: block; }<br>	&lt;/style&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>	&lt;canvas id=&quot;canvas&quot;&gt;&lt;/canvas&gt;<br>	&lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js&quot;&gt;&lt;/script&gt;<br>	&lt;script src=&quot;script.js&quot;&gt;&lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>JavaScript (script.js):</p><pre>// Create the scene<br>const scene = new THREE.Scene();<br>// Create the camera<br>const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);<br>// Create the renderer<br>const renderer = new THREE.WebGLRenderer({<br>  canvas: document.getElementById(&#39;canvas&#39;),<br>  antialias: true<br>});<br>// Add a cube to the scene<br>const geometry = new THREE.BoxGeometry(1, 1, 1);<br>const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 });<br>const cube = new THREE.Mesh(geometry, material);<br>scene.add(cube);<br>// Position the camera<br>camera.position.z = 5;<br>// Render the scene<br>function animate() {<br>  requestAnimationFrame(animate);<br>  renderer.render(scene, camera);<br>}<br>animate();</pre><p>This code creates a simple scene with a green cube in the center. The camera is positioned to view the cube from the front.</p><blockquote>More examples</blockquote><p><a href="https://www.linkedin.com/posts/dev-prakash-dubey_webgl-threejs-webglexperiments-activity-6885847973977300993-vaZ8?utm_source=share&amp;utm_medium=member_desktop">Project one</a></p><p><a href="https://www.linkedin.com/posts/dev-prakash-dubey_webgl-threejs-webglexperiments-activity-6885791912410914816-Ty84?utm_source=share&amp;utm_medium=member_desktop">Project Two</a></p><p><a href="https://www.linkedin.com/feed/update/urn:li:activity:6883016487645327360?utm_source=share&amp;utm_medium=member_desktop">Project Three</a>. <a href="https://www.linkedin.com/posts/dev-prakash-dubey_threejs-webgl-design-activity-6883011166587678720-ZOIw?utm_source=share&amp;utm_medium=member_desktop">next</a></p><p><a href="https://www.linkedin.com/posts/dev-prakash-dubey_threejs-webgl-activity-6882937876452032512-RVjd?utm_source=share&amp;utm_medium=member_desktop">Project Four</a></p><blockquote>Core Concepts:</blockquote><ul><li>Scenes: The container for all 3D objects and cameras.</li><li>Cameras: Define the viewpoint and projection of the scene.</li><li>Meshes: 3D objects composed of geometry and material.</li><li>Geometries: Define the shape and structure of 3D objects.</li><li>Materials: Define the appearance and properties of 3D objects.</li></ul><blockquote>Features:</blockquote><ul><li>3D Rendering: Real-time rendering of 3D scenes.</li><li>Animations: Keyframe animations and physics-based simulations.</li><li>Lighting: Various light sources and shading models.</li><li>Loaders: Import 3D models from popular file formats.</li></ul><blockquote>Use Cases:</blockquote><ul><li>Gaming: Create immersive 3D games with interactive graphics.</li><li>Product Visualization: Showcase products in 3D with realistic materials and lighting.</li><li>Data Visualization: Represent complex data in interactive 3D visualizations.</li><li>Architecture: Visualize buildings and spaces in 3D with accurate lighting and materials.</li></ul><blockquote>Advanced Topics:</blockquote><ul><li>Physics Engines: Integrate physics engines like Ammo.js or Cannon.js for realistic simulations.</li><li>Dynamic Lighting: Use dynamic lighting techniques like shadow mapping or screen space ambient occlusion.</li><li>Advanced Materials: Create custom materials using shaders or explore advanced material properties.</li><li>Performance Optimization: Learn techniques for optimizing performance in complex scenes.</li></ul><blockquote>Best Practices:</blockquote><ul><li>Scene Management: Organize and manage complex scenes with multiple objects and cameras.</li><li>Code Structure: Follow best practices for structuring and modularizing Three.js code.</li><li>Debugging: Learn how to debug common issues and optimize performance.</li></ul><blockquote>Real-World Examples:</blockquote><ul><li>Product Visualization: Explore examples of product visualization using Three.js.</li><li>Data Visualization: See how Three.js is used in data visualization projects.</li><li>Gaming: Check out examples of games built with Three.js.</li></ul><blockquote>Conclusion:</blockquote><p>Three.js is a powerful tool for creating stunning 3D graphics in the browser. With its easy-to-use API and extensive features, it’s perfect for beginners and experienced developers alike. Whether you’re building games, product visualizations, or data visualizations, Three.js has got you covered.</p><p>Resources:</p><ul><li>Official Documentation: <a href="https://threejs.org/docs/">Three.js official documentation and tutorials</a>.</li><li>Examples: <a href="https://threejs.org/">Three.js examples and demos</a>.</li><li>Community: Three.js community forum and Discord channel.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e37a351125f1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript Types and Operators]]></title>
            <link>https://medium.com/@dev786.1/javascript-types-and-operators-0dec2b13a74f?source=rss-a764e3ced043------2</link>
            <guid isPermaLink="false">https://medium.com/p/0dec2b13a74f</guid>
            <dc:creator><![CDATA[Dev ]]></dc:creator>
            <pubDate>Tue, 27 Aug 2024 04:14:12 GMT</pubDate>
            <atom:updated>2024-08-27T04:14:35.789Z</atom:updated>
            <content:encoded><![CDATA[<p>JavaScript has two main types of data: primitive types and reference types.</p><blockquote><strong>Primitive Types:</strong></blockquote><ul><li>Number: Represents a numeric value, e.g., 42, 3.14</li><li>String: Represents a sequence of characters, e.g., “hello”, ‘hello’</li><li>Boolean: Represents a true or false value</li><li>Null: Represents the absence of any object value</li><li>Undefined: Represents an uninitialized or non-existent variable</li><li>Symbol: Represents a unique identifier, e.g., Symbol(‘foo’)</li></ul><blockquote><strong>Reference Types:</strong></blockquote><ul><li>Object: Represents a collection of key-value pairs, e.g., {a: 1, b: 2}</li><li>Array: Represents an ordered collection of values, e.g., [1, 2, 3]</li><li>Function: Represents a block of code that can be executed, e.g., function () {}</li></ul><blockquote><strong>Arithmetic Operators:</strong></blockquote><ul><li>Addition (+): Returns the sum of two numbers, e.g., 2 + 3 = 5</li><li>Subtraction (-): Returns the difference of two numbers, e.g., 5–2 = 3</li><li><em>Multiplication ():</em>* Returns the product of two numbers, e.g., 4 * 5 = 20</li><li>Division (/): Returns the quotient of two numbers, e.g., 10 / 2 = 5</li><li>Modulus (%): Returns the remainder of two numbers, e.g., 17 % 5 = 2</li><li>Exponentiation ():** Returns the result of raising a number to a power, e.g., 2 ** 3 = 8</li></ul><blockquote><strong>Comparison Operators:</strong></blockquote><ul><li>Equal (==): Returns true if two values are equal, e.g., 5 == 5</li><li>Not Equal (!=): Returns true if two values are not equal, e.g., 5 != 3</li><li>Strict Equal (===): Returns true if two values are equal and of the same type, e.g., 5 === 5</li><li>Strict Not Equal (!==): Returns true if two values are not equal or of different types, e.g., 5 !== ‘5’</li><li>Greater Than (&gt;): Returns true if one value is greater than another, e.g., 5 &gt; 3</li><li>Less Than (&lt;): Returns true if one value is less than another, e.g., 3 &lt; 5</li><li>Greater Than or Equal (&gt;=): Returns true if one value is greater than or equal to another, e.g., 5 &gt;= 5</li><li>Less Than or Equal (&lt;=): Returns true if one value is less than or equal to another, e.g., 3 &lt;= 5</li></ul><blockquote><strong>Logical Operators:</strong></blockquote><ul><li>And (&amp;&amp;): Returns true if both values are true, e.g., true &amp;&amp; true</li><li>Or (||): Returns true if either value is true, e.g., true || false</li><li>Not (!): Returns the opposite of a boolean value, e.g., !true = false</li></ul><blockquote><strong>Operator Precedence:</strong></blockquote><ul><li>Parentheses: ()</li><li>Exponentiation: **</li><li>Multiplication, Division, Modulus: *, /, %</li><li>Addition, Subtraction: +, -</li><li>Comparison: ==, !=, ===, !==, &gt;, &lt;, &gt;=, &lt;=</li><li>Logical: &amp;&amp;, ||, !</li></ul><p>By understanding JavaScript types and operators, we can write more effective and efficient code!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0dec2b13a74f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript Built-in Methods]]></title>
            <link>https://medium.com/@dev786.1/javascript-built-in-methods-401ac3565db1?source=rss-a764e3ced043------2</link>
            <guid isPermaLink="false">https://medium.com/p/401ac3565db1</guid>
            <dc:creator><![CDATA[Dev ]]></dc:creator>
            <pubDate>Tue, 27 Aug 2024 04:07:28 GMT</pubDate>
            <atom:updated>2024-08-27T04:08:05.088Z</atom:updated>
            <content:encoded><![CDATA[<p>JavaScript provides various built-in methods for working with strings, arrays, and objects.</p><blockquote><strong>String Methods:</strong></blockquote><ul><li>split (): Splits a string into an array of substrings</li><li>join (): Joins an array of strings into a single string</li><li>trim (): Removes whitespace from the beginning and end of a string</li><li>replace (): Replaces a substring with another string</li><li>toUpperCase () / toLowerCase (): Converts a string to uppercase or lowercase</li><li>includes (): Checks if a string contains a specified substring</li><li>startsWith (): Checks if a string starts with a specified substring</li><li>endsWith (): Checks if a string ends with a specified substring</li><li>repeat (): Repeats a string a specified number of times</li><li>replace (): Replaces a substring with another string</li></ul><p>Example:</p><pre>const str = &quot;hello world&quot;;<br>console.log(str.split(&quot; &quot;)); // Output: [&quot;hello&quot;, &quot;world&quot;]<br>console.log(str.toUpperCase()); // Output: &quot;HELLO WORLD&quot;<br><br>console.log(str.includes(&quot;world&quot;)); // Output: true<br>console.log(str.startsWith(&quot;hello&quot;)); // Output: true<br>console.log(str.endsWith(&quot;world&quot;)); // Output: true<br>console.log(str.repeat(3)); // Output: &quot;hello worldhello worldhello world&quot;</pre><blockquote><strong>Array Methods:</strong></blockquote><ul><li>sort (): Sorts an array in ascending or descending order</li><li>reverse (): Reverses the order of an array</li><li>push () / pop (): Adds or removes elements from the end of an array</li><li>shift () / unshift (): Adds or removes elements from the beginning of an array</li><li>splice (): Adds or removes elements from a specific position in an array</li><li>find (): Returns the first element that matches a specified condition</li><li>findIndex (): Returns the index of the first element that matches a specified condition</li><li>every (): Checks if all elements in an array match a specified condition</li><li>some (): Checks if at least one element in an array matches a specified condition</li><li>reduce(): Reduces an array to a single value</li></ul><p>Example:</p><pre>const arr = [3, 1, 2];<br>console.log(arr.sort()); // Output: [1, 2, 3]<br>console.log(arr.reverse()); // Output: [3, 2, 1]<br><br>const arr = [1, 2, 3, 4, 5];<br>console.log(arr.find(x =&gt; x &gt; 3)); // Output: 4<br>console.log(arr.findIndex(x =&gt; x &gt; 3)); // Output: 3<br>console.log(arr.every(x =&gt; x &gt; 0)); // Output: true<br>console.log(arr.some(x =&gt; x &gt; 5)); // Output: false<br>console.log(arr.reduce((a, b) =&gt; a + b)); // Output: 15</pre><blockquote><strong>Object Methods:</strong></blockquote><ul><li>keys (): Returns an array of an object’s property names</li><li>values (): Returns an array of an object’s property values</li><li>entries (): Returns an array of an object’s property key-value pairs</li><li>assign (): Copies properties from one object to another</li><li>hasOwnProperty (): Checks if an object has a specified property</li><li>isPrototypeOf (): Checks if an object is a prototype of another object</li><li>propertyIsEnumerable (): Checks if a property is enumerable</li><li>freeze (): Freezes an object, making it immutable</li><li>seal (): Seals an object, preventing new properties from being added</li></ul><p>Example:</p><pre>const obj = { a: 1, b: 2 };<br>console.log(Object.keys(obj)); // Output: [&quot;a&quot;, &quot;b&quot;]<br>console.log(Object.values(obj)); // Output: [1, 2]<br><br>const obj = { a: 1, b: 2 };<br>console.log(obj.hasOwnProperty(&quot;a&quot;)); // Output: true<br>console.log(obj.isPrototypeOf({})); // Output: false<br>console.log(obj.propertyIsEnumerable(&quot;a&quot;)); // Output: true<br>Object.freeze(obj);<br>obj.a = 2;<br>console.log(obj.a); // Output: 1</pre><p>By utilizing these built-in methods, you can simplify your code and work more efficiently with strings, arrays, and objects in JavaScript!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=401ac3565db1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript Best Practices]]></title>
            <link>https://medium.com/@dev786.1/javascript-best-practices-3af1dd294fde?source=rss-a764e3ced043------2</link>
            <guid isPermaLink="false">https://medium.com/p/3af1dd294fde</guid>
            <dc:creator><![CDATA[Dev ]]></dc:creator>
            <pubDate>Tue, 27 Aug 2024 03:56:19 GMT</pubDate>
            <atom:updated>2024-08-27T03:56:47.774Z</atom:updated>
            <content:encoded><![CDATA[<p>Adopting best practices in JavaScript development ensures maintainable, efficient, and scalable code.</p><p><strong>Code Organization and Structure:</strong></p><ul><li>Modularize: Break code into smaller, reusable modules</li><li>Separate Concerns: Keep UI, logic, and data separate</li><li>Consistent Directory Structure: Organize files and directories logically</li></ul><p><strong>Naming Conventions and Code Style:</strong></p><ul><li>Use Descriptive Names: Clear and concise variable and function names</li><li>Follow a Consistent Style: Use a linter and code formatter (e.g., ESLint, Prettier)</li><li>Keep it Simple: Avoid unnecessary complexity</li></ul><p><strong>Error Handling and Debugging:</strong></p><ul><li>Try-Catch Blocks: Handle errors and exceptions gracefully</li><li>Error Messages: Provide informative error messages</li><li>Debugging Tools: Use browser dev tools, console logs, and debuggers</li><li>Test Thoroughly: Write comprehensive unit tests and integration tests</li></ul><p><strong>Additional Best Practices:</strong></p><ul><li>Code Comments: Explain complex logic and code decisions</li><li>Code Reviews: Regularly review code with peers</li><li>Refactoring: Continuously improve code quality and performance</li><li>Stay Up-to-Date: Follow JavaScript trends, updates, and security patches</li></ul><blockquote><strong>Here are some examples to illustrate the best practices:</strong></blockquote><p>Code Organization and Structure:</p><ul><li><strong>Modularize:</strong></li></ul><pre>// Instead of a single large file<br>// scripts.js</pre><pre>// Break it down into smaller modules<br>// user.js<br>// product.js<br>// cart.js</pre><ul><li><strong>Separate Concerns:</strong></li></ul><pre>// Instead of mixing UI and logic<br>// ui.js<br>function renderUser(name) {<br>  // UI logic<br>}</pre><pre>// logic.js<br>function getUserData() {<br>  // Data logic<br>}</pre><blockquote><strong>Naming Conventions and Code Style:</strong></blockquote><ul><li><strong><em>Use Descriptive Names:</em></strong></li></ul><pre>// Instead of<br>var d = new Date();</pre><pre>// Use<br>var currentDate = new Date();</pre><ul><li><strong><em>Follow a Consistent Style:</em></strong></li></ul><pre>// Use ESLint and Prettier for consistent formatting<br>function myFunction() {<br>  // Code<br>}</pre><pre>// Instead of<br>function myfunction(){<br>  // Code<br>}</pre><blockquote><strong>Error Handling and Debugging:</strong></blockquote><ul><li>Try-Catch Blocks:</li></ul><pre>try {<br>  // Code that might throw an error<br>} catch (error) {<br>  console.error(error);<br>}</pre><ul><li>Error Messages:</li></ul><pre>try {<br>  // Code that might throw an error<br>} catch (error) {<br>  console.error(&quot;Error: Unable to fetch data&quot;);<br>}</pre><ul><li>Debugging Tools:</li></ul><pre>// Use console logs for debugging<br>console.log(&quot;Current user:&quot;, user);</pre><p>By following these best practices and examples, we can write more maintainable, efficient, and scalable JavaScript code!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3af1dd294fde" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript Regular Expressions]]></title>
            <link>https://medium.com/@dev786.1/javascript-regular-expressions-079189911927?source=rss-a764e3ced043------2</link>
            <guid isPermaLink="false">https://medium.com/p/079189911927</guid>
            <dc:creator><![CDATA[Dev ]]></dc:creator>
            <pubDate>Tue, 27 Aug 2024 03:49:55 GMT</pubDate>
            <atom:updated>2024-08-27T03:49:55.116Z</atom:updated>
            <content:encoded><![CDATA[<p>Regular expressions (regex) are a powerful tool for matching and manipulating text patterns in JavaScript.</p><p><strong><em>Pattern Matching and Replacement:</em></strong></p><ul><li>Matching: Using regex to search for patterns in strings</li><li>Replacement: Using regex to replace matched patterns with new text</li></ul><p>Example:</p><pre>const text = &quot;Hello, world!&quot;;<br>const regex = /world/;<br>const replacement = &quot;JavaScript&quot;;<br>console.log(text.replace(regex, replacement)); // Output: &quot;Hello, JavaScript!&quot;</pre><p>Regex Syntax and Flags:</p><ul><li>Regex Syntax:</li><li>. matches any character</li><li>* matches zero or more occurrences</li><li>+ matches one or more occurrences</li><li>? matches zero or one occurrence</li><li>{n} matches exactly n occurrences</li><li>[abc] matches any character in the set</li><li>[^abc] matches any character not in the set</li></ul><p>Regex Flags:</p><ul><li>i case-insensitive matching</li><li>g global matching (find all matches)</li><li>m multiline matching</li></ul><p>Example:</p><pre>const regex = /hello/i; // Case-insensitive matching<br>console.log(&quot;Hello, World!&quot;.match(regex)); // Output: [&quot;Hello&quot;]</pre><pre>const regex = /hello/g; // Global matching<br>console.log (&quot;Hello, hello, world!&quot;.match(regex)); // Output: [&quot;hello&quot;, &quot;hello&quot;]</pre><p><strong>Regex Patterns:</strong></p><ul><li>Character Classes: \d (digits), \w (word characters), \s (whitespace), \D (non-digits), \W (non-word characters), \S (non-whitespace)</li><li>Character Escapes: \ (escape character), \n (newline), \t (tab), \r (carriage return)</li><li>Grouping and Capturing: ( ) (capture group), (? ) (non-capturing group)</li><li>Quantifiers: * (zero or more), + (one or more), ? (zero or one), {n} (exactly n), {n,} (n or more), {n,m} (between n and m)</li><li>Anchors: ^ (start of string), $ (end of string), \b (word boundary), \B (non-word boundary)</li></ul><p><strong>Regex Methods:</strong></p><ul><li>test (): Tests if a string matches a regex pattern</li><li>exec (): Executes a regex search and returns an array of matches</li><li>match (): Returns an array of matches in a string</li><li>replace (): Replaces matches in a string with a replacement string</li><li>search (): Returns the index of the first match in a string</li><li>split (): Splits a string into an array using a regex pattern</li></ul><p><strong>Common Use Cases:</strong></p><ul><li>Validation: Email addresses, phone numbers, passwords</li><li>Parsing: Extracting data from strings, like URLs or dates</li><li>Formatting: Reformatting text, like converting to uppercase or lowercase</li><li>Searching: Finding and replacing text patterns in strings</li></ul><p>By mastering JavaScript regular expressions, you can efficiently search, validate, and manipulate text patterns in your code!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=079189911927" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>