<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Jinad AbdulQuadri</title>
    <description>The latest articles on Forem by Jinad AbdulQuadri (@0mobolaji).</description>
    <link>https://forem.com/0mobolaji</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1146456%2Fed7e8a0e-ed0b-4433-ae6d-1683bd51261d.jpg</url>
      <title>Forem: Jinad AbdulQuadri</title>
      <link>https://forem.com/0mobolaji</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/0mobolaji"/>
    <language>en</language>
    <item>
      <title>Exploring Frontend Technologies: Elm vs. Svelte</title>
      <dc:creator>Jinad AbdulQuadri</dc:creator>
      <pubDate>Sat, 29 Jun 2024 12:57:56 +0000</pubDate>
      <link>https://forem.com/0mobolaji/exploring-frontend-technologies-elm-vs-svelte-4hp0</link>
      <guid>https://forem.com/0mobolaji/exploring-frontend-technologies-elm-vs-svelte-4hp0</guid>
      <description>&lt;p&gt;I recently joined HNG internship, it's a fast paced, online bootcamp for coders from various backgrounds including frontend, backend, data analysis, and product design. They also have a marketplace for hiring top talent—learn more &lt;a href="https://hng.tech/hire" rel="noopener noreferrer"&gt;here&lt;/a&gt;. Our first task was to write a technical article comparing two front-end technologies. I initially considered writing about ReactJS, the language we'll use in the bootcamp, but there are already tons of articles about ReactJS. So I decided to write about something less common: Elm, and since I'm to compare with another technology, I'm going with Svelte.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's start with Elm
&lt;/h2&gt;

&lt;p&gt;Elm is a functional programming language specifically designed for front-end development. Created by Evan Czaplicki, Elm compiles to JavaScript and emphasizes immutability and type safety, ensuring robust and maintainable codebases.&lt;/p&gt;

&lt;p&gt;Elm is ideal for projects where reliability and maintainability are paramount. Its strong typing and functional programming paradigm make it suitable for large-scale applications that require rigorous code quality and robustness.&lt;/p&gt;

&lt;p&gt;One distinguishing feature of Elm that makes it so different is, all functions written in Elm cannot cause &lt;strong&gt;side effects&lt;/strong&gt;, they are mandatorily pure. But that doesn't mean you cannot develop dynamic pages with it because even if all the functions are pure, there is still a runtime capable of performing some type of side effects, which includes triggering REST services. This one feature makes development much more predictable and easy to maintain.&lt;/p&gt;

&lt;p&gt;Another feature I really loved was &lt;strong&gt;no runtime errors&lt;/strong&gt;. Yes, that's right. It's almost impossible to generate unexpected failure while running your applications. Unlike JavaScript that, no matter how hard you try, errors will always find a way to pop it's ugly head up, that doesn't happen in Elm. The compiler will always show where and how an error can occur and force you to deal with it! Like a friend said, "It's like programming with someone helping you all the time not to screw up!".&lt;/p&gt;

&lt;p&gt;And if you're new to the functional programming world, Elm's compiler generate very friendly error messages that not only point out the mistakes but also teaches the syntax of the language. How cool is that?&lt;/p&gt;

&lt;p&gt;Another cool feature to note is it's package management. Elm enforces semantic versioning and it's possible to compare what has changes from one version of a package to another, using the command &lt;code&gt;elm diff&lt;/code&gt; followed by the name and the versions you want to compare.&lt;/p&gt;

&lt;p&gt;You can learn more about this beautiful language &lt;a href="https://guide.elm-lang.org/" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Now, to Svelte
&lt;/h2&gt;

&lt;p&gt;Svelte, created by Rich Harris, is a relatively new framework that shifts much of the work from the browser to the build step, producing highly optimized vanilla JavaScript. Unlike traditional frameworks like React or Vue, which use a virtual DOM, Svelte compiles components to efficient imperative code that directly updates the DOM.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Features
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;No Virtual DOM&lt;/strong&gt;: Svelte components compile to highly optimized JavaScript that directly manipulates the DOM, resulting in faster updates and smaller bundle sizes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Reactive Declarations&lt;/strong&gt;: Svelte's reactivity is built into the language, allowing for concise and clear state management without the need for additional libraries.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Lightweight Runtime&lt;/strong&gt;: Applications built with Svelte often have smaller initial loads and faster runtime performance compared to other frameworks.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Use Cases
&lt;/h3&gt;

&lt;p&gt;Svelte is particularly well-suited for projects where performance and bundle size are critical. Its simplicity and lack of boilerplate code make it an excellent choice for smaller projects or teams looking to quickly prototype and develop applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bootcamp Opportunity
&lt;/h2&gt;

&lt;p&gt;If you'll like to join me in the HNG internship bootcamp, register &lt;a href="https://hng.tech/internship" rel="noopener noreferrer"&gt;here&lt;/a&gt;. They also offer a certification upon completion for a small fee. This internship is a fantastic opportunity to apply your knowledge, learn from experienced developers, and contribute to real-world projects. Don't miss out!&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Svelte and Elm offer unique approaches to frontend development, each with its own strengths and ideal use cases. Svelte focuses on simplicity and performance, while Elm emphasizes reliability through functional programming.&lt;/p&gt;

</description>
      <category>elm</category>
      <category>svelte</category>
      <category>webdev</category>
      <category>hng</category>
    </item>
    <item>
      <title>Demystifying JSON Web Tokens (JWT): Your Digital Passport to Web Security</title>
      <dc:creator>Jinad AbdulQuadri</dc:creator>
      <pubDate>Fri, 01 Sep 2023 12:45:19 +0000</pubDate>
      <link>https://forem.com/0mobolaji/demystifying-json-web-tokens-jwt-your-digital-passport-to-web-security-4n7m</link>
      <guid>https://forem.com/0mobolaji/demystifying-json-web-tokens-jwt-your-digital-passport-to-web-security-4n7m</guid>
      <description>&lt;p&gt;JSON Web Tokens (JWT) are like digital passports for the internet. They are used to prove who you are and what you're allowed to do when you visit websites or use apps. &lt;/p&gt;

&lt;p&gt;Imagine you have a special ID card with your name and a photo on it. This card also says what you can and cannot do in a certain place. When you go to a website or use an app, you show them this ID card (the JWT) to prove that you are who you say you are and to show what you're allowed to do there.&lt;/p&gt;

&lt;p&gt;The JWT consists of three parts:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Header - Protecting Your ID Card&lt;/strong&gt;: In the world of JWTs, the &lt;strong&gt;Header&lt;/strong&gt; acts like a protective cover for your ID card. It communicates important information about how your ID card (JWT) is safeguarded and what kind of information it holds. Think of it as a holographic seal on your physical ID card, indicating its authenticity.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Payload- Your Digital Identity&lt;/strong&gt;: Just as your ID card holds your personal information, the &lt;strong&gt;Payload&lt;/strong&gt; of a JWT carries essential data about you. This might include your username, user ID, and possibly extra details. Essentially, it mirrors the information on your physical ID card, allowing websites or apps to know who you are and what you're allowed to do.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Signature - Ensuring Tamper-Resistance&lt;/strong&gt;: Now, let's talk about the &lt;strong&gt;Signature&lt;/strong&gt; of a JWT. It's comparable to a secret code that only you and the website or app share. This code is used to verify that your ID card hasn't been tampered with during transmission. Imagine it as an invisible ink mark on your physical ID card that can only be detected under special conditions.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  I. What is a JWT?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;JSON Web Tokens (JWT)&lt;/strong&gt; are digital credentials for the internet, acting as virtual passports that confirm your identity and outline your permissions when you access websites or use applications. Let's break down the acronyms:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;JSON (JavaScript Object Notation)&lt;/strong&gt;: JSON is a widely used data interchange format that's easy for both humans and machines to read and write. In the context of JWT, it's the structure used to represent the data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Web&lt;/strong&gt;: JWTs are predominantly used in web-based applications, making them essential tools for securely managing user identities and authorizations on the internet.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Tokens&lt;/strong&gt;: JWTs are compact pieces of information, like tokens, that encapsulate critical details about a user, which are crucial for authentication and authorization.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  II. How JWT Works
&lt;/h3&gt;

&lt;p&gt;JSON Web Tokens (JWTs) operate through a straightforward process that involves encoding the Header and Payload as JSON, signing the JWT with a secret key, sending it to the recipient, and then verifying and decoding it at the recipient's end. Here's a step-by-step breakdown of this process:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Encoding the Header and Payload as JSON:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Header&lt;/strong&gt;: As the first step, the Header is transformed into a JSON object. This object typically contains information about the type of token (JWT) and the signing algorithm being used. For example, it may look like this: &lt;code&gt;{ "alg": "HS256", "typ": "JWT" }&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Payload&lt;/strong&gt;: Next, the Payload, which contains user-specific data, is also converted into a JSON object. This data can include user IDs, roles, permissions, and more. For instance: &lt;code&gt;{ "sub": "1234567890", "name": "John Doe", "exp": 1630422000 }&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Signing the JWT with a Secret Key:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;After encoding the Header and Payload, the JWT is created by combining these JSON objects and signing them with a secret key using a specified algorithm (as indicated in the Header). This cryptographic operation ensures the JWT's integrity and authenticity.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The secret key is known only to the party creating the JWT (typically a server or an identity provider). It acts as a digital seal, allowing the recipient to verify that the JWT hasn't been tampered with during transmission.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Sending the JWT to the Recipient:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Once the JWT is generated and signed, it is ready to be sent to the intended recipient. This can be done through various means, such as including it in an HTTP header, within a request parameter, or even in a cookie, depending on the application's design.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The recipient, which can be a web server or an application, receives the JWT and begins the verification process.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4. Verification and Decoding at the Recipient's End:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Upon receiving the JWT, the recipient first checks the Header to understand the signing algorithm and ensure it matches the one they expect.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then, the recipient uses the same secret key (which should be securely stored) to verify the JWT's signature. If the signature is valid, it means the JWT has not been altered in transit.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once the JWT's authenticity is verified, the recipient proceeds to decode the JSON objects in the Header and Payload. This allows them to access the information contained within, such as user details and permissions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The recipient can then use this information to make access control decisions or personalize the user's experience based on the data in the Payload.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In summary, JWTs provide a secure and efficient way to transmit information and prove identity between parties. They ensure the integrity of data, prevent unauthorized tampering, and enable decentralized verification. This process simplifies authentication and authorization in distributed systems and web applications, making JWTs a valuable tool in modern web development.&lt;/p&gt;

&lt;h3&gt;
  
  
  III. Use Cases of JWT
&lt;/h3&gt;

&lt;p&gt;JSON Web Tokens (JWT) find practical applications in several scenarios:&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Authentication
&lt;/h4&gt;

&lt;p&gt;JWTs are commonly used for user authentication. When a user logs in, the server issues a JWT containing user information, and the client can present this token in subsequent requests to access protected resources. This approach eliminates the need for session management and is well-suited for stateless microservices architectures.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Authorization
&lt;/h4&gt;

&lt;p&gt;JWTs can carry authorization information, enabling servers to make access control decisions. This is particularly useful when different parts of an application need to share information about a user's permissions.&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Single Sign-On (SSO)
&lt;/h4&gt;

&lt;p&gt;JWTs facilitate Single Sign-On systems, where a user logs in once and gains access to multiple applications without the need to log in again. Each application trusts the JWT issued by the identity provider, enabling seamless user experiences.&lt;/p&gt;

&lt;h4&gt;
  
  
  4. Information Exchange
&lt;/h4&gt;

&lt;p&gt;JWTs are used for securely exchanging information between parties. For instance, they play a pivotal role in OAuth 2.0 flows to exchange tokens between different services.&lt;/p&gt;

&lt;h4&gt;
  
  
  5. Mobile Applications
&lt;/h4&gt;

&lt;p&gt;JWTs are suitable for securing communication between mobile apps and backend servers, allowing mobile clients to request and receive data securely.&lt;/p&gt;

&lt;h3&gt;
  
  
  IV. Advantages of JWT
&lt;/h3&gt;

&lt;p&gt;JSON Web Tokens (JWT) offer several advantages that make them a preferred choice for secure data transmission and authentication:&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Stateless and Scalable
&lt;/h4&gt;

&lt;p&gt;Since JWTs carry all the necessary information, there's no need for the server to store session data, making them highly scalable and suitable for distributed systems.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Cross-Domain Compatibility
&lt;/h4&gt;

&lt;p&gt;JWTs can be easily shared between different domains or services as they are not bound to any specific server or application. This cross-domain compatibility simplifies integration in complex environments.&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Strong Security
&lt;/h4&gt;

&lt;p&gt;JWTs use a digital signature to ensure the integrity and authenticity of the data within the token. Unauthorized tampering is detectable, providing robust security guarantees.&lt;/p&gt;

&lt;h4&gt;
  
  
  4. Decentralized Authentication
&lt;/h4&gt;

&lt;p&gt;JWTs enable decentralized authentication by allowing token verification without the need for a central authority. This makes them suitable for distributed systems where central authentication might not be feasible.&lt;/p&gt;

&lt;h4&gt;
  
  
  5. Flexibility
&lt;/h4&gt;

&lt;p&gt;JWTs can carry any type of information, making them versatile for various use cases. This flexibility allows developers to include custom data relevant to their applications.&lt;/p&gt;

&lt;h3&gt;
  
  
  V. Limitations of JWT
&lt;/h3&gt;

&lt;p&gt;While JWTs offer many advantages, they also have limitations that need to be considered:&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Token Size
&lt;/h4&gt;

&lt;p&gt;JWTs can become large when carrying extensive information, potentially impacting network performance, especially in scenarios with limited bandwidth.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Security Risks
&lt;/h4&gt;

&lt;p&gt;The security of JWTs heavily relies on the secrecy of the key used for signing. If this key is compromised, an attacker can create valid tokens. Key management is crucial to JWT security.&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Token Expiration
&lt;/h4&gt;

&lt;p&gt;JWTs have an expiration time, which can lead to issues if not managed correctly. Tokens might expire while a user is actively using an application, causing disruptions.&lt;/p&gt;

&lt;h4&gt;
  
  
  4. Lack of Revocation
&lt;/h4&gt;

&lt;p&gt;Once issued, JWTs are valid until they expire. There is no built-in mechanism for revoking or invalidating a JWT before its expiration time, which can be a challenge in some use cases.&lt;/p&gt;

&lt;p&gt;In conclusion, understanding the various use cases, advantages, and limitations of JSON Web Tokens (JWT) is essential for making informed decisions when implementing them in web development and security contexts.&lt;/p&gt;

&lt;h3&gt;
  
  
  VII. Best Practices for JWT
&lt;/h3&gt;

&lt;p&gt;JSON Web Tokens (JWT) offer powerful capabilities for authentication and data exchange, but their security and effectiveness depend on proper implementation. Here are key best practices to ensure the secure and effective use of JWTs:&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Key Management
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;a. Use Strong Secret Keys&lt;/strong&gt;: When signing JWTs, use strong cryptographic keys. Weak keys can be easily compromised, putting the security of your tokens at risk. Consider using industry-standard key lengths and algorithms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b. Keep Your Keys Secret&lt;/strong&gt;: Safeguard your secret keys and never expose them publicly or in client-side code. Leaked keys can compromise the security of your JWTs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;c. Key Rotation&lt;/strong&gt;: Implement a key rotation strategy. Regularly changing your secret keys can mitigate the risk associated with key exposure. Ensure seamless transitions between old and new keys to avoid disruptions.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Token Validation
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;a. Verify Signatures&lt;/strong&gt;: Always validate the digital signature of incoming JWTs. Verify that the signature matches the one generated using the expected secret key and algorithm. Reject any tokens with invalid or missing signatures.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b. Check Expiration&lt;/strong&gt;: Enforce token expiration checks. Ensure that tokens have not expired before processing them. Expired tokens should be rejected to prevent unauthorized access.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;c. Validate Claims&lt;/strong&gt;: Check and validate the claims within the Payload, including the issuer (iss), expiration time (exp), and audience (aud). Reject tokens with invalid claims.&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Token Expiration Strategies
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Use Short Expiration Times&lt;/strong&gt;: Keep token lifetimes as short as practical. Short-lived tokens reduce the risk of unauthorized access if a token is compromised. Consider implementing refresh tokens for long-lasting sessions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implement Token Refresh&lt;/strong&gt;: In scenarios where longer-lived sessions are required, consider implementing token refresh mechanisms. This allows users to obtain new tokens without reauthentication.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rotate Keys and Invalidate Old Tokens&lt;/strong&gt;: When performing key rotation, consider invalidating tokens signed with old keys to mitigate the risk of using outdated or compromised tokens.&lt;/p&gt;

&lt;p&gt;By following these best practices, you can maximize the security and reliability of JWTs in your applications. Proper key management, thorough token validation, and thoughtful token expiration strategies are crucial elements in achieving a robust and secure JWT implementation.&lt;/p&gt;

&lt;h3&gt;
  
  
  VIII. Alternatives to JWT
&lt;/h3&gt;

&lt;p&gt;While JSON Web Tokens (JWTs) are a popular choice for authentication and authorization, there are other solutions worth considering:&lt;/p&gt;

&lt;h4&gt;
  
  
  1. &lt;strong&gt;OAuth and OAuth2&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;OAuth (Open Authorization)&lt;/strong&gt; is a widely used protocol for granting third-party applications limited access to user resources without sharing credentials. &lt;strong&gt;OAuth2&lt;/strong&gt; is the current version of this protocol, providing enhanced security and flexibility.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. &lt;strong&gt;OAuth2-based Flows&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;OAuth2 introduces various flows for different use cases, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Authorization Code Flow&lt;/strong&gt;: Ideal for web applications and single-page applications, it provides a secure way to obtain user consent.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Implicit Flow&lt;/strong&gt;: Designed for mobile and JavaScript apps, it allows access tokens to be returned directly from the authorization endpoint.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Client Credentials Flow&lt;/strong&gt;: Used when the client is a confidential client, like a server, without user involvement.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Resource Owner Password Credentials Flow&lt;/strong&gt;: Appropriate for trusted clients, it enables username and password-based authentication.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  3. &lt;strong&gt;OpenID Connect&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Built on top of OAuth2, OpenID Connect provides identity authentication and can be used in conjunction with OAuth2 for secure and standardized user authentication.&lt;/p&gt;

&lt;h4&gt;
  
  
  4. &lt;strong&gt;Cookies and Sessions&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Traditional session-based authentication relies on server-side sessions and cookies to maintain user state. While less stateless than JWTs, they are still widely used in web applications.&lt;/p&gt;

&lt;p&gt;Each of these alternatives has its strengths and weaknesses, and the choice depends on the specific requirements and constraints of your application. Consider factors like security, ease of implementation, compatibility, and scalability when selecting the most suitable authentication and token-based solution for your project.&lt;/p&gt;

&lt;h3&gt;
  
  
  IX. Conclusion
&lt;/h3&gt;

&lt;p&gt;JSON Web Tokens (JWTs) are essential tools in modern web development and security. They simplify authentication, authorization, and data exchange. While offering many advantages, like efficiency and decentralized authentication, they come with considerations like token size and security. Understanding these trade-offs is key to harnessing the power of JWTs effectively and securely in today's digital landscape.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>productivity</category>
      <category>jwt</category>
    </item>
    <item>
      <title>Mastering Web Development: A Guide to Crafting Clean and Sustainable Code</title>
      <dc:creator>Jinad AbdulQuadri</dc:creator>
      <pubDate>Sun, 27 Aug 2023 21:08:27 +0000</pubDate>
      <link>https://forem.com/0mobolaji/mastering-web-development-a-guide-to-crafting-clean-and-sustainable-code-442j</link>
      <guid>https://forem.com/0mobolaji/mastering-web-development-a-guide-to-crafting-clean-and-sustainable-code-442j</guid>
      <description>&lt;p&gt;Imagine you're part of a web development team tasked with enhancing a popular e-commerce website. The project seems straightforward at first - adding new features, improving user interfaces, and boosting performance. However, as you delve into the existing codebase, you find yourself navigating through a maze of cryptic variable names, inconsistent formatting, and a lack of meaningful comments. Each new line of code feels like deciphering a secret language.&lt;/p&gt;

&lt;p&gt;To make matters more challenging, the original developers who crafted this intricate web of code are long gone. There's no one to turn to for explanations, and the project's tight deadlines loom ominously. Frustration sets in as hours are wasted trying to grasp the code's logic, and simple tasks turn into Herculean feats.&lt;/p&gt;

&lt;p&gt;This scenario is all too familiar in the world of web development. The importance of clean and maintainable code becomes glaringly evident in such moments of crisis. In this article, we'll explore the best practices that can transform this nightmare into a dream development experience. We'll uncover the secrets of writing code that's not only functional but also comprehensible, predictable, and easy to maintain. Welcome to the world of clean and maintainable web development code.&lt;/p&gt;

&lt;p&gt;Clean and maintainable code is paramount in web development. It makes code comprehensible and predictable, facilitating seamless collaboration among developers. Clear and readable code reduces debugging efforts, eases onboarding for new team members, and minimizes errors, ultimately accelerating development. Moreover, it ensures long-term project sustainability, saving time and effort in maintenance. In this article, we’ll explore essential best practices for achieving clean and maintainable code in web development.&lt;/p&gt;

&lt;h3&gt;
  
  
  Section 1: Naming convention and code structure
&lt;/h3&gt;

&lt;p&gt;Naming conventions and code structure play a pivotal role in code quality and maintainability.&lt;/p&gt;

&lt;p&gt;Clear, descriptive names are like signposts in your code. They make your code self-documenting, helping developers instantly understand the purpose and functionality of each variable or function. For instance, using &lt;code&gt;userName&lt;/code&gt; instead of vague names like &lt;code&gt;x&lt;/code&gt; or &lt;code&gt;data&lt;/code&gt; not only accelerates development but also reduces the risk of introducing bugs during code modifications.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;Good&lt;/span&gt; &lt;span class="nx"&gt;Naming&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="c1"&gt;// Good: Descriptive variable name&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;userName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;JohnDoe&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Good: Clear function name&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calculateTotalPrice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;itemPrice&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;quantity&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="nx"&gt;Bad&lt;/span&gt; &lt;span class="nx"&gt;Naming&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="c1"&gt;// Bad: Non-descriptive variable name&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;JohnDoe&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Bad: Unclear function name&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the examples above, the good naming practices make it evident what each variable and function does, while the bad naming practices introduce ambiguity and hinder understanding.&lt;/p&gt;

&lt;p&gt;Additionally, consistent code indentation and formatting contribute to code aesthetics and readability. A well-formatted codebase is not only visually organized but also conveys professionalism. This is particularly useful during collaborations or code reviews.&lt;/p&gt;

&lt;p&gt;Proper indentation helps in quickly identifying code blocks and their hierarchies, while consistent formatting conventions promote uniformity across the codebase. This can be invaluable when troubleshooting issues or making modifications. Consider a block of code with inconsistent indentation; it's like trying to read a book with randomly scattered paragraphs. You'll spend more time deciphering the structure than understanding the content.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TIP:&lt;/strong&gt; Utilizing code analysis tools like ESLint and Prettier can be very helpful. These tools can automatically detect and fix issues related to code formatting and naming conventions, helping you maintain a uniform structure. You should also create a set of coding guidelines for your project or team. These guidelines should cover naming conventions, indentation, and formatting rules. Adhering to these guidelines will help ensure consistency throughout the codebase.&lt;/p&gt;

&lt;p&gt;Having discussed the significance of naming conventions and code structure, let’s now turn our attention to the critical role of comments and documentation.&lt;/p&gt;

&lt;h3&gt;
  
  
  Section 2: Comments and Documentation
&lt;/h3&gt;

&lt;p&gt;Comments and documentation serve as invaluable navigational aids. They serve as essential tools for communication, clarification, and long-term project sustainability.&lt;/p&gt;

&lt;p&gt;Comments play a vital role in code by providing context and explanations. They act as notes to future developers, helping them understand why certain code decisions were made.&lt;/p&gt;

&lt;p&gt;When dealing with complex algorithms or edge cases, inline comments elucidate the thought process behind the code, making it easier to troubleshoot and modify. However, the ultimate goal is to move towards self-documenting code. In an ideal scenario, the code itself is so well-structured and expressive that it requires minimal comments. This not only streamlines the codebase but also reduces the risk of comments becoming outdated.&lt;/p&gt;

&lt;p&gt;When developing APIs or libraries intended for public use or collaborations, thorough and comprehensive documentation becomes crucial. Documentation offers users and developers insights into how to interact with and extend the codebase effectively. It serves as a roadmap, preventing potential pitfalls, providing expected outputs, delineating parameters, and minimizing troubleshooting times.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TIP:&lt;/strong&gt; Documentation is not a ‘set it and forget it’ task. As your code evolves, the documentation should follow suit. This practice prevents outdated information from misleading other developers or even your future self, maintaining the reliability of your project’s documentation.&lt;/p&gt;

&lt;p&gt;Let’s move on to the benefits of modularization.&lt;/p&gt;

&lt;h3&gt;
  
  
  Section 3: Modularization and Code Organization
&lt;/h3&gt;

&lt;p&gt;Modularization and code organization are keystones to achieving scalable code.&lt;/p&gt;

&lt;p&gt;Modularization, the process of dividing code into discrete, independent modules, brings a host of benefits. It enhances code reusability, allowing you to reuse modules across your projects or even in other projects. When you encounter a situation where similar functionality is required, you can simply import and utilize the relevant module, reducing redundancy.&lt;/p&gt;

&lt;p&gt;When a bug arises or a feature needs modification, you can isolate the affected module, making troubleshooting and updates more efficient. This isolation minimizes the risk of unintended side effects on other parts of your code.&lt;/p&gt;

&lt;p&gt;Modules, classes, and functions are the building blocks of code separation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Modules:&lt;/strong&gt; are encapsulated in files, grouping related code logically. They allow you to export and expose only what's necessary, reducing the risk of unintended access or modification.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Classes:&lt;/strong&gt;  encapsulate both data and behavior. They provide a structured blueprint for creating objects with consistent properties and methods, facilitating reusability and organization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Functions:&lt;/strong&gt; should ideally perform a single, well-defined task, with a descriptive name that clarifies its purpose. This promotes both reusability and maintainability.&lt;/p&gt;

&lt;p&gt;Organizing files and directories is crucial for maintaining a structured project. Grouping related files into directories based on functionality, components, or features promotes orderliness. For instance, you can have separate directories for models, views, controllers, and utilities in a web application. This not only fosters easy navigation but also prevents clutter and confusion.&lt;/p&gt;

&lt;p&gt;Managing dependencies is essential to avoid code bloat and ensure smooth integration of external libraries or packages. Utilize package managers like npm or yarn to maintain a clear record of dependencies and versions. Additionally, adhere to Semantic Versioning (SemVer) to manage updates without introducing compatibility issues.&lt;/p&gt;

&lt;p&gt;Embracing modularization, employing well-structured modules, classes, and functions, organizing files systematically, and managing dependencies judiciously collectively cultivate a codebase that is comprehensible, adaptable, and maintainable.&lt;/p&gt;

&lt;h3&gt;
  
  
  Section 4: Error Handling and Testing
&lt;/h3&gt;

&lt;p&gt;Error handling is a foundational pillar in code quality and maintenance.&lt;/p&gt;

&lt;p&gt;It’s not a matter of if errors will occur in your code, but when they do, how your code responds defines its resilience and usability. Proper error handling ensures that when unexpected scenarios arise, your code doesn’t crumble but responds gracefully.&lt;/p&gt;

&lt;p&gt;When errors arise, they shouldn’t result in cryptic messages that leave developers perplexed. Instead, they should provide clear insights into what went wrong and how to rectify it. Graceful error handling not only aids developers in troubleshooting but also enhances user experiences.&lt;/p&gt;

&lt;p&gt;For instance, when handling user input, validating data and providing specific error messages when data doesn’t meet requirements can prevent frustration and confusion. Moreover, logging errors systematically aid in diagnosing issues promptly.&lt;/p&gt;

&lt;p&gt;Here are some best practices to follow in handling errors gracefully:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use Try-Catch Blocks:&lt;/strong&gt; In languages like Javascript, employ try-catch blocks to encapsulate code that might throw errors. This allows you to catch and handle exceptions gracefully.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Provide Context:&lt;/strong&gt; When an error occurs, include contextual information in the error message. Indicate what operation was being performed, what inputs were provided, and what the user or developer should do next.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Log Errors:&lt;/strong&gt; Implement logging mechanisms to record errors. These logs are invaluable for debugging and monitoring your application’s health in real-world scenarios.&lt;/p&gt;

&lt;p&gt;Writing unit tests involves defining scenarios and expected outcomes for various code components. The benefits of unit testing are substantial, they provide a safety net when refactoring code ensuring that existing functionality isn’t inadvertently broken by changes. They also help catch bugs and errors in the development process, reducing the cost and complexity of fixing issues later.&lt;/p&gt;

&lt;p&gt;For web applications, you can utilize testing frameworks like Jest, Mocha, or Jasmine. Consider a scenario where you’re testing a user authentication function, you would need to design tests to verify successful authentication, incorrect passwords, and other possible scenarios. This is implemented in the code below using Jest:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Example using Jest&lt;/span&gt;
&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;User authentication succeeds with correct credentials&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;authenticateUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;username&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;password&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;User authentication fails with incorrect password&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;authenticateUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;username&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;incorrect_password&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Another example of testing with Jest&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;addition&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this section, we’ve explored the pivotal role of error handling in maintaining code quality and the importance of crafting meaningful error messages. Additionally, we’ve introduced the concept of unit testing and its indispensable role in code maintainability, providing examples to illustrate its implementation in web applications.&lt;/p&gt;

&lt;p&gt;In conclusion, writing clean and maintainable code isn't merely a best practice; it's the bedrock of successful web development. These principles not only benefit individual developers but also elevate the entire team's productivity and the longevity of your projects. As you embark on your coding journey, remember that embracing these practices isn't just about writing better code—it's about becoming a more efficient and effective web developer. Apply them in your projects, share them with your team, and witness your codebase transform into a model of clarity and sustainability. Happy coding!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>productivity</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>How to Master Lodash: A Comprehensive Guide</title>
      <dc:creator>Jinad AbdulQuadri</dc:creator>
      <pubDate>Sun, 27 Aug 2023 20:21:59 +0000</pubDate>
      <link>https://forem.com/0mobolaji/how-to-master-lodash-a-comprehensive-guide-2ihm</link>
      <guid>https://forem.com/0mobolaji/how-to-master-lodash-a-comprehensive-guide-2ihm</guid>
      <description>&lt;p&gt;Among the many Javascript libraries, Lodash shines as a powerful utility. Often underestimated, Lodash boasts a wealth of functions designed to streamline everyday programming tasks. Whether you're manipulating arrays or managing objects, Lodash can greatly simplify your code and enhance its readability and quality.&lt;/p&gt;

&lt;p&gt;In this guide, I'll furnish you with practical examples and insights to empower you with the skills needed to leverage Lodash's capabilities in your projects.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Installation
&lt;/h3&gt;

&lt;p&gt;Before you can start using Lodash, you need to install it in your project. Open your terminal and navigate to your project directory. Then, run the following command to install Lodash as a dependency using npm:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;lodash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Importing Lodash
&lt;/h3&gt;

&lt;p&gt;Once installed, you can import Lodash into your JavaScript files. You can import the entire Lodash library or specific functions from it. Here's how you can import the entire library:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;const _ &lt;span class="o"&gt;=&lt;/span&gt; require&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'lodash'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code, we're using &lt;code&gt;_&lt;/code&gt; as an alias for Lodash. This is a common convention to keep your code concise.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Using Lodash Functions
&lt;/h3&gt;

&lt;p&gt;Lodash provides a vast range of functions. Let's explore a few examples:&lt;/p&gt;

&lt;h4&gt;
  
  
  Array Manipulation:
&lt;/h4&gt;

&lt;h5&gt;
  
  
  Splitting an array into chunks
&lt;/h5&gt;

&lt;p&gt;You have an array of tasks, and you want to split them into groups of two for better organization. Here’s how you can do that with Lodash:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;tasks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Task A&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Task B&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Task C&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Task D&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Task E&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="c1"&gt;// Split the tasks into chunks of two using Lodash&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;taskChunks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Output: [['Task A', 'Task B'], ['Task C', 'Task D'], ['Task E']]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice the simplicity Lodash brings? Now, contrast it with the verbosity of the non-Lodash code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;tasks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Task A&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Task B&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Task C&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Task D&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Task E&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;chunkArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;array&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;chunkSize&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;chunks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;chunkSize&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;chunks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;chunkSize&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;chunks&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;taskChunks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;chunkArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Output: [['Task A', 'Task B'], ['Task C', 'Task D'], ['Task E']]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s check other examples under array manipulation.&lt;/p&gt;

&lt;h5&gt;
  
  
  Randomly Shuffling an Array
&lt;/h5&gt;

&lt;p&gt;You have a deck of cards represented as an array, and you want to shuffle them randomly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;deck&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Ace&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;King&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Queen&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Jack&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;10&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;9&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;8&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;7&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="c1"&gt;//With Lodash&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;shuffledDeck&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;shuffle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;deck&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Without Lodash&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;shuffleArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;array&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;shuffled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;array&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;shuffled&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;random&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
        &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;shuffled&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="nx"&gt;shuffled&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;shuffled&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="nx"&gt;shuffled&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]];&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;shuffled&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;shuffledDeck&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;shuffleArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;deck&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Output: Randomly shuffled array&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Calculating Differences between Arrays
&lt;/h5&gt;

&lt;p&gt;We want to compare two arrays, list and toRemove, to find unique items.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;A&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;B&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;C&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;D&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;E&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;toRemove&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;B&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;E&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;F&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;


&lt;span class="c1"&gt;// With Lodash&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;uniqueItems&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;xor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;list&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;toRemove&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Without Lodash&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;findUniqueItems&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;array1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;array2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;unique1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;array1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;array2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;unique2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;array2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;array1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;unique1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;concat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;unique2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;uniqueItems&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;findUniqueItems&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;list&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;toRemove&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Output: ['A', 'C', 'D', 'F']&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Having explored the contrasting efficiency of Lodash versus non-Lodash code, let's delve deeper into various additional use cases where Lodash's capabilities shine brightly.&lt;/p&gt;

&lt;h4&gt;
  
  
  Object Manipulation:
&lt;/h4&gt;

&lt;h5&gt;
  
  
  Deep Merging Objects
&lt;/h5&gt;

&lt;p&gt;You have two objects with nested properties, and you want to merge them deeply.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;object1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;object2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;c&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// With Lodash&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;mergedObject&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;merge&lt;/span&gt;&lt;span class="p"&gt;({},&lt;/span&gt; &lt;span class="nx"&gt;object1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;object2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Without Lodash&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;mergedObject&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;({},&lt;/span&gt; &lt;span class="nx"&gt;object1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;({},&lt;/span&gt; &lt;span class="nx"&gt;object1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;object2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Output: { a: { b: 1, c: 2 } }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Picking Specific Properties
&lt;/h5&gt;

&lt;p&gt;You have an object with multiple properties, and you want to create a new object containing only specific properties.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// With Lodash&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;originalObject&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;john@example.com&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;pickedProperties&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pick&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;originalObject&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;email&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;

&lt;span class="c1"&gt;// Without Lodash&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;pickedProperties&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;originalObject&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;originalObject&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// Output: { name: 'John', email: 'john@example.com' }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Renaming Object Keys
&lt;/h5&gt;

&lt;p&gt;You have an object with keys in snake_case, and you want to convert them to camelCase.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;originalObject&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;first_name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;last_name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Doe&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// With Lodash&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;camelCaseObject&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mapKeys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;originalObject&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;camelCase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

&lt;span class="c1"&gt;// Without Lodash&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;camelCaseObject&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;
&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;originalObject&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;camelCaseObject&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;camelCase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;originalObject&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Output: { firstName: 'John', lastName: 'Doe' }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Functional Programming:
&lt;/h4&gt;

&lt;h5&gt;
  
  
  Currying
&lt;/h5&gt;

&lt;p&gt;Currying is the process of converting multi-argument functions into a sequence of single-argument functions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// With Lodash&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;add&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;curry&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;add5&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;add5&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// Output: 15&lt;/span&gt;

&lt;span class="c1"&gt;// Without Lodash&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;add5&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;add5&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// Output: 15&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Memoization
&lt;/h5&gt;

&lt;p&gt;Memoization is a technique where the results of expensive function calls are cached and returned when the same inputs occur again.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// With Lodash&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;memoizedFactorial&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;memoize&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nf"&gt;memoizedFactorial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;memoizedFactorial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// Output: 120 (cached)&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;memoizedFactorial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// Output: 720 (cached)&lt;/span&gt;

&lt;span class="c1"&gt;// Without Lodash&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;memo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;factorial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;memo&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;memo&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;memo&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nf"&gt;factorial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;memo&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;factorial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// Output: 120 (cached)&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;factorial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// Output: 720 (cached)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Composition
&lt;/h5&gt;

&lt;p&gt;Function composition involves merging two or more functions to create a fresh function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;greet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;`Hello, &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;!`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;toUpperCase&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;str&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toUpperCase&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// With Lodash&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;greetAndUppercase&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;flowRight&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;toUpperCase&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;greetAndUppercase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// Output: "Hello, JOHN!"&lt;/span&gt;

&lt;span class="c1"&gt;// Without Lodash&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;greetAndUppercase&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;toUpperCase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;greetAndUppercase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// Output: "Hello, JOHN!"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4: Explore the Documentation
&lt;/h3&gt;

&lt;p&gt;Lodash's documentation is an invaluable resource. It provides detailed information about each function, its usage, and examples. Explore the documentation to discover the full range of functions Lodash offers and find the ones that fit your needs:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://lodash.com/docs/4.17.21" rel="noopener noreferrer"&gt;Lodash Documentation&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5: Use Lodash Responsibly
&lt;/h3&gt;

&lt;p&gt;While Lodash can simplify your code, be mindful of using it appropriately. Importing the entire library can add unnecessary bulk to your project. Instead, import only the functions you need to optimize your codebase's size and performance.&lt;/p&gt;

&lt;p&gt;Lodash is a versatile tool that can save you time and improve your code quality. By following these guidelines, you'll be well on your way to leveraging its power effectively in your JavaScript projects.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Web Sockets: Real-Time Web Development</title>
      <dc:creator>Jinad AbdulQuadri</dc:creator>
      <pubDate>Sat, 26 Aug 2023 20:46:47 +0000</pubDate>
      <link>https://forem.com/0mobolaji/web-sockets-real-time-web-development-5fac</link>
      <guid>https://forem.com/0mobolaji/web-sockets-real-time-web-development-5fac</guid>
      <description>&lt;p&gt;As the digital realm continues to expand, users now demand more than static pages and asynchronous updates. They now require dynamic, real-time interactions akin to face-to-face conversations. This is where WebSockets shine, allowing data to flow seamlessly between clients and servers in real-time, and unlocking new possibilities that were previously inaccessible.&lt;/p&gt;

&lt;p&gt;WebSockets are a two-way communication protocol that enables real-time, bidirectional, and full-duplex communication between a client (typically a web browser) and a server over a single, long-lived connection. Think of WebSockets as a persistent, virtual “tunnel” between a web application and a server. Once established, this tunnel remains open, allowing data to flow in both directions without the need for repeated requests. It’s like having a phone line that’s always active, so you can instantly make and receive calls without dialing the person’s number each time. &lt;/p&gt;

&lt;p&gt;This technology is particularly valuable for building interactive web applications, such as chat applications, online gaming, collaborative document editing, and live data feeds. They enhance user experiences with real-time updates, reduce latency, and empower developers to create dynamic, engaging online experiences.&lt;/p&gt;

&lt;h4&gt;
  
  
  Some key terms explained:
&lt;/h4&gt;

&lt;p&gt;To master WebSockets and create real-time, interactive web applications, it’s essential to understand these key terminologies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;WebSocket Protocol:&lt;/strong&gt; The WebSocket protocol is a standardized communication protocol that provides full-duplex, bidirectional communication channels over a single TCP (Transmission Control Protocol) connection.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Client:&lt;/strong&gt; The end-users web browser or application that initiates a WebSocket connection to a server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Server:&lt;/strong&gt; The server is the backend component that handles WebSocket connections, processes incoming messages, and sends messages back to clients.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Handshake:&lt;/strong&gt; The WebSocket handshake is the initial process where a client requests to establish a WebSocket connection, and the server acknowledges this request. It involves an HTTP handshake followed by a WebSocket handshake.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Uniform Resource Identifier (URI):&lt;/strong&gt; A URI is a unique address used to identify a WebSocket endpoint, typically in the format &lt;code&gt;ws://&lt;/code&gt; (for unencrypted connections) or &lt;code&gt;wss://&lt;/code&gt; (for encrypted connections).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Text data:&lt;/strong&gt; Human-readable data sent as messages in WebSocket frames. It's typically encoded as UTF-8 text.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Frame:&lt;/strong&gt; A WebSocket frame is the smallest unit of data exchanged in a WebSocket connection. Frames can be text, binary, or control frames used for specific purposes like connection management.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ping and Pong Frames:&lt;/strong&gt; Control frames used to check the health of a WebSocket connection. The server can send a ping frame, and the client should respond with a pong frame to confirm that the connection is alive.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;WebSocket Secure (WSS):&lt;/strong&gt; A secure version of WebSocket that uses encryption (TLS/SSL) for data transmission. It's essential for securing sensitive data in WebSocket connections.&lt;/p&gt;

&lt;h3&gt;
  
  
  Understanding the WebSockets Protocol
&lt;/h3&gt;

&lt;p&gt;At its core, the WebSocket protocol builds upon the HTTP protocol, initially starting with an HTTP handshake. When a client desires to establish a WebSocket connection, it sends an initial HTTP request to the server. Importantly, this request includes an “Upgrade” header field, signaling the intent to switch to the WebSocket protocol. The server, if WebSocket-capable, responds with an “Upgrade” header of its own, thereby confirming the protocol shift.&lt;/p&gt;

&lt;p&gt;Once the handshake is successfully completed, the connection transitions from HTTP to WebSocket, commonly signified by a change in the URL scheme, from &lt;code&gt;http://&lt;/code&gt; to &lt;code&gt;ws://&lt;/code&gt; for unencrypted connections or &lt;code&gt;https://&lt;/code&gt; to &lt;code&gt;wss://&lt;/code&gt; for secure, encrypted connections.&lt;/p&gt;

&lt;p&gt;A fundamental feature of the WebSocket protocol is its persistent connection. Unlike traditional HTTP, where each interaction necessitates a new request and response, WebSocket maintains an open channel, permitting either the client or server to dispatch data at any time.&lt;/p&gt;

&lt;h4&gt;
  
  
  How is data transferred?
&lt;/h4&gt;

&lt;p&gt;Data is transferred in small discrete units called frames. Frames come in various types, including data frames for transmitting application data (which can be in text or binary format) and control frames used for managing the connection (e.g., ping and pong frames for connection health checks or close frames for graceful connection termination).&lt;/p&gt;

&lt;p&gt;Moreover, WebSockets excel in supporting binary data, making it highly adaptable for applications involving file transfers, multimedia content, or any non-textual information. Text data is also supported, facilitating human-readable messages.&lt;/p&gt;

&lt;p&gt;In scenarios where the WebSocket connection is no longer needed, either the client or the server can initiate a graceful closure by transmitting a close frame. This frame may include a status code and a reason for closure, ensuring both parties understand the reason behind the connection termination.&lt;/p&gt;

&lt;p&gt;Lastly, WebSocket security is bolstered through the WebSocket Secure (WSS) protocol, which encrypts the data transmitted between the client and server, guaranteeing the integrity of the communication.&lt;/p&gt;

&lt;h3&gt;
  
  
  WebSockets VS HTTPS
&lt;/h3&gt;

&lt;p&gt;WebSockets and traditional HTTPS differ in their communication models. WebSockets provide persistent, bidirectional communication over a single connection, enabling real-time data exchange without repeated requests. They excel in interactive applications like chat and gaming due to reduced latency and efficient updates. In contrast, traditional HTTPS follows a request-response model, involving separate connections for each interaction resulting in higher latency. It’s designed for textual data transmission, while WebSockets support both text and binary data efficiently. HTTPS is suitable for typical web browsing, while WebSockets enhance real-time, dynamic experiences by maintaining open channels for simultaneous data transfer between clients and servers.&lt;/p&gt;

&lt;p&gt;WebSockets are particularly advantageous in applications that require a high number of concurrent connections. For example, in social media platforms, where users receive real-time notifications, or in live streaming services, where numerous users simultaneously watch and interact with content. HTTPS, on the other hand, is indispensable when security is paramount. It ensures that data transmitted between clients and servers is encrypted, making it an essential choice for financial transactions, online shopping, healthcare applications, and any scenario where the confidentiality and integrity of data are critical. In these contexts, HTTPS provides the necessary protection against eavesdropping and data tampering.&lt;/p&gt;

&lt;p&gt;Additionally, WebSockets are resource-efficient for servers. Traditional HTTP connections require repeated establishment and teardown, which can strain server resources, especially when serving a large user base. In contrast, WebSockets maintain a single, persistent connection for each client, reducing server overhead and making them an excellent choice for applications that need to scale horizontally to accommodate a growing user base.&lt;/p&gt;

&lt;p&gt;Moreover, HTTPS offers advantages in terms of Search Engine Optimization (SEO). Traditional websites that use HTTPS are favored by search engines like Google, which gives them a ranking boost. Additionally, HTTPS enables more effective content indexing and caching, contributing to improved SEO results. This makes HTTPS the preferred option for websites aiming to maximize their online visibility and search engine rankings.&lt;/p&gt;

&lt;p&gt;In conclusion, WebSockets are poised to redefine the landscape of web development by ushering in a new era of real-time, interactive, and dynamic applications. With their ability to reduce latency, facilitate efficient data exchange, and enhance user engagement, WebSockets empowers developers to create innovative solutions across various domains. From real-time collaboration to IoT connectivity, their potential to transform the way we interact with the web is immense. Embracing WebSockets represents a strategic move for developers and businesses seeking to deliver cutting-edge, responsive, and competitive online experiences, marking a pivotal shift in the evolution of web development.&lt;/p&gt;

</description>
      <category>websockets</category>
      <category>api</category>
      <category>realtime</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
