<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Dev By RayRay]]></title><description><![CDATA[🚀 Lead Frontend/JavaScript Developer
🔥 Writing about CSS, JavaScript, Typescript, Angular, Serverless functions, and a lot more web-related topics.]]></description><link>https://hasnode.byrayray.dev</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1630051986776/j3HW9FsOb.png</url><title>Dev By RayRay</title><link>https://hasnode.byrayray.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Sun, 19 Apr 2026 17:34:35 GMT</lastBuildDate><atom:link href="https://hasnode.byrayray.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[I Watched Two Dev Teams Fight a Mono-Repo War. A Manager Started It.]]></title><description><![CDATA[(Note: To protect everyone's privacy, I will not be naming the organization, the projects, the managers, or the teams involved in this story. The lessons are universal, and that's what matters.)


The "Efficient" Promise
It was my first major project...]]></description><link>https://hasnode.byrayray.dev/i-watched-two-dev-teams-fight-a-mono-repo-war-a-manager-started-it</link><guid isPermaLink="true">https://hasnode.byrayray.dev/i-watched-two-dev-teams-fight-a-mono-repo-war-a-manager-started-it</guid><category><![CDATA[Product Management]]></category><category><![CDATA[software development]]></category><category><![CDATA[software architecture]]></category><category><![CDATA[Software Engineering]]></category><dc:creator><![CDATA[Dev By RayRay]]></dc:creator><pubDate>Fri, 07 Nov 2025 20:04:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1762544918854/7f2acea8-3cb7-43c6-9d6c-e226fa34045e.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote>
<p><em>(Note: To protect everyone's privacy, I will not be naming the organization, the projects, the managers, or the teams involved in this story. The lessons are universal, and that's what matters.)</em></p>
</blockquote>
<hr />
<h3 id="heading-the-efficient-promise">The "Efficient" Promise</h3>
<p>It was my first major project in a new capacity. I was in the middle of transitioning from being a developer <em>in</em> a team to a Tech Lead <em>overseeing</em> teams.</p>
<p>The project seemed straightforward: rebuild a website with new tech. We were finally decoupling the front-end from the back-end (yes, I know, it's amazing this is still a 'new' thing in some organizations) and using GraphQL. It was exciting.</p>
<p>The budget and deadline, of course, had already been set by management.</p>
<p>Then came the meeting. The 'Big Idea' meeting.</p>
<p>A project leader pointed out, "You know, Website B uses 90% of the same data as Website A. It would be incredibly <em>efficient</em> if we just... build them both at the same time? In the same project?"</p>
<p>The non-technical managers in the room nodded. They saw spreadsheets. They saw synergy. They saw a '2-for-1' deal.</p>
<p>My teammate and I looked at each other. We saw the disaster from miles away.</p>
<p>We knew we had to speak up, even though we didn't want to be the "party poopers." We explained that <em>architecturally</em> this wasn't a good idea. That forcing two different teams with two different goals into one repo would create massive challenges.</p>
<p>And then we fell into the classic developer's trap.</p>
<p>A manager asked, "But... setting the challenges aside, is it <em>technically possible</em>? Can you <em>manage</em> it?"</p>
<p>As engineers, we answered honestly: "Well... <em>technically</em>... yes, we can <em>make</em> it work. But it's not the right way to do it."</p>
<p><strong>They only heard the "yes."</strong> They ignored the rest.</p>
<p>Our technical honesty—the distinction between what is <em>possible</em> and what is <em>wise</em>—was just used as a green light. They heard "technically manageable." We <em>meant</em> "architectural nightmare."</p>
<p>That was the real "Oh... SHIT" moment. The decision was made.</p>
<hr />
<h3 id="heading-the-setup-two-teams-one-arena">The Setup: Two Teams, One Arena</h3>
<p>Here was the fatal structure the non-technical managers had designed:</p>
<ul>
<li><p><strong>The Arena:</strong> A single mono-repo. (Because: 'shared code' = 'efficient').</p>
</li>
<li><p><strong>Team A (Internal):</strong> My team. Our Goal: Build a sustainable, scalable, and maintainable solution. We were the craftsmen. We would own the platform long-term.</p>
</li>
<li><p><strong>Team B (External):</strong> The hired guns. Their Goal: Hit the deadline, at all costs. They would send an invoice and then disappear.</p>
</li>
</ul>
<p>They had put two teams with <em>exact-opposite incentives</em> in the same cage and expected them to collaborate.</p>
<hr />
<h3 id="heading-the-conflict-the-mono-repo-war">The Conflict: The Mono-Repo War</h3>
<p>This wasn't an immediate explosion. It was a slow-motion tragedy in three acts.</p>
<p><strong>Act 1: The First Cracks</strong> To be fair, it didn't start as a war. The first few sprints were actually collaborative. We were all figuring out the new architecture, communicating, and building.</p>
<p>The cracks began to show when my team (Internal) started building the core, sustainable, shared components. As craftsmen, we were building them <em>properly</em>—thinking about accessibility, scalability, and reusability. This is the crucial work that saves you from a year of pain later.</p>
<p>But this kind of "doing it right" takes time.</p>
<p>The external team, and the PO, didn't see 'quality'. They saw 'slowness'. They had a deadline to hit. Our craft was a <em>blocker</em> for their velocity.</p>
<p><em>This</em> was the first real crack. Frustrated, Team B did what they were incentivized to do: they started cutting corners to <em>get around</em> our "slow" process. They began writing one-off, unsustainable code to 'just get the feature out'.</p>
<p><strong>Act 2: The Political Coup</strong> The conflict quickly escalated from the code editor to the meeting room. And let's be clear: I don't blame the external team. They were simply executing on their goal (speed). The friction was inevitable because their goal was fundamentally in conflict with our goal (sustainability).</p>
<p>The manager of the external team, frustrated by our 'quality gates', went directly to the Product Owner (PO).</p>
<p>Their argument was as simple as it was deadly: "The internal team is <em>blocking</em> us. <em>They</em> are the reason we're going to miss the deadline."</p>
<p>They had successfully reframed the narrative. Our quality control wasn't 'guarding the architecture' anymore; it was 'a blocker to progress'.</p>
<p>And the PO, who was under immense pressure to hit the (already unrealistic) deadline, zwichtte. They made a fatal error: as the owner of <em>functional priorities</em> (the "what"), they stepped out of their role and made a <em>technical</em> decision (the "how").</p>
<p>They chose speed.</p>
<p><strong>Act 3: The Banishment</strong> It all culminated in a meeting I will never forget. The PO, now fully allied with the 'speed-at-all-costs' manager, made the final call.</p>
<p>My teammate and I—the two developers fighting hardest for the long-term sustainability of the platform—were <strong>officially removed from the project by the Product Owner.</strong></p>
<p>We were the problem. The 'difficult' developers who were 'slowing things down'.</p>
<hr />
<h3 id="heading-the-reckoning-the-real-cost-of-efficiency">The Reckoning: The Real Cost of "Efficiency"</h3>
<p>With 'the blockers' (us) out of the way, the external team had free rein. They slammed the code through. They 'hit' the deadline (with massive stress and overtime). The manager was 'satisfied'. The PO was 'relieved'.</p>
<p>And now, months later, the <em>real</em> bill is here.</p>
<p>Team B is long gone.</p>
<p>And the backlog from the external team? <strong>That's <em>our</em> backlog now.</strong> A toxic, open sewer of bugs, performance issues, and architectural sins that my internal team now has to live and work in, every single day.</p>
<p>The "fast" solution created an <em>endless</em> maintenance burden.</p>
<p>The only saving grace? The internal developers who remain. They are, to a person, craftsmen who believe in building sustainable solutions, and I am incredibly lucky to work with them. But <em>they</em> are the ones now paying the price, forced to clean up a mess they never made.</p>
<hr />
<h3 id="heading-the-lesson-the-birth-of-my-role-as-a-tech-lead">The Lesson: The Birth of My Role as a Tech Lead</h3>
<p>This disaster wasn't just a 'bad project.' It was the end of my role <em>in</em> a team and the beginning of my role as a Tech Lead.</p>
<p>My own team leader was <em>furious</em>. He saw exactly what had happened:</p>
<ol>
<li><p>A non-technical manager had created an architectural disaster by forcing two conflicting goals into one codebase.</p>
</li>
<li><p>A Product Owner had stepped out of their role, making a <em>technical</em> decision (speed/debt) instead of a <em>functional</em> one (priority).</p>
</li>
<li><p>Craftsmanship had been sacrificed for short-term politics.</p>
</li>
</ol>
<p>His solution was to create my new role. A Tech Lead, positioned <em>outside</em> the project silos, with one clear, organization-wide mandate:</p>
<blockquote>
<p><strong>"This can never happen again."</strong></p>
</blockquote>
<hr />
<h3 id="heading-my-lesson-for-every-manager">My Lesson for Every Manager</h3>
<p>My role was born from that conflict. And that is what I, and the amazing internal team, are fixing to this day. We're not just cleaning up the mess; we're building a better way to work.</p>
<p>We are defining our quality standards. Not "perfection"—perfection is a trap. We are defining <em>sustainable</em> and <em>stable</em> standards. We are building the guardrails that make it easier for teams to maintain quality, even when project pressure builds.</p>
<p>Here is my simple, yet unbreakable, lesson for every manager, project leader, and Product Owner out there.</p>
<blockquote>
<p><strong>Never. Ever. Make a technical decision.</strong></p>
<p>That's what your Tech Leads and developers are for. They are more than capable of handling it.</p>
<p>And if your tech team <em>does</em> ask you to make a choice—like "Do we choose Speed or Quality?"—your <em>only</em> job is to let them advise you. Ask them to explain the consequences. They are the only ones who truly understand the <em>long-term technical effects</em> of each choice.</p>
<p>Listen to them. Trust their craft. You may not hear the answer you want, but you'll hear the one that's true. And you'll save yourself from starting a war you can't win.</p>
</blockquote>
<hr />
<p><em>What do you think? Have you seen a "logical" decision doom a project? How do you guard the line between technical and non-technical decisions in your organization?</em></p>
]]></content:encoded></item><item><title><![CDATA[Stop Adding PR Reviewers One-by-One in Azure DevOps]]></title><description><![CDATA[Are you still adding your teammates one by one to your Azure DevOps PRs?
You know the drill. You create your pull request, then click and search for Jane. Click, search for Bob. Click, search for Maria. Did you forget someone? Probably.
It's a repeti...]]></description><link>https://hasnode.byrayray.dev/stop-adding-pr-reviewers-one-by-one-in-azure-devops</link><guid isPermaLink="true">https://hasnode.byrayray.dev/stop-adding-pr-reviewers-one-by-one-in-azure-devops</guid><category><![CDATA[Devops]]></category><category><![CDATA[Azure]]></category><category><![CDATA[azure-devops]]></category><dc:creator><![CDATA[Dev By RayRay]]></dc:creator><pubDate>Fri, 07 Nov 2025 09:47:15 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1762508745584/0ccf66a6-e663-4fc5-ae23-0462bd95b980.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Are you still adding your teammates one by one to your Azure DevOps PRs?</p>
<p>You know the drill. You create your pull request, then click and search for Jane. Click, search for Bob. Click, search for Maria. Did you forget someone? Probably.</p>
<p>It's a repetitive task that's slow, tedious, and just gets in the way of merging your code.</p>
<p>There is a much cleaner, more efficient way to handle this. You don't want to manage a list of individuals; you want a single rule that says, "I need one approval from the Dev Team."</p>
<p>Let's build that rule. It's a "set it and forget it" fix using a <strong>Branch Policy</strong>.</p>
<hr />
<h2 id="heading-prerequisite-a-team">Prerequisite: A Team</h2>
<p>This trick relies on having your reviewers grouped into a 'Team' in Azure DevOps. If you haven't done this, it's a one-time setup and makes managing permissions much easier. Check the docs on <a target="_blank" href="https://learn.microsoft.com/en-us/azure/devops/organizations/settings/add-teams?view=azure-devops&amp;tabs=preview-page">how to create a team in Azure DevOps</a>.</p>
<hr />
<h2 id="heading-your-branch-policy">Your Branch Policy</h2>
<p>You set this up once on your target branch (like <code>main</code> or <code>develop</code>), and it works forever.</p>
<ol>
<li><p>Go to <strong>Project Settings</strong> (represented by the gear icon, located in the bottom-left corner).</p>
</li>
<li><p>Navigate to <strong>Repositories</strong> (under the <code>Repos</code> heading).</p>
</li>
<li><p>Click the repo you want, then the <strong>Policies</strong> tab.</p>
</li>
<li><p>Scroll to the 'Branch Policies' section and click on the branch you want to protect (e.g., <code>main</code>).</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1762508622118/b2304126-a029-4560-b581-643be834f923.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>Find the <strong>"Automatically include reviewers"</strong> section and click the <code>+</code> button.</p>
</li>
</ol>
<p>(If you want to read about all the policy options, you can find the <a target="_blank" href="https://learn.microsoft.com/en-us/azure/devops/repos/git/branch-policies?view=azure-devops">official docs on branch policies here</a>.)</p>
<h2 id="heading-reviewer-policy"><strong>Reviewer policy</strong></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1762508660885/ed0aa005-facb-4881-b0ae-20464d34c68c.png" alt class="image--center mx-auto" /></p>
<ul>
<li><p><strong>Reviewers:</strong> Search for and select your <em>team's name</em> (e.g., <code>[MyProject]\Dev Team</code>). Do <strong>not</strong> add the individuals.</p>
</li>
<li><p><strong>Policy requirement:</strong> Set this to <strong>Required</strong>.</p>
</li>
<li><p><strong>Minimum number of reviewers:</strong> This option will now appear. Set it to <strong>1</strong>.</p>
</li>
</ul>
<p>Click <strong>Save</strong>.</p>
<hr />
<h3 id="heading-what-did-you-just-build">What Did You Just Build?</h3>
<p>From now on, every new PR to that branch will automatically add the <code>Dev Team</code> as a single, required block.</p>
<p>As soon as <em>one person</em> from that team approves it, the <em>entire team block</em> gets a green checkmark.</p>
<p>No more clicking on individual names. No more forgetting teammates. Your PR is unblocked, and you can get back to your flow. 😌</p>
<hr />
<p>What's your favorite 'set it and forget it' setting in Azure DevOps? What's one small policy tweak that has removed the most friction for your team? Share it in the comments!</p>
]]></content:encoded></item><item><title><![CDATA[Beyond Vibe Coding]]></title><description><![CDATA[I'm sure you're familiar with "vibe coding"—that creative process of building things based on a feeling, without a strict plan. It can be fun, but in a team environment, it simply doesn't work. It’s hard to scale, new people get lost, and the results...]]></description><link>https://hasnode.byrayray.dev/beyond-vibe-coding</link><guid isPermaLink="true">https://hasnode.byrayray.dev/beyond-vibe-coding</guid><category><![CDATA[vibe coding]]></category><category><![CDATA[AI]]></category><category><![CDATA[webdev]]></category><category><![CDATA[Programming Tips]]></category><category><![CDATA[tech leadership]]></category><dc:creator><![CDATA[Dev By RayRay]]></dc:creator><pubDate>Thu, 16 Oct 2025 12:47:42 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1760618950029/6320854f-9c1c-4820-b6dc-e72e6155abc6.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I'm sure you're familiar with "vibe coding"—that creative process of building things based on a feeling, without a strict plan. It can be fun, but in a team environment, it simply doesn't work. It’s hard to scale, new people get lost, and the results are often messy.</p>
<p>For me, things have changed. I now focus on working with clear specifications, and I use AI as my co-pilot. Many people think using AI means you lose control, but I've found the opposite is true. When used correctly, AI is a powerful partner that helps you apply your knowledge more effectively, giving you <em>more</em> control, not less.</p>
<p>Here are the six main ways I use AI as a tech lead.</p>
<hr />
<h3 id="heading-1-supercharging-my-git-workflow">1. Supercharging My Git Workflow</h3>
<p>I've used Git for a long time, so I'm comfortable with it. But being comfortable with a tool doesn't mean you're using it efficiently. This is where AI, especially GitHub Copilot, has made my daily Git work seamless.</p>
<p>Instead of typing every command by hand, I let AI handle the repetitive parts. It suggests sharp, accurate commit messages based on my changes, and most of the time they're perfect with just a few small tweaks. It can also create branch names for me based on the user story, which keeps everything consistent.</p>
<p>But the real game-changer is writing pull request descriptions. By connecting AI to our Azure DevOps board, it can generate a comprehensive summary of changes, including the rationale behind them, and automatically link to the corresponding user story. This frees me from tedious tasks so I can focus on what really matters: the quality of the code itself.</p>
<hr />
<h3 id="heading-2-the-ai-powered-second-pair-of-eyes-code-reviews">2. The AI-Powered Second Pair of Eyes: Code Reviews</h3>
<p>As a tech lead, I frequently conduct code reviews for multiple teams, which means I don't always have the full context. Previously, it took a lot of time to get up to speed. Now, AI is my starting point.</p>
<p>I can ask it to explain changes in a pull request, identify potential problems I might have missed, or verify that code adheres to our team's coding rules. As long as our rules are written down, AI can handle a large part of the review, and it does it much faster than I ever could.</p>
<p>This approach enables me to focus on the most critical aspects, such as the core logic and architecture. It also helps me give better, fairer feedback. For instance, I can ask AI to "explain why we use dependency injection here." That simple request turns a standard comment into a valuable teaching moment for the whole team.</p>
<hr />
<h3 id="heading-3-staying-in-the-zone-with-ai-and-azure-devops">3. Staying in the Zone with AI and Azure DevOps</h3>
<p>Connecting an AI assistant like GitHub Copilot to your project board—whether it's Azure DevOps, Jira, or GitLab—is a massive improvement for any developer's workflow. I can stay in my code editor—my focus zone—and still have a direct connection to our team's plan.</p>
<p>Through my editor, I can request additional information on a user story, seek help in understanding a new bug report, or even write and post comments for product owners. It effectively creates a bridge between the project plan and the actual coding work, ensuring that what I'm building is aligned with the team's goals and that everything is tracked properly.</p>
<hr />
<h3 id="heading-4-taming-the-cicd-beast">4. Taming the CI/CD Beast</h3>
<p>After years of building CI/CD pipelines in Azure DevOps, I’ve developed a solid understanding of how they work. But every so often, you run into a problem that’s hard to figure out.</p>
<blockquote>
<p>"I remember spending two hours debugging a pipeline once, only to find it was a single misplaced character. Last week, a similar issue came up, and by pasting the error into Copilot Chat, I found the fix in less than two minutes."</p>
</blockquote>
<p>My process for fixing these issues has completely changed. I just copy the strange error message from the pipeline, paste it into the chat with the AI, and since the AI can read my <code>*.yml</code> file, it often finds the problem right away. It’s this teamwork—my experience guiding the AI’s powerful pattern-matching—that helps me fix problems in a fraction of the time.</p>
<hr />
<h3 id="heading-5-my-go-to-brainstorming-partner">5. My Go-To Brainstorming Partner</h3>
<p>Honestly, brainstorming is the main way I've used AI from the very beginning. It feels like having a senior architect on call 24/7. I use it for all sorts of things:</p>
<ul>
<li><p><strong>Technical ideas:</strong> "How can we build a good reusable component?" or "What are the pros and cons of different ways to build a component library?"</p>
</li>
<li><p><strong>Improving code:</strong> "Why is this code so slow? Give me three ideas to make it faster."</p>
</li>
<li><p><strong>Team skills:</strong> "Can you help me write this PR comment so it sounds helpful, not like an attack?" or "How can I help my interns understand this topic better?"</p>
</li>
</ul>
<p>Regardless of your job, having an AI to help you think through ideas is incredibly useful. It consistently challenges my assumptions and pushes me to make better, more well-rounded decisions.</p>
<hr />
<h3 id="heading-6-why-specs-are-more-important-than-ever">6. Why Specs Are More Important Than Ever</h3>
<p>Using AI to build applications is powerful, but AI without clear specifications is a recipe for disaster. It’s like asking an intern to build a streaming platform in a few weeks. I often compare AI to an intern: you have to give it the right information at the right time. One single prompt is not going to create a perfect application.</p>
<p>The quality of the output you get from AI is a direct reflection of the quality of the input you provide. So, if managers think AI will replace developers, they first need to improve significantly at clearly defining their requirements.</p>
<p>For us developers, this is a good thing. By creating clear specifications that the team agrees on, we set the rules. We are still in control. We guide the AI to build what we planned, making sure the final product works well, is consistent, and meets the team's goals. Our jobs aren't disappearing; they're evolving.</p>
<hr />
<p>At the end of the day, "vibe coding" is a relic of the past because modern software demands planning, teamwork, and scalability. AI, when guided by our own knowledge, is the best way to be more productive while staying in control.</p>
<p>How are you using AI in your role as a developer or tech lead? I'd love to hear your favorite tips in the comments below! 👇</p>
]]></content:encoded></item><item><title><![CDATA[Let's Talk About Accessibility]]></title><description><![CDATA[Let's be honest. When you're a full-stack developer, juggling the front-end, back-end, database, and everything in between, "accessibility" can sometimes feel like just one more thing on an endless to-do list. I get it. You want to build great things...]]></description><link>https://hasnode.byrayray.dev/lets-talk-about-accessibility</link><guid isPermaLink="true">https://hasnode.byrayray.dev/lets-talk-about-accessibility</guid><category><![CDATA[Accessibility]]></category><category><![CDATA[programming]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[webdev]]></category><category><![CDATA[Developer]]></category><dc:creator><![CDATA[Dev By RayRay]]></dc:creator><pubDate>Wed, 15 Oct 2025 18:39:14 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1760553391729/b1742d9b-161a-4937-b584-1e96a9f87a49.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Let's be honest. When you're a full-stack developer, juggling the front-end, back-end, database, and everything in between, "accessibility" can sometimes feel like just one more thing on an endless to-do list. I get it. You want to build great things, but sometimes the finer details of accessibility guidelines can feel overwhelming, especially if you're not a front-end specialist.</p>
<p>For a long time, I treated accessibility as a "nice-to-have," something I'd get to <em>after</em> the core functionality was working. But I had a realization: what's the point of building something amazing if a significant portion of people can't even use it properly? Making the web accessible isn't just about ticking a box; it's about making our work usable for everyone. It’s about being inclusive.</p>
<p>The good news? It doesn't have to be a huge, complicated chore. I found a tool that has completely changed how I approach this, and I think it’ll do the same for you.</p>
<hr />
<h3 id="heading-meet-accenteddev-your-new-best-friend-for-accessibility">Meet Accented.dev: Your New Best Friend for Accessibility</h3>
<p>I recently discovered <a target="_blank" href="http://Accented.dev">Accented.dev</a>, a fantastic open-source tool that simplifies spotting accessibility issues. Seriously, it’s a game-changer. (You can also check it out on <a target="_blank" href="https://github.com/pomerantsev/accented">GitHub</a>!)</p>
<p>What I love about it is how seamless it is. Accented is a frontend library that runs directly in your browser while you're developing. It’s built on the <a target="_blank" href="https://github.com/dequelabs/axe-core"><strong>axe-core® engine</strong></a>, which is the gold standard for accessibility testing, so you know you're getting reliable feedback.</p>
<p>Here’s why I think you’ll love it:</p>
<ul>
<li><p><strong>See issues in real-time.</strong> As you code, Accented highlights any accessibility problems directly on the page. No more running a separate audit at the end of a sprint. You see a problem, you fix it. Done.</p>
</li>
<li><p><strong>It's super easy to set up.</strong> You can get it running with just a few lines of code. It doesn't matter if you're using React, Vue, Svelte, or even a legacy project with no framework. It just works.</p>
</li>
<li><p><strong>No more context switching.</strong> The issues are flagged visually on the page <em>and</em> in the console. You can see exactly which element has a problem without having to dig through code to find it.</p>
</li>
<li><p><strong>It’s completely free and open-source.</strong> Who doesn’t love that? ❤️</p>
</li>
</ul>
<hr />
<h3 id="heading-how-it-works-in-practice">How It Works in Practice</h3>
<p>Imagine you're building a new feature. You save your code, the page reloads, and little callouts appear next to a few elements. One might say an image is missing an <code>alt</code> tag, another might point out a button with low color contrast.</p>
<p>Instead of this being a problem you discover weeks later (or worse, never), you can fix it on the spot in a matter of seconds. It transforms accessibility from a complex audit into a seamless, ongoing part of your development workflow. It’s like having a friendly accessibility coach looking over your shoulder.</p>
<hr />
<h3 id="heading-give-it-a-try">Give It a Try!</h3>
<p>If you've ever felt that accessibility was too complex or time-consuming to focus on, I really encourage you to give <a target="_blank" href="http://Accented.dev">Accented.dev</a> a try. It’s one of those rare tools that is not only powerful but also a genuine pleasure to use. It has helped me become a more mindful and inclusive developer without adding any friction to my workflow.</p>
<p>What are your go-to tools for accessibility? Or have you had a similar experience? Share your thoughts in the comments below. Let’s make the web a better place for everyone, one line of code at a time! 🚀</p>
]]></content:encoded></item><item><title><![CDATA[AI or Obsolete: Why Developers Need AI in Their Workflow]]></title><description><![CDATA[Back in 2022, when I first heard the term "AI-powered developer", I pictured a robot typing code while I sat back. Today, that "robot" looks more like a VS Code extension, a CLI plugin, or even a teammate suggesting solutions right when I need them.
...]]></description><link>https://hasnode.byrayray.dev/ai-or-obsolete-why-developers-need-ai-in-their-workflow</link><guid isPermaLink="true">https://hasnode.byrayray.dev/ai-or-obsolete-why-developers-need-ai-in-their-workflow</guid><category><![CDATA[AI]]></category><category><![CDATA[github copilot]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[software development]]></category><category><![CDATA[programming]]></category><dc:creator><![CDATA[Dev By RayRay]]></dc:creator><pubDate>Thu, 21 Aug 2025 12:46:36 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1755780295068/981d091f-0924-4523-804a-ec8191865ac8.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Back in 2022, when I first heard the term "AI-powered developer", I pictured a robot typing code while I sat back. Today, that "robot" looks more like a VS Code extension, a CLI plugin, or even a teammate suggesting solutions right when I need them.</p>
<p>If you're still hesitant, I understand. I was curious and a bit uneasy as well. However, the data is clear: AI in development is no longer optional - it's a must-have. In this post, I'll share why, what happens if you wait too long, what research shows about the impact of tools like GitHub Copilot, and how you can get started with your team.</p>
<hr />
<h2 id="heading-1-where-we-are-today">1. Where We Are Today</h2>
<h3 id="heading-ai-is-already-part-of-daily-work">AI is already part of daily work</h3>
<p>Take a look around GitHub, your IDE marketplace, or even Stack Overflow—AI is everywhere. Tools like <strong>GitHub Copilot</strong>, <strong>Tabnine</strong>, and <strong>Cursor</strong> are no longer experiments; they’re part of how developers actually work.</p>
<p>They’re helping with:</p>
<ul>
<li><p>Generating boilerplate code in seconds (Vue components, Pinia stores, composables).</p>
</li>
<li><p>Suggesting meaningful refactors for readability and performance.</p>
</li>
<li><p>Writing unit tests for your components.</p>
</li>
<li><p>Converting code between frameworks (Vue ↔ React) or JavaScript → TypeScript.</p>
</li>
</ul>
<p>And it’s not just developers: managers are already using AI to spot bottlenecks, flag risky PRs, and track velocity more effectively.</p>
<h3 id="heading-what-this-means-for-us">What this means for us</h3>
<p>This isn’t just hype. Studies confirm the benefits:</p>
<ul>
<li><p><strong>Faster coding</strong> – GitHub found developers completed tasks <strong>55% faster</strong> with Copilot compared to those without it.</p>
</li>
<li><p><strong>Higher satisfaction</strong> – In surveys, 60–75% of developers said Copilot made them feel more fulfilled and less frustrated.</p>
</li>
<li><p><strong>Better focus</strong> – 73% said Copilot kept them “in the flow,” and 87% said it reduced the mental energy spent on repetitive work.</p>
</li>
<li><p><strong>Quality maintained</strong> – Enterprise studies even showed higher PR merge rates and more successful builds with Copilot in the mix.</p>
</li>
</ul>
<p>So, AI is already becoming a <strong>productivity layer</strong> on top of our existing workflows.</p>
<hr />
<h2 id="heading-2-the-cost-of-waiting">2. The Cost of Waiting</h2>
<h3 id="heading-weve-managed-fine-without-it">“We’ve managed fine without it.”</h3>
<p>This is the line I hear most from experienced developers. But waiting has risks:</p>
<p><img src="https://cdn-images-1.medium.com/v2/resize:fit:1600/1*atavztvgcJR2_pif1LupMw.png" alt /></p>
<p>The truth is, teams that delay AI adoption risk being outpaced by those who embrace it. The data shows that adoption is quick once teams start: <strong>81% of developers enable Copilot on the day they get access</strong> , and <strong>96% accept suggestions immediately</strong>.</p>
<hr />
<h2 id="heading-3-what-the-data-tells-us">3. What the Data Tells Us</h2>
<p>Instead of telling stories, let’s look at the real numbers:</p>
<ul>
<li><p><a target="_blank" href="https://github.blog/news-insights/research/research-quantifying-github-copilots-impact-on-developer-productivity-and-happiness/"><strong>55% faster</strong></a><strong>:</strong> In GitHub’s study, developers using Copilot finished coding tasks more than twice as quickly.</p>
</li>
<li><p><a target="_blank" href="https://resources.github.com/learn/pathways/copilot/essentials/measuring-the-impact-of-github-copilot/"><strong>Better throughput</strong></a><strong>:</strong> In an enterprise rollout, pull requests per developer increased by <strong>8.7%</strong>, and merge rates were <strong>15% higher</strong> with Copilot.</p>
</li>
<li><p><strong>Quality intact:</strong> <a target="_blank" href="https://github.blog/news-insights/research/research-quantifying-github-copilots-impact-in-the-enterprise-with-accenture/#:~:text=But%20we%20don%E2%80%99t%20want%20to,human%20reviewers%20and%20test%20automation">Teams saw <strong>84% more successful CI builds</strong></a>, meaning fewer regressions slipping through.</p>
</li>
<li><p><a target="_blank" href="https://github.blog/news-insights/research/research-quantifying-github-copilots-impact-on-developer-productivity-and-happiness/"><strong>Happier developers</strong></a><strong>:</strong> 90% of engineers reported feeling more fulfilled, and 95% said they enjoyed coding more with Copilot.</p>
</li>
<li><p><a target="_blank" href="https://github.blog/news-insights/research/research-quantifying-github-copilots-impact-in-the-enterprise-with-accenture/#:~:text=We%20also%20observed%20that%20developers,provide%20a%20barrier%20to%20entry"><strong>Widespread adoption</strong></a><strong>:</strong> 40% of developers worldwide have tried Copilot, and 26% use it regularly, according to JetBrains’ 2024 survey.</p>
</li>
</ul>
<p>These numbers paint a clear picture: Copilot isn’t just saving time—it’s improving quality and making work more enjoyable.</p>
<hr />
<h2 id="heading-4-how-to-get-started-with-your-team">4. How to Get Started with Your Team</h2>
<p>Here’s how you can introduce AI coding tools like Copilot without chaos:</p>
<p>1️⃣ <strong>Start small</strong> – Pick one tool (e.g., Copilot) and try it on a specific workflow, like scaffolding new Vue components or setting up composables.<br />2️⃣ <strong>Set expectations</strong> – AI is a co-pilot, not the pilot. Always review and test.<br />3️⃣ <strong>Train the team</strong> – Run a short demo, share effective prompts, and talk about pitfalls.<br />4️⃣ <strong>Standardize usage</strong> – Don’t let everyone reinvent the wheel. I built a <a target="_blank" href="https://github.com/devbyray/github-copilot-starter"><strong>GitHub Copilot Starter</strong></a> project for exactly this reason. It’s a template repository with ready-to-go instructions for coding standards, commit message conventions, accessibility guidelines, testing practices, project structure, and more. By cloning it, your team can maintain consistent and aligned Copilot usage with your standards.<br />5️⃣ <strong>Measure impact</strong> – Track PR cycle times, test coverage, and run short surveys. GitHub even offers APIs to measure Copilot usage across teams.<br />6️⃣ <strong>Scale gradually</strong> – If the pilot is positive, expand. GitHub’s studies show that it can take up to ~11 weeks for full benefits to be effective, so give it time.</p>
<hr />
<h2 id="heading-5-whats-next-for-ai-in-development">5. What’s Next for AI in Development</h2>
<p>AI is evolving from an “assistant” to a <strong>collaborator</strong>. We’ll soon see:</p>
<ul>
<li><p>AI-generated architecture diagrams from codebases.</p>
</li>
<li><p>Automated migrations between frameworks.</p>
</li>
<li><p>Assistants that adapt to your team’s coding style and domain knowledge.</p>
</li>
</ul>
<p>The best way to prepare is to keep experimenting, join developer communities, and invest in upskilling. Prompting is quickly becoming as essential as Git.</p>
<hr />
<h2 id="heading-wrapping-up">Wrapping Up</h2>
<p>The first time I let AI generate a Vue composable for me, I was skeptical—but it worked perfectly, even with a clear comment on how to reuse it. That’s when it clicked: <strong>the tools we use shape the work we do</strong>.</p>
<p>Here’s my challenge: on your next ticket, let AI assist you. Try Copilot, ask it to generate a Vue component with TypeScript support, and see how it feels.</p>
<p>Let’s turn curiosity into skills. 🚀</p>
]]></content:encoded></item><item><title><![CDATA[How to Use Azure DevOps MCP Server with GitHub Copilot in VS Code: Complete Setup Guide]]></title><description><![CDATA[Ever find yourself juggling VS Code and Azure DevOps browser tabs all day? I know the feeling—every time I switch contexts, I lose my flow. 😩 But guess what: Microsoft just dropped an official Model Context Protocol (MCP) server that plugs Azure Dev...]]></description><link>https://hasnode.byrayray.dev/how-to-use-azure-devops-mcp-server-with-github-copilot-in-vs-code-complete-setup-guide</link><guid isPermaLink="true">https://hasnode.byrayray.dev/how-to-use-azure-devops-mcp-server-with-github-copilot-in-vs-code-complete-setup-guide</guid><category><![CDATA[Azure]]></category><category><![CDATA[azure-devops]]></category><category><![CDATA[mcp]]></category><category><![CDATA[AI]]></category><category><![CDATA[github copilot]]></category><category><![CDATA[Visual Studio Code]]></category><dc:creator><![CDATA[Dev By RayRay]]></dc:creator><pubDate>Tue, 17 Jun 2025 19:29:21 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1750186311387/653bd5b7-b769-4da3-b051-24a305d2a624.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Ever find yourself juggling VS Code and Azure DevOps browser tabs all day? I know the feeling—every time I switch contexts, I lose my flow. 😩 But guess what: Microsoft just dropped an official Model Context Protocol (MCP) server that plugs Azure DevOps right into GitHub Copilot. Game‑changer, right? 🎉</p>
<p>In this post, I’ll show you how to set up and use the Azure DevOps MCP server with GitHub Copilot in VS Code. You’ll be able to see work items, update tasks, query project info, and more—all without leaving your editor. Let’s dive in!</p>
<h2 id="heading-what-youll-need-prerequisites">What You'll Need (Prerequisites)</h2>
<p>Before we dive in, make sure you have:</p>
<ul>
<li><p>VS Code or VS Code Insiders installed</p>
</li>
<li><p>GitHub Copilot extension is active</p>
</li>
<li><p>Node.js 20 or higher</p>
</li>
<li><p>An Azure DevOps account with appropriate permissions</p>
</li>
<li><p>Azure CLI installed</p>
</li>
</ul>
<h2 id="heading-step-1-authenticate-with-azure">Step 1: Authenticate with Azure</h2>
<p>First, you need to authenticate with Azure DevOps through the Azure CLI (If not installed, <a target="_blank" href="https://learn.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest">follow the docs</a>):</p>
<pre><code class="lang-bash">az login
</code></pre>
<p>This will open your browser and prompt you to sign in to your Azure account. Ensure you use the same account with access to your Azure DevOps organization.</p>
<h2 id="heading-step-2-create-the-mcp-configuration">Step 2: Create the MCP Configuration</h2>
<p>In your project root directory, create a <code>.vscode/mcp.json</code> file with the following configuration:</p>
<pre><code class="lang-json">{
  <span class="hljs-attr">"inputs"</span>: [
    {
      <span class="hljs-attr">"id"</span>: <span class="hljs-string">"ado_org"</span>,
      <span class="hljs-attr">"type"</span>: <span class="hljs-string">"promptString"</span>, 
      <span class="hljs-attr">"description"</span>: <span class="hljs-string">"Azure DevOps organization name (e.g. 'contoso')"</span>
    }
  ],
  <span class="hljs-attr">"servers"</span>: {
    <span class="hljs-attr">"ado"</span>: {
      <span class="hljs-attr">"type"</span>: <span class="hljs-string">"stdio"</span>,
      <span class="hljs-attr">"command"</span>: <span class="hljs-string">"npx"</span>,
      <span class="hljs-attr">"args"</span>: [
        <span class="hljs-string">"-y"</span>,
        <span class="hljs-string">"@azure-devops/mcp"</span>,
        <span class="hljs-string">"${input:ado_org}"</span>
      ]
    }
  }
}
</code></pre>
<p>This configuration tells VS Code how to connect to the Azure DevOps MCP server using your organization name.</p>
<h2 id="heading-step-3-start-the-mcp-server">Step 3: Start the MCP Server</h2>
<ol>
<li><p>Save the <code>mcp.json</code> configuration file</p>
</li>
<li><p>Open the Command Palette in VS Code (<code>Ctrl+Shift+P</code> or <code>Cmd+Shift+P</code>)</p>
</li>
<li><p>Run the MCP server startup command</p>
</li>
<li><p>When prompted, enter your Azure DevOps organization name (just the name, not the full URL)</p>
</li>
</ol>
<h2 id="heading-step-4-enable-github-copilot-agent-mode">Step 4: Enable GitHub Copilot Agent Mode</h2>
<ol>
<li><p>Open GitHub Copilot in VS Code</p>
</li>
<li><p>Switch to Agent Mode</p>
</li>
<li><p>Look for Azure DevOps tools in the available tools list</p>
</li>
<li><p>Select the Azure DevOps MCP server tools</p>
</li>
</ol>
<p>That's it! You're now ready to interact with Azure DevOps directly through GitHub Copilot.</p>
<h2 id="heading-how-to-use-azure-devops-mcp-with-github-copilot">How to Use Azure DevOps MCP with GitHub Copilot</h2>
<h3 id="heading-managing-work-items">Managing Work Items</h3>
<p><strong>View your assigned work items:</strong></p>
<p>This will give you a list of all the assigned work items with your name.</p>
<pre><code class="lang-plaintext">Show me my assigned work items in Azure DevOps
</code></pre>
<p>But you can make it more advanced or specific:</p>
<pre><code class="lang-plaintext">Show me my assigned work items in Azure DevOps with the title's based on priority
</code></pre>
<p><strong>Create new work items:</strong></p>
<p>Adding new work items has never been easier! Just use a prompt like this, and it will create it for you.</p>
<pre><code class="lang-plaintext">Create a new user story titled "Implement user authentication" with description "As a user, I want to log in securely so that I can access my account"
</code></pre>
<p>Or if you want to create a task that belongs to a work item:</p>
<pre><code class="lang-plaintext">Create a set of tasks for work item 875342.
- Implement new auth method
- Update exisiting unit tests
- Create new unit tests
</code></pre>
<p><strong>Update work item status:</strong></p>
<p>Updating existing is also very handy! This saves us so much context switching!</p>
<pre><code class="lang-plaintext">Update work item 12345 to "In Progress" and add a comment that I've started working on it
</code></pre>
<h3 id="heading-project-and-repository-operations">Project and Repository Operations</h3>
<p><strong>List your projects:</strong></p>
<p>If you have multiple projects you work on, you can list them easily.</p>
<pre><code class="lang-plaintext">List my Azure DevOps projects and show me the teams for my main project
</code></pre>
<p><strong>Repository information:</strong></p>
<pre><code class="lang-plaintext">Show me the repositories in this project and list the recent branches
</code></pre>
<p><strong>Pull request management:</strong></p>
<p>You are not just tied to one thing per prompt. Just combine multiple requests to do it.</p>
<pre><code class="lang-plaintext">I just created a PR for my authentication feature. Update work item 12345 to reference this PR and change the status to Code Review
</code></pre>
<h3 id="heading-build-and-test-management">Build and Test Management</h3>
<p><strong>Check build status:</strong></p>
<pre><code class="lang-plaintext">Show me the status of recent builds for this project
</code></pre>
<p><strong>Test plan information:</strong></p>
<pre><code class="lang-plaintext">List test plans for this project and show me recent test results
</code></pre>
<hr />
<h2 id="heading-why-azure-devops-mcp-in-github-copilot-is-so-powerful">Why Azure DevOps MCP in GitHub Copilot is So Powerful</h2>
<h3 id="heading-1-no-more-context-switching">1. No More Context Switching 💪</h3>
<p>The biggest productivity killer in development is context switching. Research shows it takes an average of 23 minutes to fully refocus after an interruption. With Azure DevOps MCP, you can:</p>
<ul>
<li><p>Check work item details without opening a browser</p>
</li>
<li><p>Update task status while reviewing code</p>
</li>
<li><p>Create follow-up tasks immediately after solving bugs</p>
</li>
<li><p>Query project information within your coding context</p>
</li>
</ul>
<h3 id="heading-2-natural-conversation-with-your-project-data">2. Natural Conversation with Your Project Data 💬</h3>
<p>Instead of clicking through Azure DevOps UI menus, you can have natural conversations:</p>
<pre><code class="lang-plaintext">Show me work items in the current iteration for the Development Team, then create a new task for implementing API authentication
</code></pre>
<p>This conversational approach makes project management feel less like administrative overhead and more like a natural part of development.</p>
<h3 id="heading-3-intelligent-task-updates-after-development">3. Intelligent Task Updates After Development 🤖</h3>
<p>After you create a pull request, you can immediately:</p>
<ul>
<li><p>Link the PR to the relevant work item</p>
</li>
<li><p>Update the work item status to "Code Review"</p>
</li>
<li><p>Add implementation details as comments</p>
</li>
<li><p>Create follow-up tasks for testing or documentation</p>
</li>
</ul>
<p>All without leaving VS Code.</p>
<h3 id="heading-4-rich-context-understanding">4. Rich Context Understanding 🧠</h3>
<p>GitHub Copilot with MCP access understands the relationship between your code and Azure DevOps work items. It can:</p>
<ul>
<li><p>Help create better commit messages based on work item descriptions</p>
</li>
<li><p>Suggest relevant test cases from the user story acceptance criteria</p>
</li>
<li><p>Help decompose large user stories into smaller, manageable tasks</p>
</li>
<li><p>Provide context about requirements when you're coding</p>
</li>
</ul>
<hr />
<h2 id="heading-real-world-example-complete-development-workflow">Real-World Example: Complete Development Workflow</h2>
<p>Here's how a typical development session looks like that I have with Azure DevOps MCP:</p>
<ol>
<li><p><strong>Start the day:</strong></p>
<pre><code class="lang-plaintext"> Show me my assigned work items for this sprint
</code></pre>
</li>
<li><p><strong>Begin working on a task:</strong></p>
<pre><code class="lang-plaintext"> Update work item 12345 to "In Progress" and add a comment that I'm starting the implementation
</code></pre>
</li>
<li><p><strong>Need clarification on requirements:</strong></p>
<pre><code class="lang-plaintext"> Show me the full description and acceptance criteria for work item 12345
</code></pre>
</li>
<li><p><strong>After creating a PR:</strong></p>
<pre><code class="lang-plaintext"> Update work item 12345 to reference PR #67 and change status to "Code Review"
</code></pre>
</li>
<li><p><strong>Create follow-up tasks:</strong></p>
<pre><code class="lang-plaintext"> Create a new task for writing documentation for the authentication feature, link it to user story 12345
</code></pre>
</li>
</ol>
<p>All of this happens without ever opening a browser tab or losing focus from your code.</p>
<hr />
<h2 id="heading-troubleshooting-common-issues">Troubleshooting Common Issues</h2>
<p><strong>MCP Server Not Starting:</strong></p>
<ul>
<li><p>Ensure you're authenticated with Azure CLI (<code>az login</code>)</p>
</li>
<li><p>Check that your Azure DevOps organization name is correct</p>
</li>
<li><p>Verify Node.js 20+ is installed</p>
</li>
</ul>
<p><strong>Permission Issues:</strong></p>
<ul>
<li><p>Make sure your Azure account has appropriate permissions in Azure DevOps</p>
</li>
<li><p>Check that you're a member of the project you're trying to access</p>
</li>
<li><p>If it says you don’t have sufficient authorization, but you know you have. Visit Azure DevOps in the browser, sometimes this will fix it for me.</p>
</li>
</ul>
<p><strong>Connection Problems:</strong></p>
<ul>
<li><p>Restart VS Code after configuration changes</p>
</li>
<li><p>Verify the MCP configuration file syntax is correct</p>
</li>
<li><p>Check your internet connection and Azure DevOps service status</p>
</li>
</ul>
<hr />
<h2 id="heading-the-future-of-ai-powered-development">The Future of AI-Powered Development</h2>
<p>This Azure DevOps MCP integration represents a fundamental shift in interacting with development tools. We're moving away from tool-hopping toward a unified experience where natural language becomes the interface to our entire development ecosystem.</p>
<p>The Model Context Protocol (MCP) is the key enabler here - it's like USB-C for AI integrations. Once a service has an MCP server, any MCP-compatible AI agent can use it without custom development work.</p>
<hr />
<h2 id="heading-get-started-today">Get Started Today</h2>
<p>The Azure DevOps MCP server is open source and available on GitHub at: <a target="_blank" href="https://github.com/microsoft/azure-devops-mcp">https://github.com/microsoft/azure-devops-mcp</a></p>
<p>Setting up takes less than 10 minutes, but the productivity gains compound over time. You'll spend less time navigating tools and more time solving actual problems.</p>
<hr />
<h2 id="heading-whats-your-experience">What's Your Experience?</h2>
<p>Have you tried integrating MCP servers into your development workflow? What other tools would you love to see with MCP support?</p>
<p>I'd love to hear about your experience! Connect with me on <a target="_blank" href="https://x.com/devbyrayray">X/Twitter</a> or <a target="_blank" href="https://linkedin.com/raym0ns">LinkedIn</a> and let's discuss how AI is transforming our development workflows.</p>
]]></content:encoded></item><item><title><![CDATA[Vibe Coding: Is This the Future of Software Development?]]></title><description><![CDATA[The world of software development is constantly evolving, and the latest buzz? Vibe coding. It’s an AI-driven approach that’s shaking up how we write code, making it faster, more intuitive, and more fun (not always, hahaha). But is it all hype, or is...]]></description><link>https://hasnode.byrayray.dev/vibe-coding-is-this-the-future-of-software-development</link><guid isPermaLink="true">https://hasnode.byrayray.dev/vibe-coding-is-this-the-future-of-software-development</guid><category><![CDATA[AI]]></category><category><![CDATA[#ai-tools]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[Programming Tips]]></category><category><![CDATA[programming]]></category><dc:creator><![CDATA[Dev By RayRay]]></dc:creator><pubDate>Wed, 26 Mar 2025 10:42:36 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1742984934304/dac56b23-d252-4e7d-9044-c7beaa18a0c3.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The world of software development is constantly evolving, and the latest buzz? <strong>Vibe coding.</strong> It’s an AI-driven approach that’s shaking up how we write code, making it faster, more intuitive, and more fun (<em>not always, hahaha</em>). But is it all hype, or is there something useful here? Let’s dive in and see what vibe coding is about and whether it’s worth your attention.</p>
<hr />
<h2 id="heading-so-whats-vibe-coding">So, What’s Vibe Coding?</h2>
<p>Vibe coding flips the script on traditional development. Instead of painstakingly writing out every line of code, you describe what you want in plain language, and a large language model (LLM) generates the code for you. The concept gained traction after <a target="_blank" href="https://x.com/karpathy/status/1886192184808149383?ref_src=twsrc%5Etfw%7Ctwcamp%5Etweetembed%7Ctwterm%5E1886192184808149383%7Ctwgr%5E6e0a430b6f2bc487c20cb65eaf4d722426b48cf5%7Ctwcon%5Es1_&amp;ref_url=https%3A%2F%2Ftimesofindia.indiatimes.com%2Ftechnology%2Ftech-news%2Fwhat-is-vibe-coding-former-tesla-ai-director-andrej-karpathy-defines-a-new-era-in-ai-driven-development%2Farticleshow%2F118659724.cms">Andrej Karpathy introduced it earlier this year</a>, and it’s been making waves ever since.</p>
<p>Think of it as having an AI-powered coding buddy that turns your ideas into working code. It’s all about making development more conversational, reducing tedious work, and letting developers focus on solving more significant problems instead of getting stuck in syntax details.</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://x.com/karpathy/status/1886192184808149383">https://x.com/karpathy/status/1886192184808149383</a></div>
<p> </p>
<hr />
<h2 id="heading-why-its-a-big-deal">Why It’s a Big Deal</h2>
<p>Vibe coding has the potential to open doors for more people to build software. You no longer need deep technical expertise to get started—if you can describe what you want, you can generate working code. That’s a game-changer for beginners and non-developers who want to bring their ideas to life.</p>
<p>For experienced developers, vibe coding can boost productivity by handling the repetitive, boilerplate-heavy coding parts. Need a quick API call setup? A function to process data? Just describe it, and let AI do the rest. It’s also great for rapid prototyping—perfect for hackathons, proof-of-concept projects, or testing new ideas without sinking hours into setup.</p>
<hr />
<h2 id="heading-the-catch-its-not-magic">The Catch: It’s Not Magic</h2>
<p>Before we get too carried away, let’s be honest—vibe coding isn’t flawless. AI-generated code isn’t always clean, efficient, or even correct. Bugs can creep in, requiring careful debugging and validation.</p>
<p>Then there’s the issue of understanding. You could have a maintenance nightmare if you rely too much on AI-generated code without understanding its workings. That’s a risk in professional settings where clean, maintainable code is key.</p>
<p>Security is another concern. AI can generate code with vulnerabilities, especially when handling sensitive data or external dependencies. If you don’t review it properly, you could introduce security risks without realizing it.</p>
<p><img src="https://byrayray.dev/images/fafc6893-781a-43f1-9e40-4b29b2eb4092.png" alt /></p>
<p><a target="_blank" href="https://www.linkedin.com/posts/mihaivalentin_state-of-writing-code-with-ai-march-2025-activity-7307670836486856705-jXFX/?utm_source=share&amp;utm_medium=member_desktop&amp;rcm=ACoAAAORaU0BYKL5LPqa2TeQfSY4JoawyqbrFX8"><em>LinkedIn post where they posted this picture</em></a><em>.</em></p>
<hr />
<h2 id="heading-how-to-vibe-code-the-right-way">How to Vibe Code the Right Way</h2>
<p>To make the most of vibe coding, use it responsibly:</p>
<ul>
<li><p><strong>Always review AI-generated code.</strong> Don’t trust it blindly—debug and refine as needed.</p>
</li>
<li><p><strong>Start with non-critical projects.</strong> Experiment before integrating it into production-level systems.</p>
</li>
<li><p><strong>Use it as a learning tool.</strong> Understanding how AI interprets prompts can improve your own coding intuition.</p>
</li>
</ul>
<p>On the SyntaxFM podcast, they also talked about Vibe Coding, and I agree with their opinion. Check the video here:</p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/2b_KlROMfp8?si=MKz0od7wrKuiyO9i"></iframe>

<hr />
<h2 id="heading-final-thoughts">Final Thoughts</h2>
<p>Vibe coding is more than a fleeting trend—it’s a glimpse into the future of software development. It makes coding more accessible, speeds up workflows, and enhances creativity. But it’s not a replacement for traditional coding skills. Instead, it’s a tool that, when used wisely, can make development more efficient and enjoyable.</p>
<p>So, are you ready to ride the vibe coding wave? Give it a shot and see where it takes you! 🚀</p>
<p><em>Happy coding!</em> 💻</p>
]]></content:encoded></item><item><title><![CDATA[Save Hours By Giving GitHub Copilot Custom Instructions for Code and Commit Generation 💡🤖]]></title><description><![CDATA[I’ve always believed that writing great code isn’t just about getting things to work — creating a story in every line and commit.
I was recently diving into the documentation of GitHub Copilot, and I was thrilled to discover that you can teach it usi...]]></description><link>https://hasnode.byrayray.dev/save-hours-by-giving-github-copilot-custom-instructions-for-code-and-commit-generation</link><guid isPermaLink="true">https://hasnode.byrayray.dev/save-hours-by-giving-github-copilot-custom-instructions-for-code-and-commit-generation</guid><category><![CDATA[GitHub]]></category><category><![CDATA[github copilot]]></category><category><![CDATA[AI]]></category><category><![CDATA[Programming Tips]]></category><category><![CDATA[Developer]]></category><dc:creator><![CDATA[Dev By RayRay]]></dc:creator><pubDate>Thu, 13 Mar 2025 07:58:15 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1741852191979/3adc9378-79ea-4052-af01-4b9d6b76b171.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<hr />
<p>I’ve always believed that writing great code isn’t just about getting things to work — creating a story in every line and commit.</p>
<p>I was recently diving into the documentation of GitHub Copilot, and I was thrilled to discover that you can teach it using your coding and commit message style.</p>
<p>In this post, I will show you how I set up custom instructions so that Github Copilot generates code similar to my coding style and writes commit messages that speak in our team’s language. Trust me, once you get this working, you’ll never look at your Git history the same way again!</p>
<hr />
<h3 id="heading-what-are-custom-instructions">What are custom instructions?</h3>
<p>Custom instructions are like giving Github Copilot a guide detailing your coding preferences and committing message rules. Imagine having a teammate who already knows your quirks — whether you love using double quotes in JavaScript or insist on using conventional commit messages. </p>
<p>With custom instructions, whenever you ask Github Copilot for help, it automatically writes in your style and follows your guidelines. It’s not just about saving time; it’s about ensuring consistency throughout your project.</p>
<hr />
<h3 id="heading-1-create-the-settings-file">1. Create the settings file</h3>
<p>First, create a folder (if it’s not already there yet) <code>.vscode</code> and create a <code>settings.json</code> file in it.</p>
<p><img src="https://cdn-images-1.medium.com/max/1000/1*ToyZ4AJlZTfrXPZCIGHNTw.png" alt class="image--center mx-auto" /></p>
<hr />
<h3 id="heading-2-setup-custom-instructions-for-code-generation">2. Setup custom instructions for code generation</h3>
<p>Then, I create a file called <code>code-style.md</code> in the a <code>docs</code> folder in my repository. In that file, I outline my coding style for languages like JavaScript, CSS, and Vue.js.</p>
<pre><code class="lang-markdown"><span class="hljs-section"># Code Style Guide</span>

<span class="hljs-section">## General Guidelines</span>
<span class="hljs-bullet">-</span> Keep the code simple and readable.
<span class="hljs-bullet">-</span> Use Prettier for code formatting.

<span class="hljs-section">## CSS</span>
<span class="hljs-bullet">-</span> Use class names that are descriptive and follow a consistent naming convention.
<span class="hljs-bullet">-</span> Avoid using IDs for styling.
<span class="hljs-bullet">-</span> Organize CSS properties in a logical order.

<span class="hljs-section">## Tailwind CSS</span>
<span class="hljs-bullet">-</span> Use utility-first classes to build components.
<span class="hljs-bullet">-</span> Avoid using custom CSS when possible.
<span class="hljs-bullet">-</span> Group related classes together for better readability.

<span class="hljs-section">## JavaScript</span>
<span class="hljs-bullet">-</span> Use <span class="hljs-code">`const`</span> and <span class="hljs-code">`let`</span> instead of <span class="hljs-code">`var`</span>.
<span class="hljs-bullet">-</span> Prefer arrow functions for anonymous functions.
<span class="hljs-bullet">-</span> Use template literals for string concatenation.
<span class="hljs-bullet">-</span> Always use semicolons.
<span class="hljs-bullet">-</span> Follow the Prettier configuration for formatting.

<span class="hljs-section">## Vue.js</span>
<span class="hljs-bullet">-</span> Use single-file components (SFCs) with the <span class="hljs-code">`.vue`</span> extension.
<span class="hljs-bullet">-</span> Organize component structure in this order: <span class="hljs-code">`&lt;script&gt;`</span> then <span class="hljs-code">`&lt;template&gt;`</span> and lastly <span class="hljs-code">`&lt;style&gt;`</span>.
<span class="hljs-bullet">-</span> Use PascalCase for component names.
<span class="hljs-bullet">-</span> Use kebab-case for component file names.
<span class="hljs-bullet">-</span> Keep components small and focused.
<span class="hljs-bullet">-</span> Use Vuex for state management.
</code></pre>
<p>With these guidelines, Github Copilot generates code that seamlessly fits into my projects without needing constant tweaks.</p>
<hr />
<h3 id="heading-3-custom-instructions-for-commit-message-generation">3. Custom instructions for commit message generation</h3>
<p>A clear, consistent commit message can be a lifesaver when understanding your codebase’s evolution. I create a <code>commit-style.md</code> file in the <code>docs</code> folder. Here's a peek at my commit style guide:</p>
<pre><code class="lang-markdown"><span class="hljs-section">## Commit Style Guide</span>
We follow the [<span class="hljs-string">Conventional Commits</span>](<span class="hljs-link">https://www.conventionalcommits.org/en/v1.0.0/</span>) style for our commit messages. Here are some examples:

<span class="hljs-bullet">-</span> <span class="hljs-code">`feat: add new user authentication module`</span>
<span class="hljs-bullet">-</span> <span class="hljs-code">`fix: resolve issue with data fetching.`</span>
<span class="hljs-bullet">-</span> <span class="hljs-code">`docs: update README with installation instructions`</span>
<span class="hljs-bullet">-</span> <span class="hljs-code">`style: format code with Prettier`</span>
<span class="hljs-bullet">-</span> <span class="hljs-code">`refactor: improve performance of data processing`</span>
<span class="hljs-bullet">-</span> <span class="hljs-code">`test: add unit tests for user service`</span>
<span class="hljs-bullet">-</span> <span class="hljs-code">`chore: update dependencies`</span>
</code></pre>
<p>This way, when I click the “Generate Commit Message” button, GitHub Copilot produces a message summarizing the changes using our style. This will keep our Git history clean and readable.</p>
<p><img src="https://cdn-images-1.medium.com/max/1000/1*HpTTgyt9QmxdopXRDYcdhA.png" alt class="image--center mx-auto" /></p>
<hr />
<h3 id="heading-4-reference-the-docs-in-the-settings-file">4. Reference the docs in the settings file</h3>
<p>To tie it all together, I add the path of the markdown files in the <code>settings.json</code>. Here is my configuration:</p>
<pre><code class="lang-json">{
    <span class="hljs-attr">"github.copilot.chat.codeGeneration.instructions"</span>: [
        {
            <span class="hljs-attr">"file"</span>: <span class="hljs-string">"docs/code-style.md"</span><span class="hljs-comment">// import instructions from file `code-style.md`</span>
        }
    ],
    <span class="hljs-attr">"github.copilot.chat.commitMessageGeneration.instructions "</span>: [
        {
            <span class="hljs-attr">"file"</span>: <span class="hljs-string">"docs/commit-message.md"</span><span class="hljs-comment">// import instructions from file `commit-message.md`</span>
        }
    ]
}
</code></pre>
<p>With this setup, my code and commit messages automatically align with my standards. This simple change makes a huge difference in maintaining consistency throughout my projects.</p>
<hr />
<h3 id="heading-best-practices-and-personal-tips">Best Practices and Personal Tips</h3>
<p>Over time, I’ve learned that the key to getting the most out of custom instructions is to keep them simple and iterative. Start with the basics, then refine as you notice what works and what doesn’t. </p>
<p>By placing your custom instruction files in your repository, you ensure that everyone on your team is on the same page and speaking the same coding language.</p>
<p>I recorded a quick video that shows precisely what I describe in this blog—check it out below. </p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://www.youtube.com/watch?v=NrSjVO74Lm8">https://www.youtube.com/watch?v=NrSjVO74Lm8</a></div>
<p> </p>
<hr />
<h3 id="heading-conclusion">Conclusion</h3>
<p>Custom instructions for GitHub Copilot have sped up my workflow. They allow me to write cleaner code and generate commit messages that communicate the story behind my changes. </p>
<p>You can find the <a target="_blank" href="https://code.visualstudio.com/docs/copilot/copilot-customization">Github Copilot custom instructions documentation</a> in the Visual Studio Code docs.</p>
<p>If you haven’t explored this feature yet, I encourage you to do so. You might be surprised at how much time you can save and how consistent your project can become. I’d love to hear about your experiences with custom instructions.</p>
<p>Comment below, share your custom rules or give this post a thumbs up if you find it helpful. Let’s make coding a little more personal and a lot more productive! </p>
<p>Happy coding — and committing!</p>
]]></content:encoded></item><item><title><![CDATA[From Hating Public Speaking to DevWorld Amsterdam 2025 (It Took Me 20 Years)]]></title><description><![CDATA[Twenty years ago, speaking in front of a crowd terrified me. I would rather fail skip a class than stand in front of an audience. Fast forward to 2025, and I was on the DevWorld stage in Amsterdam: calm and confident.
This isn’t a story about flawles...]]></description><link>https://hasnode.byrayray.dev/from-hating-public-speaking-to-devworld-amsterdam-2025-it-took-me-20-years</link><guid isPermaLink="true">https://hasnode.byrayray.dev/from-hating-public-speaking-to-devworld-amsterdam-2025-it-took-me-20-years</guid><category><![CDATA[conference]]></category><category><![CDATA[Developer]]></category><category><![CDATA[programming]]></category><category><![CDATA[AI]]></category><dc:creator><![CDATA[Dev By RayRay]]></dc:creator><pubDate>Tue, 04 Mar 2025 09:58:11 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1741082093773/7ec9364a-7741-44b6-b4ec-77368acc32f6.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Twenty years ago, speaking in front of a crowd terrified me. I would rather fail skip a class than stand in front of an audience. Fast forward to 2025, and I was on the <a target="_blank" href="https://devworldconference.com/">DevWorld stage in Amsterdam</a>: calm and confident.</p>
<p>This isn’t a story about flawless rehearsals or perfectly scripted talks — it’s a honest journey filled with mishaps, genuine learning, and unexpected moments of triumph.</p>
<p>In this blog I want to highlight my lessons learned with some tips &amp; tricks for you to apply in your own journey.</p>
<hr />
<h1 id="heading-tip-1-start-with-a-buddy"><strong>Tip 1: Start with a Buddy</strong></h1>
<p>My first talk was back in 2012, when responsive design was the latest buzzword. I teamed up with a colleague at our small web agency, and we took our first plunge into public speaking.</p>
<p>I still remember the nerves—fumbling with my slides and accidentally swapping min-width with max-width. Despite my shaky start, having my buddy on stage helped ease the tension. We could cover for each other and even laugh off our mistakes in real-time.</p>
<p>Sharing the spotlight reduces the pressure. The journey feels less daunting and more collaborative when you have someone by your side.</p>
<p>The audience, too, plays an essential role in this dynamic. They are often more invested in the genuine learning process than in pursuing flawlessness. When they witness teamwork in action, they appreciate the authenticity behind the effort. It humanizes the experience and makes the endeavor relatable.</p>
<hr />
<p><img src="https://miro.medium.com/v2/resize:fit:700/1*oNYBTMo5d1fqpbIXhGXWWg.jpeg" alt="My first talk about JavaScript Web Speech API (sorry for the picture quality 😉)" /></p>
<h1 id="heading-tip-2-embrace-your-unknowns"><strong>Tip 2: Embrace Your Unknowns</strong></h1>
<p>In 2015, I decided it was time to go solo with a talk on the <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API">JavaScript Web Speech API</a>. Facing an audience of mostly experienced developers, I felt the weight of expectations to deliver something technical and in-depth.</p>
<p>When a question about accented speech caught me off guard, instead of scrambling for an answer, I admitted, “I don’t know — but let’s figure this out together after my talk!” That honest response opened up a collaborative dialogue, changing a moment of panic into a learning opportunity for everyone.</p>
<p>Practicing honesty lays the foundation for trust. When you openly acknowledge your areas of uncertainty, it enhances the authenticity of your presentation.</p>
<p>This vulnerability not only makes your message more relatable but also encourages your audience to actively participate in exploring new ideas with you. Inviting them into this shared discovery journey creates a more engaging and dynamic atmosphere that fosters connection and collaboration.</p>
<hr />
<h1 id="heading-tip-3-let-teaching-expose-your-gaps"><strong>Tip 3: Let Teaching Expose Your Gaps</strong></h1>
<p>By 2018, I mentored interns and taught courses on HTML, CSS, Flexbox, Grid, JavaScript, React, Angular, and more.</p>
<p>One session stands out: a bright intern asked, “What is a ternary operator in JavaScript?” I didn’t have a ready answer then, but rather than feeling embarrassed, I saw it as an opportunity to learn together.</p>
<p>We dove into the topic, and the discussion turned into a mini-workshop that benefited everyone in the room.</p>
<p>Teaching goes beyond sharing knowledge. It embodies the journey of learning side by side with your students. Rather than presenting oneself as the sole authority, acknowledging one's areas of uncertainty can transform each educational session into a shared expedition of discovery.</p>
<p>This collaborative approach enhances understanding and creates a rich environment where participants feel empowered to contribute their insights and experiences.</p>
<p>In this way, every discussion evolves into a great experience of ideas and perspectives, deepening the collective knowledge of both the instructor and the audience.</p>
<blockquote>
<p>Don’t stress if things don’t go as planned — most people won’t know your original plan.</p>
</blockquote>
<hr />
<h1 id="heading-tip-4-use-real-world-projects-for-content"><strong>Tip 4: Use Real-World Projects for Content</strong></h1>
<p>During 2023 and 2024, I partnered with my buddy Marco two talks on cutting-edge topics like GitHub Copilot for .NET projects. Back then it was pretty new for quite some developers.</p>
<p>I even showed how you can make ChatGPT be rude toward a notoriously rude recruiter. We practiced our presentation more than four or five times, receiving invaluable feedback from colleagues, interns, and trainees.</p>
<p>Basing your presentation on real-world projects make them highly relatable for the audience. Each practice round gave us more and more constructive feedback, which allowed us to improve our session.</p>
<p>Embrace every practice session as a chance to fine-tune your delivery, experimenting with different approaches based on real-life experiences and scenarios. By integrating these hands-on experiments into your preparation, you can craft talks that resonate with your audience, leaving a lasting impression.</p>
<hr />
<p><img src="https://miro.medium.com/v2/resize:fit:700/1*fcC7RRJZHfrrM3JUMG_C3w.png" alt /></p>
<h1 id="heading-tip-5-let-passion-outshine-perfection"><strong>Tip 5: Let Passion Outshine Perfection</strong></h1>
<p>In February 2025, I took the stage at DevWorld for my solo talk on local AI tools like Ollama, LM Studio, and Continue.dev — a genuinely passionate topic.</p>
<p>I prepared extensively with the support of trainees and colleagues, rehearsing and iterating my demos. While there were no demo glitches, the unpredictable nature of LLMs kept the audience engaged. I even showcased earlier tryouts of conversational demos to highlight the evolution of my work.</p>
<p>Preparation is key. Don’t stress if things don’t go as planned — most people won’t know your original plan. Plan for failure, be ready for unexpected twists and remember that passion will always outshine a quest for flawless perfection.</p>
<blockquote>
<p><em>You can find my presentation</em> <a target="_blank" href="https://dw2025.byrayray.dev/"><em>https://dw2025.byrayray.dev/</em></a></p>
</blockquote>
<hr />
<h1 id="heading-your-turn-to-start"><strong>Your Turn to Start</strong></h1>
<p>Every stumble — from mixing up media queries to facing unexpected questions — has shaped the speaker I am today.</p>
<p>My journey wasn’t about flawless delivery; it was about taking that first step, learning from each experience, and letting my passion lead the way.</p>
<p>If you’re hesitating to give that first talk, remember: your voice matters, and every mistake is a stepping stone toward improvement.</p>
<p>Ready to take the plunge?</p>
<p>What’s your funniest speaking fail? Share your story below, and let’s learn from each other — after all, every great speaker once started with a shaky first step!</p>
]]></content:encoded></item><item><title><![CDATA[Five Reasons to Choose Vue.js for Your Development Teams]]></title><description><![CDATA[In the ever-evolving landscape of web development, choosing the right framework can make or break your project's success. For lead developers, tech leads, and engineering managers, Vue.js has emerged as a compelling option worth considering. This pro...]]></description><link>https://hasnode.byrayray.dev/five-reasons-to-choose-vuejs-for-your-development-teams</link><guid isPermaLink="true">https://hasnode.byrayray.dev/five-reasons-to-choose-vuejs-for-your-development-teams</guid><category><![CDATA[Vue.js]]></category><category><![CDATA[vue]]></category><category><![CDATA[Vue3]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Programming Tips]]></category><dc:creator><![CDATA[Dev By RayRay]]></dc:creator><pubDate>Fri, 13 Sep 2024 09:08:36 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1726218264480/97f9bdc6-39ac-47bf-85f1-401d112e4877.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the ever-evolving landscape of web development, choosing the right framework can make or break your project's success. For lead developers, tech leads, and engineering managers, Vue.js has emerged as a compelling option worth considering. This progressive JavaScript framework offers numerous advantages that cater to developers and organizations alike.</p>
<p>In this blog post, I'll explore five key reasons why Vue.js should be your go-to for building robust, efficient, and scalable applications. But I won't be the evangelist telling you this framework is the best at all levels—others have great things, too!</p>
<blockquote>
<p><em>This blog post results from a strategic decision I was involved in, collaborating with IT managers at a semi-government organization in the Netherlands. We're currently transitioning two websites from Umbraco into a headless architecture with Vue.js, Nuxt.js, and the Umbraco content API.</em></p>
</blockquote>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-1-independent-and-not-owned-by-a-single-company">1. Independent and Not Owned by a Single Company</h2>
<p>We have many web frameworks and libraries thanks to countless independent software developers. Most platforms and companies wouldn't exist without these developers, who give their time for free (or with little compensation).</p>
<p><a target="_blank" href="https://vuejs.org/">Vue.js</a> is a JavaScript framework built entirely with the open-source community. Fun fact: it's not even owned by a company! The framework was founded by Evan You, who did much of the groundwork but got great help from other intelligent people worldwide.</p>
<p>Developers from the community have built fantastic libraries on top of it. For example, the community created <a target="_blank" href="https://vueuse.org/">VueUse</a>, <a target="_blank" href="https://nuxt.com/">Nuxt.js</a>, <a target="_blank" href="https://router.vuejs.org/">Vue Router</a>, <a target="_blank" href="https://vuex.vuejs.org/">Vuex</a>, <a target="_blank" href="https://pinia.vuejs.org/">Pinia</a>, and <a target="_blank" href="https://vuetifyjs.com/">Vuetify</a>. Some of these have even been adopted by the core Vue team.</p>
<p>So, if your company values or wants to support the open-source community, Vue.js is a great framework that aligns with that idea. As an organization, you can put your money where your mouth is by supporting them. Many <a target="_blank" href="https://vuejs.org/sponsor/">companies are doing the same</a>.</p>
<p>Also, it's good to know that Vue.js is no longer an underdog framework. It's used by big companies all around the world. Here's a list as an example:</p>
<ol>
<li><p>Alibaba Group</p>
</li>
<li><p>Zoom</p>
</li>
<li><p>GitLab</p>
</li>
<li><p>Grammarly</p>
</li>
<li><p>Upwork</p>
</li>
<li><p>Behance</p>
</li>
<li><p>Netlify</p>
</li>
<li><p>Netflix</p>
</li>
<li><p>Adobe</p>
</li>
<li><p>Google</p>
</li>
<li><p>Nintendo</p>
</li>
</ol>
<p>The list is much longer, suggesting that other big companies rely on Vue.js.</p>
<p>But if it's so great, let me tell you why. Because our engineers have to work with it, and it will never be successful if they aren't convinced.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-2-user-friendly-for-developers-of-all-levels">2. User-friendly for Developers of All Levels</h2>
<p>Vue.js's user-friendly nature is a boon for developers of all levels. Its straightforward approach makes it an excellent choice for building websites and web applications, instilling confidence and comfort in your team.</p>
<p>It's essential that if you pick a framework to build applications or websites, it won't limit you now or in the future. It should also be easy enough for all your developers to start.</p>
<p>Losing one of your team members would be sad because that framework is too tricky. Fortunately, Vue.js has you covered!</p>
<p>If you work with interns, trainees, or junior developers (and we help grow those developers to a higher level), picking Vue.js won't be a problem.</p>
<p>Even though it's easy to start, it's still very performant when building big projects. My team and I have never experienced any limits.</p>
<p>If you want to offer your developers extra framework knowledge, the Vue.js team has you covered. Unlike other frameworks, <a target="_blank" href="https://certificates.dev/vuejs">Vue.js has its certification program</a>, which teaches developers all the ins and outs of the framework through a video course. I have yet to see this with Angular or React.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-3-builds-on-top-of-standard-html-css-and-javascript">3. Builds on Top of Standard HTML, CSS, and JavaScript</h2>
<p>If you try Angular, you'll see that it requires developers to work with TypeScript. That's okay, but it can be a limitation for some developers. When you try React, you have CSS-in-JS, which can't be used inside the browser. Some developers flourish with it, but others hate it.</p>
<p>No, I don't want to get too deep into the technical details. However, every framework has its own ideas for using it. I'm very happy that in Vue.js, you can use normal HTML, CSS, and JavaScript.</p>
<p>But if you want to use, for example, Sass, SCSS, or Less for styling, they support that! They also support relying on TypeScript (which is a good idea). The power of Vue.js is that it supports the way you want to use it. They don't want to be in the way of the developers but want to accommodate how you want to use the framework.</p>
<p>One of the most significant benefits of picking Vue.js is that you can use it how you like. They won't enforce anything on you.</p>
<p>But okay, every framework needs a community to make it even better.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-4-large-and-supportive-community">4. Large and Supportive Community</h2>
<p>The Vue.js community, led by the friendly core team, is a welcoming space where developers support each other, fostering a sense of inclusion and belonging.</p>
<p>When non-core developers of Vue.js start a good plugin or extension, most of the time, they get support from the core developers. This is so great that I didn't find it in the other two frameworks. I think this also shows the power of open source.</p>
<p>No developer is too inexperienced to help maintain Vue.js. Is there a problem in the documentation, or can your team find a bug in Vue.js that they can contribute to? Your company then relies on many more developers than the ones you hired. This is a significant benefit.</p>
<p>The community can be fantastic, but developers still need documentation to use the framework. The Vue.js team has set a great example in this area, which other frameworks can take as inspiration.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-5-comprehensive-and-high-quality-documentation">5. Comprehensive and High-Quality Documentation</h2>
<p>A framework is worthless if there's no excellent and actionable documentation.</p>
<p>Vue.js has excellent documentation on their website. It contains simple language with clear code examples.</p>
<p>When developers encounter an error or experience problems using the framework, they should first consult the documentation.</p>
<p>Luckily, more than enough developers write about some edge cases on their blogs, so knowledge is also shared in the community.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>To summarize, if you're considering picking a JavaScript framework for your organization, check out Vue.js. Do a POC with it to see if it matches your and your developers' needs.</p>
<p>As a side note, if you need to rely on SSR (Server-Side Rendering), you can try <a target="_blank" href="https://vitejs.dev/guide/ssr">Vite SSR</a> or check out <a target="_blank" href="https://nuxt.com/">Nuxt.js</a>, the meta-framework for Vue.js.</p>
<p>Are you looking for a framework-independent build system? Check out <a target="_blank" href="https://vitejs.dev/">Vite</a>, built by the Vue.js team and is super fast. You can use Vite for Re<a target="_blank" href="https://vitejs.dev/">act,</a> Preact, Lit, Svelte, Solid, and even Qwik.</p>
<h2 id="heading-thanks">Thanks</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629789655319/nBF6anHH4w.png" alt="hashnode-footer.png" /></p>
<p><em>After reading this story, I hope you learned something new or are inspired to create something new! 🤗 If I left you with questions or something to say as a response, scroll down and type me a message, send me a</em> <a target="_blank" href="https://twitter.com/@devbyrayray"><em>DM on Twitter @DevByRayRay</em></a></p>
<p><em>Want to receive new posts in your mailbox? No, not only a link, just the whole article without any ads</em> 🤗 <em>or other stuff.</em> <a target="_blank" href="https://byrayraydev.substack.com/"><strong><em>Then subscribe to my newsletter</em></strong></a> <em>👍. I promise I won’t spam you, only the most important and best-quality content will be sent to you ✌️.</em></p>
<blockquote>
<p>Did you know that you can create a <a target="_blank" href="https://hashnode.com/@devbyrayray/joinme">Developer blog like this one, yourself</a>? It's entirely for free. 👍💰🎉🥳🔥</p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[How to Easily Add and Subtract Dates in JavaScript — date-fns is a solid choice]]></title><description><![CDATA[Are you seeking a straightforward solution to manipulate dates in JavaScript? Do you need to effortlessly add or subtract time units such as seconds, minutes, days, weeks, months, or years? 
You're in the right place! Learn how to add and subtract da...]]></description><link>https://hasnode.byrayray.dev/how-to-easily-add-and-subtract-dates-in-javascript-date-fns-is-a-solid-choice</link><guid isPermaLink="true">https://hasnode.byrayray.dev/how-to-easily-add-and-subtract-dates-in-javascript-date-fns-is-a-solid-choice</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Javascript library]]></category><category><![CDATA[date]]></category><category><![CDATA[Developer]]></category><category><![CDATA[development]]></category><dc:creator><![CDATA[Dev By RayRay]]></dc:creator><pubDate>Wed, 05 Jul 2023 19:57:29 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1688586819053/a3a1642c-c7c5-4650-ab67-830aa54677b4.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Are you seeking a straightforward solution to manipulate dates in JavaScript? Do you need to effortlessly add or subtract time units such as seconds, minutes, days, weeks, months, or years? </p>
<p>You're in the right place! Learn how to add and subtract dates easily in JavaScript using date-fns. Our guide helps you understand these steps in a simple way, making your code work better and faster. Start improving your date skills in JavaScript with us now!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-the-benefits-of-choosing-date-fns">The Benefits of Choosing date-fns</h2>
<p>If you've been in the JavaScript world for a while, you're likely familiar with MomentJS, once the go-to library for JavaScript date calculations, timezones, and formatting. However, as we started focusing more on efficient application performance, MomentJS's inability to tree-shaking and its impact on bundle size became an issue.</p>
<p>This led to the rise of modular JavaScript date libraries, among which date-fns emerged as a leading choice. Here's why: If you're mindful about not bloating your application bundle, date-fns is a sound choice. Its modular design allows you to include only the needed functions, reducing the impact on your bundle size and enhancing application performance.</p>
<p>And maybe even more valuable, <a target="_blank" href="https://github.com/date-fns/date-fns">date-fns is completely open source</a> 💪.</p>
<p>But let's get started where you came for the practical examples to help you further do Date calculations in JavaScript efficiently. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-tldr">TLDR;</h2>
<p>For those who don't want to read the whole article, here is the TLDR on how to do <code>Date</code> calculations with date-fn's.</p>
<h3 id="heading-add-days-weeks-months-and-years-to-date">Add days, weeks, months, and years to Date</h3>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { add, addDays, addWeeks, addMonths, addYears } <span class="hljs-keyword">from</span> <span class="hljs-string">'date-fns'</span>

<span class="hljs-comment">//31st of January 2023</span>
<span class="hljs-keyword">const</span> date = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(<span class="hljs-number">2023</span>, <span class="hljs-number">0</span>, <span class="hljs-number">31</span>);

<span class="hljs-built_in">console</span>.log(date); <span class="hljs-comment">// Tue Jan 31 2023</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Add 2 days: '</span>, addDays(date, <span class="hljs-number">2</span>)); <span class="hljs-comment">// Thu Feb 02 2023</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Add 5 weeks: '</span>, addWeeks(date, <span class="hljs-number">5</span>)); <span class="hljs-comment">// Tue Mar 07 2023</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Add 3 months: '</span>, addMonths(date, <span class="hljs-number">3</span>)); <span class="hljs-comment">// Sun Apr 30 2023</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Add 8 years: '</span>, addYears(date, <span class="hljs-number">8</span>)); <span class="hljs-comment">// Fri Jan 31 2031</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Add 5 days, 2 months, 3 weeks and 7 years: '</span>, add(date, {
    <span class="hljs-attr">days</span>: <span class="hljs-number">5</span>,
    <span class="hljs-attr">weeks</span>: <span class="hljs-number">3</span>,
    <span class="hljs-attr">months</span>: <span class="hljs-number">2</span>,
    <span class="hljs-attr">years</span>: <span class="hljs-number">7</span>
})); <span class="hljs-comment">// Fri Apr 26 2030</span>
<span class="hljs-built_in">console</span>.log(date); <span class="hljs-comment">// Tue Jan 31 2023</span>
</code></pre>
<h3 id="heading-subtract-days-weeks-months-years-to-date">Subtract days, weeks, months, years to Date</h3>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { sub, subDays, subWeeks, subMonths, subYears } <span class="hljs-keyword">from</span> <span class="hljs-string">'date-fns'</span>

<span class="hljs-comment">//31st of January 2023</span>
<span class="hljs-keyword">const</span> date = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(<span class="hljs-number">2023</span>, <span class="hljs-number">0</span>, <span class="hljs-number">31</span>);

<span class="hljs-built_in">console</span>.log(date); <span class="hljs-comment">// Tue Jan 31 2023</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Subtract 2 days: '</span>, subDays(date, <span class="hljs-number">2</span>)); <span class="hljs-comment">// Sun Jan 29 2023</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Subtract 5 weeks: '</span>, subWeeks(date, <span class="hljs-number">5</span>)); <span class="hljs-comment">// Tue Dec 27 2022</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Subtract 3 months: '</span>, subMonths(date, <span class="hljs-number">3</span>)); <span class="hljs-comment">// Mon Oct 31 2022</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Subtract 8 years: '</span>, subYears(date, <span class="hljs-number">8</span>)); <span class="hljs-comment">// Sat Jan 31 2015</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Subtract 5 days, 2 months, 3 weeks and 7 years: '</span>, sub(date, {
    <span class="hljs-attr">days</span>: <span class="hljs-number">5</span>,
    <span class="hljs-attr">weeks</span>: <span class="hljs-number">3</span>,
    <span class="hljs-attr">months</span>: <span class="hljs-number">2</span>,
    <span class="hljs-attr">years</span>: <span class="hljs-number">7</span>
})); <span class="hljs-comment">// Wed Nov 04 2015</span>
<span class="hljs-built_in">console</span>.log(date); <span class="hljs-comment">// Tue Jan 31 2023</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-installation">Installation</h2>
<p>Before using date-fns in your code, you need to install it.</p>
<pre><code class="lang-bash">npm install date-fns --save
<span class="hljs-comment"># or</span>
yarn add date-fns
</code></pre>
<p>After installation, you can choose to import the modules in different ways.</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// ESM</span>
<span class="hljs-keyword">import</span> { addDays, subDays } <span class="hljs-keyword">from</span> <span class="hljs-string">'date-fns'</span>;
<span class="hljs-comment">// ES 2015</span>
<span class="hljs-keyword">import</span> addDays <span class="hljs-keyword">from</span> <span class="hljs-string">'date-fns/addDays'</span>;
<span class="hljs-keyword">import</span> subDays <span class="hljs-keyword">from</span> <span class="hljs-string">'date-fns/subDays'</span>;
<span class="hljs-comment">// CommonJS</span>
<span class="hljs-keyword">const</span> addDays = <span class="hljs-built_in">require</span>(<span class="hljs-string">'date-fns/addDays'</span>);
<span class="hljs-keyword">const</span> subDays = <span class="hljs-built_in">require</span>(<span class="hljs-string">'date-fns/subDays'</span>);
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-how-to-add-days-to-a-date">How To Add <strong>Days to a Date</strong></h2>
<p>Let's start with something simple. Add one or more days to a date.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { addDays } <span class="hljs-keyword">from</span> <span class="hljs-string">'date-fns'</span>

<span class="hljs-comment">// 4th of July 2023</span>
<span class="hljs-keyword">const</span> date = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(<span class="hljs-number">2023</span>, <span class="hljs-number">6</span>, <span class="hljs-number">4</span>);

<span class="hljs-built_in">console</span>.dir(date); <span class="hljs-comment">// Tue Jul 04 2023</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Add 3 days: '</span>, addDays(date, <span class="hljs-number">3</span>)); <span class="hljs-comment">// Fri Jul 07 2023</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Add 7 days: '</span>, addDays(date, <span class="hljs-number">7</span>)); <span class="hljs-comment">// Tue Jul 11 2023</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Add 31 days: '</span>, addDays(date, <span class="hljs-number">31</span>)); <span class="hljs-comment">// Fri Aug 04 2023</span>
<span class="hljs-built_in">console</span>.log(date); <span class="hljs-comment">// Tue Jul 04 2023</span>
</code></pre>
<p><em>Check it on <a target="_blank" href="https://runkit.com/devbyrayray/how-to-add-days-to-javascript-date-with-date-fns">runkit</a>.</em></p>
<p>First, we have imported the <code>addDays</code> from date-fn's. We created a variable with a date and added 3, 7, and 31 days. </p>
<p>Each util function in date-fns will return a new Date object. This is nice, so you can continue to add more calculations on top of it. Also, notice that these functions don't change the date in the variable <code>date</code>, so all the functions are pure JavaScript functions.</p>
<p>Let's continue with subtracting days from a date.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-how-to-subtract-days-from-a-date">How To <strong>Subtract Days from a Date</strong></h2>
<p>Subtracting days is equally simple, like the previous example.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { subDays } <span class="hljs-keyword">from</span> <span class="hljs-string">'date-fns'</span>

<span class="hljs-comment">// 4th of July 2023</span>
<span class="hljs-keyword">const</span> date = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(<span class="hljs-number">2023</span>, <span class="hljs-number">6</span>, <span class="hljs-number">4</span>);

<span class="hljs-built_in">console</span>.log(date); <span class="hljs-comment">// Tue Jul 04 2023</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Subtract 3 days: '</span>, subDays(date, <span class="hljs-number">3</span>)); <span class="hljs-comment">// Sat Jul 01 2023</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Subtract 7 days: '</span>, subDays(date, <span class="hljs-number">7</span>)); <span class="hljs-comment">// Tue Jun 27 2023</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Subtract 31 days: '</span>, subDays(date, <span class="hljs-number">31</span>)); <span class="hljs-comment">// Sat Jun 03 2023</span>
<span class="hljs-built_in">console</span>.log(date); <span class="hljs-comment">// Tue Jul 04 2023</span>
</code></pre>
<p><em>Check it on <a target="_blank" href="https://runkit.com/devbyrayray/how-to-subtract-days-from-a-date-in-javascript-with-date-fns">runkit</a>.</em></p>
<p>Well, what more can I say? Like, it's that easy, right 😅. Let's continue with adding months to a JavaScript <code>Date</code>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-how-to-add-weeks-to-a-date">How To Add <strong>Weeks to a Date</strong></h2>
<p>Adding weeks to a <code>Date</code> is also a very common thing to do in, for example, booking systems. Well, date-fns is also supporting that.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { addWeeks } <span class="hljs-keyword">from</span> <span class="hljs-string">'date-fns'</span>

<span class="hljs-comment">//31st of January 2023</span>
<span class="hljs-keyword">const</span> date = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(<span class="hljs-number">2023</span>, <span class="hljs-number">0</span>, <span class="hljs-number">31</span>);

<span class="hljs-built_in">console</span>.log(date); <span class="hljs-comment">// Tue Jan 31 2023</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Add 1 week: '</span>, addWeeks(date, <span class="hljs-number">1</span>)); <span class="hljs-comment">// Tue Feb 07 2023</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Add 3 weeks: '</span>, addWeeks(date, <span class="hljs-number">3</span>)); <span class="hljs-comment">// Tue Feb 21 2023</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Add 9 weeks: '</span>, addWeeks(date, <span class="hljs-number">9</span>)); <span class="hljs-comment">// Tue Apr 04 2023</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Subtract 52 weeks: '</span>, subWeeks(date, <span class="hljs-number">52</span>)); <span class="hljs-comment">// Tue Feb 01 2022</span>
</code></pre>
<p><em>Check it on <a target="_blank" href="https://runkit.com/devbyrayray/how-to-add-weeks-to-a-date-in-javascript-with-date-fns">runkit</a>.</em></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-how-to-subtract-weeks-from-a-date">How To Subtract Weeks from a Date</h2>
<p>Well, subtracting weeks is as simple as adding weeks with date-fn's.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { subWeeks } <span class="hljs-keyword">from</span> <span class="hljs-string">'date-fns'</span>

<span class="hljs-comment">//31st of January 2023</span>
<span class="hljs-keyword">const</span> date = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(<span class="hljs-number">2023</span>, <span class="hljs-number">0</span>, <span class="hljs-number">31</span>);

<span class="hljs-built_in">console</span>.log(date); <span class="hljs-comment">// Tue Jan 31 2023</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Subtract 1 week: '</span>, subWeeks(date, <span class="hljs-number">1</span>));<span class="hljs-comment">// Tue Jan 24 2023</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Subtract 3 weeks: '</span>, subWeeks(date, <span class="hljs-number">3</span>)); <span class="hljs-comment">// Tue Jan 10 2023</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Subtract 9 weeks: '</span>, subWeeks(date, <span class="hljs-number">9</span>)); <span class="hljs-comment">// Tue Nov 29 2022</span>
</code></pre>
<p><em>Check it on <a target="_blank" href="https://runkit.com/devbyrayray/how-to-subtract-weeks-from-a-date-in-javascript-with-date-fns">runkit</a>.</em></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-how-to-add-months-to-a-date">How To Add <strong>Months to a Date</strong></h2>
<p>Adding months to a JavaScript <code>Date</code> can be simple, but in some cases, it can be tricky.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { addMonths } <span class="hljs-keyword">from</span> <span class="hljs-string">'date-fns'</span>

<span class="hljs-comment">//31st of January 2023</span>
<span class="hljs-keyword">const</span> date = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(<span class="hljs-number">2023</span>, <span class="hljs-number">0</span>, <span class="hljs-number">31</span>);

<span class="hljs-built_in">console</span>.log(date); <span class="hljs-comment">// Tue Jan 31 2023</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Add 1 month: '</span>, addMonths(date, <span class="hljs-number">1</span>)); <span class="hljs-comment">// Tue Feb 28 2023</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Add 3 months: '</span>, addMonths(date, <span class="hljs-number">3</span>)); <span class="hljs-comment">// Sun Apr 30 2023</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Add 9 months: '</span>, addMonths(date, <span class="hljs-number">9</span>)); <span class="hljs-comment">// Tue Oct 31 2023</span>
<span class="hljs-built_in">console</span>.log(date); <span class="hljs-comment">// Tue Jan 31 2023</span>
</code></pre>
<p><em>Check it on <a target="_blank" href="https://runkit.com/devbyrayray/how-to-add-months-to-a-date-in-javascript-with-date-fns">runkit</a>.</em></p>
<p>Let's say it's the 31st of January 2023, but we want to add one month. Well, you need to know how many days there are next month. This is tricky because that differs during leap years. So that's why in 2023, it will be the 28th of February, but if you try to add one month to the 31st of January in 2024, the outcome will be the 29th of February.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { addMonths } <span class="hljs-keyword">from</span> <span class="hljs-string">'date-fns'</span>

<span class="hljs-comment">//31st of January 2024</span>
<span class="hljs-keyword">const</span> date = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(<span class="hljs-number">2024</span>, <span class="hljs-number">0</span>, <span class="hljs-number">31</span>);

<span class="hljs-built_in">console</span>.log(date); <span class="hljs-comment">// Wed Jan 31 2024</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Add 1 month: '</span>, addMonths(date, <span class="hljs-number">1</span>)); <span class="hljs-comment">// Thu Feb 29 2024</span>
</code></pre>
<p><em>Check it on <a target="_blank" href="https://runkit.com/devbyrayray/how-to-add-months-to-a-date-in-javascript-with-date-fns">runkit</a>.</em></p>
<p>So this already proves why date-fns is much easier to use than plain JavaScript <code>Date</code>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-how-to-subtract-months-from-a-date">How To Subtract <strong>Months from a Date</strong></h2>
<p>Like adding months to a <code>Date</code> , subtracting months from a <code>Date</code> is equally simple. </p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { subMonths } <span class="hljs-keyword">from</span> <span class="hljs-string">'date-fns'</span>

<span class="hljs-comment">//31st of January 2023</span>
<span class="hljs-keyword">const</span> date = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(<span class="hljs-number">2023</span>, <span class="hljs-number">0</span>, <span class="hljs-number">31</span>);

<span class="hljs-built_in">console</span>.log(date); <span class="hljs-comment">// Tue Jan 31 2023</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Subtract 1 month: '</span>, subMonths(date, <span class="hljs-number">1</span>)); <span class="hljs-comment">// Sat Dec 31 2022</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Subtract 3 months: '</span>, subMonths(date, <span class="hljs-number">3</span>)); <span class="hljs-comment">// Mon Oct 31 2022</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Subtract 9 months: '</span>, subMonths(date, <span class="hljs-number">9</span>)); <span class="hljs-comment">// Sat Apr 30 2022</span>
<span class="hljs-built_in">console</span>.log(date); <span class="hljs-comment">// Tue Jan 31 2023</span>
</code></pre>
<p><em>Check it on <a target="_blank" href="https://runkit.com/devbyrayray/how-to-subtract-months-from-a-date-in-javascript-with-date-fns">runkit</a>.</em></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-how-to-add-years-to-a-date">How To <strong>Add Years to a Date</strong></h2>
<p>Adding years is a perfect example of how date-fns handles cases with leap years.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { addYear } <span class="hljs-keyword">from</span> <span class="hljs-string">'date-fns'</span>

<span class="hljs-comment">//31st of January 2023</span>
<span class="hljs-keyword">const</span> date = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(<span class="hljs-number">2023</span>, <span class="hljs-number">0</span>, <span class="hljs-number">31</span>);
<span class="hljs-keyword">const</span> leapYear = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(<span class="hljs-number">2024</span>, <span class="hljs-number">1</span>, <span class="hljs-number">29</span>);

<span class="hljs-built_in">console</span>.log(date);
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Add 1 year: '</span>, addYears(date, <span class="hljs-number">1</span>));
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Add 1 year to leap year: '</span>, addYears(leapYear, <span class="hljs-number">1</span>));
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Add 3 year: '</span>, addYears(date, <span class="hljs-number">3</span>));
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Add 9 year: '</span>, addYears(date, <span class="hljs-number">9</span>));
<span class="hljs-built_in">console</span>.log(date);
</code></pre>
<p><em>Check it on <a target="_blank" href="https://runkit.com/devbyrayray/how-to-add-years-to-a-date-in-javascript-with-date-fns">runkit</a>.</em></p>
<p>In the example, you can see that every outcome of the <code>addYears</code> function is correct. The case with the leap year is also perfect.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-how-to-subtract-years-from-a-date">How To Subtract <strong>Years from a Date</strong></h2>
<p>In this example, you can also see that subtracting years from a <code>Date</code> is a breeze with date-fn's.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { subYears } <span class="hljs-keyword">from</span> <span class="hljs-string">'date-fns'</span>

<span class="hljs-comment">//31st of January 2023</span>
<span class="hljs-keyword">const</span> date = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(<span class="hljs-number">2023</span>, <span class="hljs-number">0</span>, <span class="hljs-number">31</span>);
<span class="hljs-keyword">const</span> leapYear = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(<span class="hljs-number">2024</span>, <span class="hljs-number">1</span>, <span class="hljs-number">29</span>);

<span class="hljs-built_in">console</span>.log(date); <span class="hljs-comment">// Tue Jan 31 2023</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Subtract 1 year: '</span>, subYears(date, <span class="hljs-number">1</span>)); <span class="hljs-comment">// Mon Jan 31 2022</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Subtract 1 year to leap year: '</span>, subYears(leapYear, <span class="hljs-number">1</span>)); <span class="hljs-comment">// Tue Feb 28 2023</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Subtract 3 year: '</span>, subYears(date, <span class="hljs-number">3</span>)); <span class="hljs-comment">// Fri Jan 31 2020</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Subtract 9 year: '</span>, subYears(date, <span class="hljs-number">9</span>)); <span class="hljs-comment">// Fri Jan 31 2014</span>
<span class="hljs-built_in">console</span>.log(date); <span class="hljs-comment">// Tue Jan 31 2023</span>
</code></pre>
<p><em>Check it on <a target="_blank" href="https://runkit.com/devbyrayray/how-to-subtract-years-from-a-date-in-javascript-with-date-fns">runkit</a>.</em></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-how-to-add-or-subtract-hours-minutes-or-seconds-from-a-date">How To Add or Subtract <strong>Hours, Minutes, or Seconds from a Date</strong></h2>
<p>Equally important in calculating <code>Date</code> in JavaScript is time because adding 2 hours when it's 22:30 is not the same day but is the next day. Or it calculates a flight time traveling through different time zones. It's not easy, but lucky you can use date-fns for it.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { 
    addSeconds, subSeconds, addMinutes, 
    subMinutes, addHours, subHours
} <span class="hljs-keyword">from</span> <span class="hljs-string">'date-fns'</span>

<span class="hljs-comment">//31st of January 2023</span>
<span class="hljs-keyword">const</span> date = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(<span class="hljs-number">2023</span>, <span class="hljs-number">0</span>, <span class="hljs-number">31</span>, <span class="hljs-number">10</span>, <span class="hljs-number">18</span>, <span class="hljs-number">35</span>);

<span class="hljs-built_in">console</span>.log(date); <span class="hljs-comment">// Tue Jan 31 2023 10:18:35</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Add 15 seconds: '</span>, addSeconds(date, <span class="hljs-number">15</span>)); <span class="hljs-comment">// Tue Jan 31 2023 10:18:50</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Subtract 2 seconds: '</span>, subSeconds(date, <span class="hljs-number">2</span>)); <span class="hljs-comment">// Tue Jan 31 2023 10:18:33</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Add 15 minutes: '</span>, addMinutes(date, <span class="hljs-number">15</span>)); <span class="hljs-comment">// Tue Jan 31 2023 10:33:35</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Subtract 2 minutes: '</span>, subMinutes(date, <span class="hljs-number">2</span>)); <span class="hljs-comment">// Tue Jan 31 2023 10:16:35</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Add 15 hours: '</span>, addHours(date, <span class="hljs-number">15</span>)); <span class="hljs-comment">// Wed Feb 01 2023 01:18:35</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Subtract 2 hours: '</span>, subHours(date, <span class="hljs-number">2</span>)); <span class="hljs-comment">// Tue Jan 31 2023 08:18:35</span>
</code></pre>
<p><em>Check it on <a target="_blank" href="https://runkit.com/devbyrayray/how-to-add-or-subtract-hours-minutes-or-seconds-from-a-date-in-javascript-with-date-fns">runkit</a>.</em></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-how-to-add-or-subtract-days-weeks-months-and-years-to-a-date">How To Add <strong>or Subtract Days, Weeks, Months, and Years to a Date</strong></h2>
<p>Let's say we want to add seven days, three weeks, and nine months to date; we can combine the <code>addDays</code>, <code>addWeeks</code>, and <code>addMonths</code> for that. But even faster is the <code>add</code> or <code>sub</code> function in which you only have to add a parameter in which you configure it.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { add, sub } <span class="hljs-keyword">from</span> <span class="hljs-string">'date-fns'</span>

<span class="hljs-comment">//31st of January 2023</span>
<span class="hljs-keyword">const</span> date = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(<span class="hljs-number">2023</span>, <span class="hljs-number">0</span>, <span class="hljs-number">31</span>);

<span class="hljs-built_in">console</span>.log(date);
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Subtract 5 days, 2 months, 3 weeks and 7 years: '</span>, sub(date, {
    <span class="hljs-attr">days</span>: <span class="hljs-number">5</span>,
    <span class="hljs-attr">weeks</span>: <span class="hljs-number">3</span>,
    <span class="hljs-attr">months</span>: <span class="hljs-number">2</span>,
    <span class="hljs-attr">years</span>: <span class="hljs-number">7</span>
})); <span class="hljs-comment">// Wed Nov 04 2015</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Add 5 days, 2 months, 3 weeks and 7 years: '</span>, add(date, {
    <span class="hljs-attr">days</span>: <span class="hljs-number">5</span>,
    <span class="hljs-attr">weeks</span>: <span class="hljs-number">3</span>,
    <span class="hljs-attr">months</span>: <span class="hljs-number">2</span>,
    <span class="hljs-attr">years</span>: <span class="hljs-number">7</span>
})); <span class="hljs-comment">// Fri Apr 26 2030</span>
</code></pre>
<p><em>Check it on <a target="_blank" href="https://runkit.com/devbyrayray/how-to-add-or-subtract-days-weeks-months-and-years-to-a-date-in-javascript-with-date-fns">runkit</a>.</em></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-how-to-calculate-the-difference-between-dates">How To Calculate the Difference Between Dates</h2>
<p>In many situations, we want to calculate the difference between two dates. There are many functions in date-fns to do that easily.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { 
    differenceInSeconds, differenceInMinutes, differenceInHours, 
    differenceInDays, differenceInCalendarDays, differenceInBusinessDays, 
    differenceInWeeks, differenceInCalendarWeeks, differenceInMonths, 
    differenceInCalendarMonths, differenceInQuarters, differenceInCalendarQuarters, 
    differenceInYears, differenceInCalendarYears 
} <span class="hljs-keyword">from</span> <span class="hljs-string">'date-fns'</span>

<span class="hljs-comment">//31st of January 2023</span>
<span class="hljs-keyword">const</span> fromDate = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(<span class="hljs-number">2023</span>, <span class="hljs-number">0</span>, <span class="hljs-number">31</span>);
<span class="hljs-keyword">const</span> toDate = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(<span class="hljs-number">2025</span>, <span class="hljs-number">7</span>, <span class="hljs-number">15</span>);
<span class="hljs-keyword">const</span> log = <span class="hljs-built_in">console</span>.log

log(<span class="hljs-string">`Diff in seconds: <span class="hljs-subst">${differenceInSeconds(toDate, fromDate)}</span>`</span>) <span class="hljs-comment">// 80089200</span>
log(<span class="hljs-string">`Diff in minutes: <span class="hljs-subst">${differenceInMinutes(toDate, fromDate)}</span>`</span>) <span class="hljs-comment">// 1334820</span>
log(<span class="hljs-string">`Diff in hours: <span class="hljs-subst">${differenceInHours(toDate, fromDate)}</span>`</span>) <span class="hljs-comment">// 22247</span>

log(<span class="hljs-string">`Diff in days: <span class="hljs-subst">${differenceInDays(toDate, fromDate)}</span>`</span>) <span class="hljs-comment">// 927</span>
log(<span class="hljs-string">`Diff in business days: <span class="hljs-subst">${differenceInBusinessDays(toDate, fromDate)}</span>`</span>) <span class="hljs-comment">// 663</span>
log(<span class="hljs-string">`Diff in calendar days: <span class="hljs-subst">${differenceInCalendarDays(toDate, fromDate)}</span>`</span>) <span class="hljs-comment">// 927</span>

log(<span class="hljs-string">`Diff in weeks: <span class="hljs-subst">${differenceInWeeks(toDate, fromDate)}</span>`</span>) <span class="hljs-comment">// 132</span>
log(<span class="hljs-string">`Diff in calendar weeks: <span class="hljs-subst">${differenceInCalendarWeeks(toDate, fromDate)}</span>`</span>) <span class="hljs-comment">// 132</span>

log(<span class="hljs-string">`Diff in months: <span class="hljs-subst">${differenceInMonths(toDate, fromDate)}</span>`</span>) <span class="hljs-comment">// 30</span>
log(<span class="hljs-string">`Diff in calendar months: <span class="hljs-subst">${differenceInCalendarMonths(toDate, fromDate)}</span>`</span>) <span class="hljs-comment">// 31</span>

log(<span class="hljs-string">`Diff in quarters: <span class="hljs-subst">${differenceInQuarters(toDate, fromDate)}</span>`</span>) <span class="hljs-comment">// 10</span>
log(<span class="hljs-string">`Diff in calendar quarters: <span class="hljs-subst">${differenceInCalendarQuarters(toDate, fromDate)}</span>`</span>) <span class="hljs-comment">// 10</span>

log(<span class="hljs-string">`Diff in years: <span class="hljs-subst">${differenceInYears(toDate, fromDate)}</span>`</span>) <span class="hljs-comment">// 2</span>
log(<span class="hljs-string">`Diff in calendar years: <span class="hljs-subst">${differenceInCalendarYears(toDate, fromDate)}</span>`</span>) <span class="hljs-comment">// 2</span>
</code></pre>
<p><em>Check it on <a target="_blank" href="https://runkit.com/devbyrayray/how-to-calculate-difference-between-dates-in-javascript-with-date-fns">runkit</a>.</em></p>
<p>In the example, we have calculated the differences between the two dates. Seconds, minutes, hours, days, weeks, months, quarters, and years. </p>
<p>If you check the days, you see three different functions. Days, business days, and calendar days are slightly different from each other:</p>
<ul>
<li><code>differenceInDays</code> calculates full-day periods between two dates.</li>
<li><code>differenceInBusinessDays</code> calculates only business days and ignores the weekends.</li>
<li><code>differenceInCalendarDays</code> calculates the difference between two dates but ignores the time.</li>
</ul>
<p>You have two functions for the weeks, months, quarters, and years. The method with <code>Calendar</code> in it ignores the time part; the other one considers the time. (<a target="_blank" href="https://date-fns.org/docs/Getting-Started">check the documentation if you want to dive deeper into it</a>)</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Navigating through date calculations in JavaScript might initially seem like a complex labyrinth. However, as we've explored throughout this guide, it doesn't have to be. With the right tools and understanding, adding and subtracting dates – seconds, minutes, hours, days, weeks, months, or even years – can be effortless.</p>
<p>By choosing a powerful and modular library like date-fans, you're simplifying your coding process and ensuring optimal application performance, keeping your bundle sizes lean.</p>
<p>As with any skill, mastery comes with practice. So, go ahead and try out these date-fns functions in your projects. Before long, you'll handle date manipulations in JavaScript like a pro. Happy coding!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-thanks">Thanks</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629789655319/nBF6anHH4w.png" alt="hashnode-footer.png" /></p>
<p><em>After reading this story, I hope you learned something new or are inspired to create something new! 🤗 If I left you with questions or something to say as a response, scroll down and type me a message, send me a</em> <a target="_blank" href="https://twitter.com/@devbyrayray"><em>DM on Twitter @DevByRayRay</em></a></p>
<p><em>Want to receive new posts in your mailbox? No, not only a link, just the whole article without any ads</em> 🤗 <em>or other stuff.</em> <a target="_blank" href="https://byrayraydev.substack.com/"><strong><em>Then subscribe to my newsletter</em></strong></a> <em>👍. I promise I won’t spam you, only the most important and best-quality content will be sent to you ✌️.</em></p>
<blockquote>
<p>Did you know that you can create a <a target="_blank" href="https://hashnode.com/@devbyrayray/joinme">Developer blog like this one, yourself</a>? It's entirely for free. 👍💰🎉🥳🔥</p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[Mastering Nuxt CLI: An Essential Tool for Accelerating Nuxt.js Development]]></title><description><![CDATA[Ramp up your Nuxt.js development efficiency with the Nuxt CLI, a highly versatile tool that's often overlooked in the Nuxt ecosystem. In this blog post, you'll learn how you can use the CLI to generate components, layouts, pages, compostables, and mo...]]></description><link>https://hasnode.byrayray.dev/mastering-nuxt-cli-an-essential-tool-for-accelerating-nuxtjs-development</link><guid isPermaLink="true">https://hasnode.byrayray.dev/mastering-nuxt-cli-an-essential-tool-for-accelerating-nuxtjs-development</guid><category><![CDATA[Nuxt]]></category><category><![CDATA[Nuxt.js]]></category><category><![CDATA[Vue.js]]></category><category><![CDATA[cli]]></category><dc:creator><![CDATA[Dev By RayRay]]></dc:creator><pubDate>Wed, 28 Jun 2023 13:19:43 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1687957942051/fea1968f-2280-490b-88ec-134332ce0519.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Ramp up your Nuxt.js development efficiency with the Nuxt CLI, a highly versatile tool that's often overlooked in the Nuxt ecosystem. In this blog post, you'll learn how you can use the CLI to generate components, layouts, pages, compostables, and more.</p>
<p>Additionally, we'll share an effective startup script to jump-start your project after the initial Nuxt installation.</p>
<p><em>Originally published on:</em> <a target="_blank" href="https://byrayray.dev/posts/2023-06-28-nuxt-cli-the-tool-for-speeding-up-nuxt-development"><em>ByRayRay.dev</em></a></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-tldr">TLDR;</h2>
<ul>
<li><p><code>npx nuxi add component TheHeader</code></p>
</li>
<li><p><code>npx nuxi add layout HomePage</code></p>
</li>
<li><p><code>npx nuxi add page HomePage</code></p>
</li>
<li><p><code>npx nuxi add composable foo</code></p>
</li>
<li><p><code>npx nuxi add plugin foo</code></p>
</li>
<li><p><code>npx nuxi add middleware foo</code></p>
</li>
<li><p><code>npx nuxi add api base</code></p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-nuxt-cli">Nuxt CLI</h2>
<p>The Nuxt CLI is one of the most underrated tools of the entire Nuxt ecosystem. Especially the part where you can generate components, layouts, pages, compostables, and more. No more manual work on creating these files; just run the command. In the examples below, I'll show you how it works.</p>
<h3 id="heading-nuxt-add-component">Nuxt Add Component</h3>
<p>We all know the modern JavaScript framework is built by components, so let's start with that. Let's run the CLI and see the result.</p>
<pre><code class="lang-bash">npx nuxi add component TheHeader
</code></pre>
<p>This command creates the <code>components/TheHeader.vue</code> with this content.</p>
<pre><code class="lang-HTML"><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">"ts"</span> <span class="hljs-attr">setup</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">template</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
    Component: TheHeader
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">template</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">style</span> <span class="hljs-attr">scoped</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span>
</code></pre>
<p>If you want the component file nested in a folder, then use it like this example:</p>
<pre><code class="lang-bash">npx nuxi add component base/Button
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h3 id="heading-nuxt-add-layout">Nuxt Add Layout</h3>
<p>Generating a layout is equally simple:</p>
<pre><code class="lang-bash">npx nuxi add layout HomePage
</code></pre>
<p>This command creates a layout in the layouts folder with this content.</p>
<pre><code class="lang-HTML"><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">"ts"</span> <span class="hljs-attr">setup</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">template</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
    Layout: HomePage
    <span class="hljs-tag">&lt;<span class="hljs-name">slot</span> /&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">template</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">style</span> <span class="hljs-attr">scoped</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h3 id="heading-nuxt-add-page">Nuxt Add Page</h3>
<p>Generating a page is equally simple:</p>
<pre><code class="lang-bash">npx nuxi add page about
</code></pre>
<p>This command creates a page in the pages folder with this content.</p>
<pre><code class="lang-HTML"><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">"ts"</span> <span class="hljs-attr">setup</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">template</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
    Page: about
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">template</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">style</span> <span class="hljs-attr">scoped</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span>
</code></pre>
<p>If you want to create a child page or a page based on a specific ID, use this command:</p>
<pre><code class="lang-bash">npx nuxi add page <span class="hljs-string">"post/[id]"</span>
</code></pre>
<p>Or if you need a route like <code>/services/web/design.</code></p>
<pre><code class="lang-bash">npx nuxi add page services/web/design
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h3 id="heading-nuxt-add-composable">Nuxt Add Composable</h3>
<p>Generating a composable is equally simple:</p>
<pre><code class="lang-bash">npx nuxi add composable foo
</code></pre>
<p>This command creates a composable in the composables folder with this content.</p>
<pre><code class="lang-js"><span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> useFoo = <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-keyword">return</span> ref()
}
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h3 id="heading-nuxt-add-plugin">Nuxt Add Plugin</h3>
<p>Generating a plugin is equally simple:</p>
<pre><code class="lang-bash">npx nuxi add plugin <span class="hljs-keyword">for</span>
</code></pre>
<p>This command creates a layout in the layouts folder with this content.</p>
<pre><code class="lang-js"><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> defineNuxtPlugin(<span class="hljs-function">(<span class="hljs-params">nuxtApp</span>) =&gt;</span> {})
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h3 id="heading-nuxt-add-middleware">Nuxt Add Middleware</h3>
<p>Generating middleware is equally simple:</p>
<pre><code class="lang-bash">npx nuxi add middleware <span class="hljs-keyword">for</span>
</code></pre>
<p>This command creates a middleware file in the middleware folder with this content.</p>
<pre><code class="lang-js"><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> defineNuxtRouteMiddleware(<span class="hljs-function">(<span class="hljs-params">to, <span class="hljs-keyword">from</span></span>) =&gt;</span> {})
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h3 id="heading-nuxt-add-api">Nuxt Add Api</h3>
<p>Generating a layout is equally simple:</p>
<pre><code class="lang-bash">npx nuxi add api base
</code></pre>
<p>This command creates an API file with this content in the server/app folder.</p>
<pre><code class="lang-js"><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> defineEventHandler(<span class="hljs-function">(<span class="hljs-params">event</span>) =&gt;</span> {
  <span class="hljs-keyword">return</span> <span class="hljs-string">'Hello base'</span>
})
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h3 id="heading-nuxt-startup-script">Nuxt Startup Script</h3>
<p>I often find myself creating the same files over and over again when I start a new Nuxt project. In this case, I created a shell script for myself which contains all the default files I use most of the time.</p>
<p>I call this file (or you can drop this command in your terminal and run it) in my terminal and have all the defaults created automatically.</p>
<p>Adjust this script for your own needs 👍</p>
<pre><code class="lang-bash">git init &amp;&amp;
npx nuxi add layout default &amp;&amp;
npx nuxi add layout HomePage &amp;&amp;
npx nuxi add component TheHeader &amp;&amp;
npx nuxi add component TheFooter &amp;&amp;
npx nuxi add api base &amp;&amp;
npx nuxi add page index &amp;&amp;
rm -of app.vue
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-thanks">Thanks</h2>
<p>Now you are entirely up to date with how to use Nuxt CLI. I hope you can start using them right away. If you want to learn more of the Nuxt CLI, check <a target="_blank" href="https://nuxt.com/docs/api/commands/add">their awesome documentation</a>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629789655319/nBF6anHH4w.png" alt="hashnode-footer.png" /></p>
<p><em>After reading this story, I hope you learned something new or are inspired to create something new! 🤗 If I left you with questions or something to say as a response, scroll down and type me a message, send me a</em> <a target="_blank" href="https://twitter.com/@devbyrayray"><em>DM on Twitter @DevByRayRay</em></a></p>
<p><em>Want to receive new posts in your mailbox? No, not only a link, just the whole article without any ads</em> 🤗 <em>or other stuff.</em> <a target="_blank" href="https://byrayraydev.substack.com/"><strong><em>Then subscribe to my newsletter</em></strong></a> <em>👍. I promise I won’t spam you, only the most important and best-quality content will be sent to you ✌️.</em></p>
<blockquote>
<p>Did you know that you can create a <a target="_blank" href="https://hashnode.com/@devbyrayray/joinme">Developer blog like this one, yourself</a>? It's entirely for free. 👍💰🎉🥳🔥</p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[How to use Angular Signals]]></title><description><![CDATA[Angular Signals are hot right now! Even if you still need to start using them because you're not on Angular 16, Making your Angular development more straightforward and future-proof is worth your time.
Do you find RxJS complex? Well, you are not the ...]]></description><link>https://hasnode.byrayray.dev/how-to-use-angular-signals</link><guid isPermaLink="true">https://hasnode.byrayray.dev/how-to-use-angular-signals</guid><category><![CDATA[Angular]]></category><category><![CDATA[RxJS]]></category><category><![CDATA[TypeScript]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Dev By RayRay]]></dc:creator><pubDate>Wed, 21 Jun 2023 15:33:50 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1687361278620/cd3b9ed0-4423-4f28-8779-8b6f19ba0926.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Angular Signals are hot right now! Even if you still need to start using them because you're not on Angular 16, Making your Angular development more straightforward and future-proof is worth your time.</p>
<p>Do you find RxJS complex? Well, you are not the only one. So many others think that way. Well, Angular Signals solves that problem for so many developers. So let's dive into it together.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h3 id="heading-sources">Sources:</h3>
<ul>
<li><p><a target="_blank" href="https://github.com/devbyray/angular-signals-vs-rxjs">Github</a></p>
</li>
<li><p><a target="_blank" href="https://codesandbox.io/p/github/devbyray/angular-signals-vs-rxjs/main?layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522panelType%2522%253A%2522TABS%2522%252C%2522id%2522%253A%2522clim5w3tu00753p6olf6t445f%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522panelType%2522%253A%2522TABS%2522%252C%2522id%2522%253A%2522clim5w3tu00763p6ok5kqy7xm%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B65.34208440466293%252C34.65791559533707%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522clim5w3tu00753p6olf6t445f%2522%253A%257B%2522id%2522%253A%2522clim5w3tu00753p6olf6t445f%2522%252C%2522tabs%2522%253A%255B%257B%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252Fsrc%252Fapp%252Fsignals-updates-array%252Fsignals-updates-array.component.ts%2522%252C%2522id%2522%253A%2522clj5ojqfc00ro3p6o339jgi5z%2522%252C%2522mode%2522%253A%2522permanent%2522%257D%255D%252C%2522activeTabId%2522%253A%2522clj5ojqfc00ro3p6o339jgi5z%2522%257D%252C%2522clim5w3tu00763p6ok5kqy7xm%2522%253A%257B%2522id%2522%253A%2522clim5w3tu00763p6ok5kqy7xm%2522%252C%2522tabs%2522%253A%255B%257B%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522start%2522%252C%2522id%2522%253A%2522clim5wjf200cy3p6o6ltrngnd%2522%252C%2522mode%2522%253A%2522permanent%2522%257D%252C%257B%2522type%2522%253A%2522TASK_PORT%2522%252C%2522taskId%2522%253A%2522start%2522%252C%2522port%2522%253A4200%252C%2522id%2522%253A%2522clim5wpod00i73p6obec6k6sr%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522path%2522%253A%2522%252F%2522%257D%255D%252C%2522activeTabId%2522%253A%2522clim5wpod00i73p6obec6k6sr%2522%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A29.677019335262912%257D">CodeSandbox</a></p>
</li>
<li><p><a target="_blank" href="https://angular-signals-vs-rxjs.vercel.app/">Example website</a></p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-signals">Signals</h2>
<p>Angular Signals are reactive properties in your Angular component, directive, or service. They update their value automatically; you don't need to listen to changes. No, they are doing all of that for you. Let's start with creating a Signal and showing it in the view.</p>
<h3 id="heading-get-the-value">Get the value</h3>
<p>Let's start simple. Getting a value from a signal is pretty straightforward.</p>
<p>If we want to show the value of a signal in the view, we need to define it first in the component.</p>
<pre><code class="lang-typescript"><span class="hljs-meta">@Component</span>({...})
<span class="hljs-keyword">export</span> <span class="hljs-keyword">class</span> Component {
    count = signal&lt;<span class="hljs-built_in">number</span>&gt;(<span class="hljs-number">0</span>)
}
</code></pre>
<p>Then in the view, we can output it in an expression like this:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>{{ count() }}<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>It is that easy. But how do we use a value of a signal in our component?</p>
<h3 id="heading-how-to-get-a-value-in-a-component-class">How to get a value in a component class</h3>
<p>The class of your component is also slightly different. The <code>Signal</code> value can be retrieved as easily as <code>this.count()</code>.</p>
<pre><code class="lang-typescript"><span class="hljs-meta">@Component</span>({...})
<span class="hljs-keyword">export</span> <span class="hljs-keyword">class</span> Component {
    count = signal&lt;<span class="hljs-built_in">number</span>&gt;(<span class="hljs-number">0</span>)

    <span class="hljs-keyword">private</span> logCount(): <span class="hljs-built_in">void</span> {
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Count: '</span>, <span class="hljs-built_in">this</span>.count())
    }
}
</code></pre>
<p>Since signals are built for reactivity in Angular, we want to set and update a value in a signal. Let's dive into that.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h3 id="heading-setting-and-updating-the-value">Setting and updating the value</h3>
<p>Reading the values of a <code>Signal</code> is simple. But if you are used to RxJS with Observables and Behavioursubjects, for example, this is a bit different, but I know you will love the simplicity!</p>
<p>By default, you can give a signal a value (just like the <code>BehaviourSubject</code>). When the value is changed, the view is updated automatically. Setting the value of a signal can be done with</p>
<pre><code class="lang-typescript"><span class="hljs-meta">@Component</span>({...})
<span class="hljs-keyword">export</span> <span class="hljs-keyword">class</span> Component {
    count = signal&lt;<span class="hljs-built_in">number</span>&gt;(<span class="hljs-number">0</span>)

    <span class="hljs-keyword">private</span> changeCount(): <span class="hljs-built_in">void</span> {
        <span class="hljs-built_in">this</span>.count.set(<span class="hljs-number">30</span>)
    }
}
</code></pre>
<h3 id="heading-how-to-update-a-value-in-a-signal-based-on-the-previous-value">How to update a value in a Signal based on the previous value</h3>
<p>If you want to update your <code>Signal</code> based on the previous value, use the <code>update()</code> method.</p>
<pre><code class="lang-typescript">count = signal(<span class="hljs-number">25</span>)

<span class="hljs-comment">// Update value</span>
<span class="hljs-built_in">this</span>.signal.update(<span class="hljs-function"><span class="hljs-params">prevValue</span> =&gt;</span> prevValue + <span class="hljs-number">10</span>) <span class="hljs-comment">// 35</span>
</code></pre>
<p>When the update has been done, it will automatically be reflected in the view.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h3 id="heading-how-to-update-a-signal-with-an-array-of-objects">How to update a signal with an array of objects</h3>
<p>Updating an Array of Objects is equally simple with Signals. For this, we will use the <code>.mutate()</code> method.</p>
<p>Let's say we have an Array of Objects. Each Object has a price property. What if we want to update the first price, we can do that with <code>.mutate()</code> like this.</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">export</span> <span class="hljs-keyword">class</span> SignalsUpdatesArrayComponent {
    prices = signal&lt;Obj[]&gt;([
      { price: <span class="hljs-number">10</span> }, 
      { price: <span class="hljs-number">20</span> }, 
      { price: <span class="hljs-number">30</span> }
    ])

    updatePrice(): <span class="hljs-built_in">void</span> {
        <span class="hljs-built_in">this</span>.prices.mutate(<span class="hljs-function"><span class="hljs-params">value</span> =&gt;</span> (value[<span class="hljs-number">0</span>].price = <span class="hljs-built_in">this</span>.getRandomPrice()))
    }

    getRandomPrice(): <span class="hljs-built_in">number</span> {
        <span class="hljs-keyword">return</span> <span class="hljs-built_in">Math</span>.round(<span class="hljs-built_in">Math</span>.random() * <span class="hljs-number">100</span>)
    }
}
</code></pre>
<p>We call the <code>updatePrice()</code> in the template, and it will be performed.</p>
<p>But what if we want to add an Object to the Array on the fly? Well just as easy. Push a new Object in the <code>mutate()</code> method.</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">export</span> <span class="hljs-keyword">class</span> SignalsUpdatesArrayComponent {
    prices = signal&lt;Obj[]&gt;([
      { price: <span class="hljs-number">10</span> }, 
      { price: <span class="hljs-number">20</span> }, 
      { price: <span class="hljs-number">30</span> }
    ])

    updatePrice(index: <span class="hljs-built_in">number</span>): <span class="hljs-built_in">void</span> {
        <span class="hljs-built_in">this</span>.prices.mutate(<span class="hljs-function"><span class="hljs-params">value</span> =&gt;</span> (value[index].price = <span class="hljs-built_in">this</span>.getRandomPrice()))
    }
    addPrice(): <span class="hljs-built_in">void</span> {
        <span class="hljs-built_in">this</span>.prices.mutate(<span class="hljs-function"><span class="hljs-params">value</span> =&gt;</span> value.push({ price: <span class="hljs-built_in">this</span>.getRandomPrice() }))
    }

    getRandomPrice(): <span class="hljs-built_in">number</span> {
        <span class="hljs-keyword">return</span> <span class="hljs-built_in">Math</span>.round(<span class="hljs-built_in">Math</span>.random() * <span class="hljs-number">100</span>)
    }
}
</code></pre>
<p><a target="_blank" href="https://angular-signals-vs-rxjs.vercel.app/">I created an example</a> so you can see that it works by easily updating the Array.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<blockquote>
<p>If you want to learn more about <a target="_blank" href="https://byrayray.dev/posts/2021-09-03_when-to-use-rxjs-subject-behavioursubject-replaysubject-asyncsubject-or-void-subject-in-angular-c2e9db61b4a0">RxJS Subjects, BehaviourSubjects and more</a>? Then read the post I wrote about that in detail.</p>
</blockquote>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-effect">Effect</h2>
<h3 id="heading-listen-to-value-updates-with-effect">Listen to value updates with effect()</h3>
<p>Listening to changes can easily be done with <code>effect()</code> . But it's not equal to the behavior of listening to changes of an <code>Observable</code> or <code>BehaviourSubject</code> in RxJS. So let's see what the difference is.</p>
<p>The <code>effect()</code> method with Signals is mostly for updating logging, saving data to local storage, or updating your canvas. By default, you are not allowed to update a signal within the <code>effect()</code>.</p>
<p>For example, we create a component where we want to log when the price is updated. In the constructor, we have added the <code>effect()</code> to show that the price has been updated. In the HTML, we create a button to update the price.</p>
<pre><code class="lang-typescript"><span class="hljs-meta">@Component</span>({...})
<span class="hljs-keyword">export</span> <span class="hljs-keyword">class</span> SignalsGetUpdatesComponent {
  price = signal&lt;<span class="hljs-built_in">number</span>&gt;(<span class="hljs-number">10</span>);
  priceUpdated = signal&lt;<span class="hljs-built_in">boolean</span>&gt;(<span class="hljs-literal">false</span>);

  <span class="hljs-keyword">constructor</span>(<span class="hljs-params"></span>) {
    effect(<span class="hljs-function">() =&gt;</span> {
      <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Price updated <span class="hljs-subst">${<span class="hljs-built_in">this</span>.price()}</span>`</span>);
    });
  }

  updatePrice() {
    <span class="hljs-built_in">this</span>.price.update(<span class="hljs-function">(<span class="hljs-params">price</span>) =&gt;</span> price + <span class="hljs-number">30</span>);
    <span class="hljs-built_in">this</span>.priceUpdated.set(<span class="hljs-literal">true</span>);
    <span class="hljs-built_in">setTimeout</span>(<span class="hljs-function">() =&gt;</span> {
      <span class="hljs-built_in">this</span>.priceUpdated.set(<span class="hljs-literal">false</span>);
    }, <span class="hljs-number">2000</span>);
  }
}
</code></pre>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>Get updates<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>
        Add {{30 | currency: 'EUR'}} to the price <span class="hljs-tag">&lt;<span class="hljs-name">br</span> /&gt;</span>
        of {{10 | currency: 'EUR'}} and notify.
    <span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>

    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>Is price updated: <span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span> {{priceUpdated() ? "👍" : "👎"}}<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>Price: <span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span> {{price() | currency:'EUR'}}<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">button</span> (<span class="hljs-attr">click</span>)=<span class="hljs-string">"updatePrice()"</span> [<span class="hljs-attr">ngClass</span>]=<span class="hljs-string">"{'is-updated': priceUpdated()}"</span>&gt;</span>Add {{30 | currency: 'EUR'}}<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>In this case, I update the <code>priceUpdated</code> signal in the <code>updatePrice()</code> method while updating the price. When you use RxJS with a <code>BehaviourSubject</code>, you could have done that in the <code>subscribe()</code> method. This is a matter of taste on what you prefer.</p>
<p>If you know what you do and are aware of creating possibly an infinite loop with updating signals in the <code>effect(),</code> you can do that by passing a second parameter <code>{ allowSignalWrites: true }</code>.</p>
<pre><code class="lang-typescript"><span class="hljs-meta">@Component</span>({...})
<span class="hljs-keyword">export</span> <span class="hljs-keyword">class</span> SignalsGetUpdatesEffectUpdateComponent {
    price = signal&lt;<span class="hljs-built_in">number</span>&gt;(<span class="hljs-number">10</span>)
    priceUpdated = signal&lt;<span class="hljs-built_in">boolean</span>&gt;(<span class="hljs-literal">false</span>)

    <span class="hljs-keyword">constructor</span>(<span class="hljs-params"></span>) {
        effect(
            <span class="hljs-function">() =&gt;</span> {
                <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Price updated <span class="hljs-subst">${<span class="hljs-built_in">this</span>.price()}</span>`</span>)

                <span class="hljs-built_in">this</span>.priceUpdated.set(<span class="hljs-literal">true</span>)
                <span class="hljs-built_in">setTimeout</span>(<span class="hljs-function">() =&gt;</span> {
                    <span class="hljs-built_in">this</span>.priceUpdated.set(<span class="hljs-literal">false</span>)
                }, <span class="hljs-number">2000</span>)
            },
            { allowSignalWrites: <span class="hljs-literal">true</span> }
        )
    }

    updatePrice() {
        <span class="hljs-built_in">this</span>.price.update(<span class="hljs-function"><span class="hljs-params">price</span> =&gt;</span> price + <span class="hljs-number">30</span>)
    }
}
</code></pre>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>Get updates and overwrite signal in effect<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>
        Add {{30 | currency: 'EUR'}} to the price <span class="hljs-tag">&lt;<span class="hljs-name">br</span> /&gt;</span>
        of {{10 | currency: 'EUR'}} and notify.
    <span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>

    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>Is price updated: <span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span> {{priceUpdated() ? "👍" : "👎"}}<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>Price: <span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span> {{price() | currency:'EUR'}}<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">button</span> (<span class="hljs-attr">click</span>)=<span class="hljs-string">"updatePrice()"</span> [<span class="hljs-attr">ngClass</span>]=<span class="hljs-string">"{'is-updated': priceUpdated()}"</span>&gt;</span>Add {{30 | currency: 'EUR'}}<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>The effect will run when the component is initialized, like the <code>ngOnInit</code>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-computations">Computations</h2>
<p>Let's talk about computations. You use a computation when calculating or doing string concatenation based on changing one or more values.</p>
<h3 id="heading-get-the-value-from-the-computation">Get the value from the computation</h3>
<pre><code class="lang-typescript"><span class="hljs-comment">// Signal</span>
getDoubleCount() {
    <span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">this</span>.doubleCount())
}

<span class="hljs-comment">// BehaviourSubject</span>
getDoubleCount() {
    <span class="hljs-built_in">this</span>.doubleCount.subscribe(<span class="hljs-function">(<span class="hljs-params">value</span>) =&gt;</span> <span class="hljs-built_in">console</span>.log(value))
}
</code></pre>
<p>And this is where getting the simplest thing, as getting the double-count value, is going to be less straightforward with the <code>BehaviourSubject</code> if you compare it with the <code>Signal</code>.</p>
<p>Because with the <code>BehaviourSubject</code>, you want to ensure the subscription is removed when it's not needed anymore.</p>
<p>With signals, Angular handles many things for you, more than using RxJS. With RxJS, we can often get buried in complex and hard-to-read code, especially for people who have yet to get used to Angular or RxJS.</p>
<p>For example, with RxJS, we need to clean our subscriptions ourselves; with signals, we don't have that because Angular handles that for us.</p>
<pre><code class="lang-typescript"><span class="hljs-comment">// Inside a component class</span>
<span class="hljs-comment">// ...</span>
destroy$ = <span class="hljs-keyword">new</span> Subject&lt;<span class="hljs-built_in">void</span>&gt;();

ngOnDestroy() {
    <span class="hljs-built_in">this</span>.destroy$.next();
}

getDoubleCount() {
    <span class="hljs-built_in">this</span>.doubleCount
        .pipe(takeUntil(<span class="hljs-built_in">this</span>.destroy$))
        .subscribe(<span class="hljs-function">(<span class="hljs-params">value</span>) =&gt;</span> <span class="hljs-built_in">console</span>.log(value))
}
<span class="hljs-comment">//...</span>
</code></pre>
<p>No, signals bring a lot of simplicity while using reactivity. Developers coming from Vue will be used to a very similar way of handling reactive properties.</p>
<p>For example, let's update a first name and show the user the full name. We will use <code>computed()</code> to help us with that.</p>
<pre><code class="lang-typescript"><span class="hljs-meta">@Component</span>({...})
<span class="hljs-keyword">export</span> <span class="hljs-keyword">class</span> SignalsComputeValueComponent {
  firstName = signal(<span class="hljs-string">'Bart'</span>)
  lastName = signal(<span class="hljs-string">'The Great'</span>)

  fullName = computed(<span class="hljs-function">() =&gt;</span> <span class="hljs-built_in">this</span>.firstName() + <span class="hljs-string">' '</span> + <span class="hljs-built_in">this</span>.lastName())

  changeFirstName() {
    <span class="hljs-built_in">this</span>.firstName.set(<span class="hljs-string">'Ray'</span>)
  }
}
</code></pre>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>Get updates and overwrite signal in effect<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>

    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>Firstname:<span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span> {{ firstName() }} <span class="hljs-tag">&lt;<span class="hljs-name">br</span> /&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>Lastname:<span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span> {{ lastName() }}
    <span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>Fullname computation:<span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span> {{ fullName() }}<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>

    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">button</span> (<span class="hljs-attr">click</span>)=<span class="hljs-string">"changeFirstName()"</span>&gt;</span>Update firstname<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>As you can see, the <code>fullName</code> property merges two strings in the <code>computed()</code> method. When the <code>firstName</code> is updated, the <code>fullName</code> will be updated automatically, and you can see it directly in the view. It is that simple!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-thanks">Thanks</h2>
<p>Now you are entirely up to date with how to use Angular Signals. I hope you can start using them right away.</p>
<p><img src="/images/0__4aTcitCaVTWHHeiO.jpg" alt /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629789655319/nBF6anHH4w.png" alt="hashnode-footer.png" /></p>
<p><em>After reading this story, I hope you learned something new or are inspired to create something new! 🤗 If I left you with questions or something to say as a response, scroll down and type me a message, send me a</em> <a target="_blank" href="https://twitter.com/@devbyrayray"><em>DM on Twitter @DevByRayRay</em></a></p>
<p><em>Want to receive new posts in your mailbox? No, not only a link, just the whole article without any ads</em> 🤗 <em>or other stuff.</em> <a target="_blank" href="https://byrayraydev.substack.com/"><strong><em>Then subscribe to my newsletter</em></strong></a> <em>👍. I promise I won’t spam you, only the most important and best-quality content will be sent to you ✌️.</em></p>
<blockquote>
<p>Did you know that you can create a <a target="_blank" href="https://hashnode.com/@devbyrayray/joinme">Developer blog like this one, yourself</a>? It's entirely for free. 👍💰🎉🥳🔥</p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[5 Ways to Improve Your Coding Skills with ChatGPT: Tips and Tricks for Developers]]></title><description><![CDATA[Are you a developer looking to improve your craft? Look no further than ChatGPT! In this blog post, we'll outline five tips for using ChatGPT to become a better developer, including brainstorming solutions to application problems, spotting errors in ...]]></description><link>https://hasnode.byrayray.dev/5-ways-to-improve-your-coding-skills-with-chatgpt-tips-and-tricks-for-developers</link><guid isPermaLink="true">https://hasnode.byrayray.dev/5-ways-to-improve-your-coding-skills-with-chatgpt-tips-and-tricks-for-developers</guid><category><![CDATA[chatgpt]]></category><category><![CDATA[AI]]></category><category><![CDATA[GPT 4]]></category><dc:creator><![CDATA[Dev By RayRay]]></dc:creator><pubDate>Wed, 05 Apr 2023 09:03:49 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1680685107530/233e5926-7d6d-41e4-b679-01e399f648a0.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Are you a developer looking to improve your craft? Look no further than ChatGPT! In this blog post, we'll outline five tips for using ChatGPT to become a better developer, including brainstorming solutions to application problems, spotting errors in code, explaining code functionality, writing better tests, and improving code readability.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-chatgpt-helps-you-brainstorm-why-a-problem-is-caused-in-your-application">ChatGPT helps you brainstorm why a problem is caused in your application</h2>
<p>My team and I encountered an issue in our application where data needed to be included, and models still needed to update. We work in an Angular environment.</p>
<p>Let me share a situation where I discovered the power of discovering solutions and problems in an application.</p>
<h3 id="heading-situation-subscription-didnt-exist">Situation: Subscription didn't exist</h3>
<p>After manually searching for what could happen, we took the leap and started asking questions to ChatGPT. We started with this question.</p>
<blockquote>
<p>We are using RxJS; we have a BehaviourSubject, but at the start, the data is received by the subscribe method, but later it isn't. What could be the problem?</p>
</blockquote>
<p>After this question, ChatGPT started answering them with possible situations. Last, it suggested we check if the subscription still exists. It also provided us with a solution to check it.</p>
<p>Well, that worked 😅🎉. Finally, we found the cause, and we could fix the issue 👍</p>
<p><img src="https://cdn-images-1.medium.com/max/1600/0*y906fP7b9qDMOnUB.png" alt /></p>
<p><strong>The answer:</strong></p>
<p><img src="https://cdn-images-1.medium.com/max/1600/0*tk1voSgCLry9SvST.png" alt /></p>
<hr />
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-chatgpt-helps-spot-problems-with-failing-tests">ChatGPT helps spot problems with failing tests</h2>
<p>In the last couple of months, I have incorporated ChatGPT into all the work in my team.</p>
<p>Sometimes you can have failing tests that don't make sense in the first place. ChatGPT can help you discover the problems and help find the solution.</p>
<p>Just like this situation I encountered lately with my team.</p>
<h3 id="heading-situation-date-function-wrongly-calculated-date-with-vanilla-javascript">Situation: Date function wrongly calculated date with Vanilla JavaScript</h3>
<p>The other day we replaced an old date library with a new one. But we needed to create some translation layer so our dependencies still work.</p>
<p>After we did that, we checked the end-to-end tests. And what was the case? One error! A method that used to work before, but now it doesn't.</p>
<pre><code class="lang-javascript">getCalculatedDate(days: number, <span class="hljs-attr">months</span>: number, <span class="hljs-attr">years</span>: number) {
    <span class="hljs-keyword">const</span> today: <span class="hljs-built_in">Date</span> = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>();
    <span class="hljs-keyword">const</span> calculatedDate = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(
      today.getFullYear() + years,
      today.getMonth() + months,
      today.getDate() + days
    );
    <span class="hljs-keyword">const</span> days = <span class="hljs-built_in">String</span>(calculatedDate.getDate()).padStart(<span class="hljs-number">2</span>, <span class="hljs-string">'0'</span>);
    <span class="hljs-keyword">const</span> months = <span class="hljs-built_in">String</span>(calculatedDate.getMonth() + <span class="hljs-number">1</span>).padStart(<span class="hljs-number">2</span>, <span class="hljs-string">'0'</span>);
    <span class="hljs-keyword">const</span> years = <span class="hljs-built_in">String</span>(calculatedDate.getFullYear());
    <span class="hljs-keyword">const</span> formattedDate = days + <span class="hljs-string">'-'</span> + months + <span class="hljs-string">'-'</span> + years;
    <span class="hljs-keyword">return</span> formattedDate;
  }
</code></pre>
<p>The issue was a difference of 1 hour time difference. Even though we didn't change the method's input, the comparison function output did.</p>
<p>After trying for a while, we started asking questions like:</p>
<ol>
<li><p>What if I add 3 months and 1 day to today? What date is that?</p>
</li>
<li><p>Explain the calculation</p>
</li>
<li><p>Would the answer be different if adding days first in the calculation?</p>
</li>
<li><p>And so on.</p>
</li>
</ol>
<p>Eventually, we dropped the function and asked what was going wrong here. It helped us discover that you should first add a day to the date in vanilla JavaScript. Then create a new date and add the month and year.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1680685161808/3076be60-78c0-418c-9d63-f877b088a0dd.png" alt class="image--center mx-auto" /></p>
<p>The funny thing was, it happened on the 31st day of the month. And there seem to be quirky things with Dates in JavaScript (as many of us know)</p>
<p>In the end, we got it fixed. But this shows you that if you're asking many questions, it will explain many things and eventually help resolve them.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-chatgpt-explains-a-piece-of-code">ChatGPT explains a piece of code</h2>
<p>As I work in a large codebase, developed and maintained by changing team members, the code can not always be as clear as you wish 😅.</p>
<p>ChatGPT got you covered on this as well.</p>
<p>This one is simple and helped me understand and re-write functionality much more simpler.</p>
<p>Just drop in a piece of the code and ask for an explanation. It's that simple 👍</p>
<p>Like in this example:</p>
<p><strong>Ask to explain</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1680684998917/1392afd7-a7b0-4c44-b383-5ff8a6e13c32.png" alt class="image--center mx-auto" /></p>
<p><img src="/images/chatgpt-ask-code-to-explain.png" alt /></p>
<p><strong>Answer</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1680685016680/0a81f79e-dcc1-4420-9f27-358846ec220f.png" alt class="image--center mx-auto" /></p>
<p><img src="/images/chatgpt-code-exaplain.png" alt /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-chatgpt-can-help-you-write-better-tests">ChatGPT can help you write better tests</h2>
<p>For many developers, writing tests for our code is a challenging task. After more than a decade of experience, it still keeps me wondering sometimes:</p>
<ul>
<li><p>What tests do I need?</p>
</li>
<li><p>How many test cases should I create?</p>
</li>
<li><p>Did I cover all the edge cases?</p>
</li>
<li><p>And many more</p>
</li>
</ul>
<p>Well, ChatGPT has got me covered as well.</p>
<p>Sometimes I use it to brainstorm and ask for additional test cases I missed.</p>
<p>It really helped my team and me, and I wrote better code for testing 💪</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-chatgpt-can-re-write-your-code-for-better-readability">ChatGPT can re-write your code for better readability</h2>
<p>Sometimes you find these code examples online and wonder how it works and if there is an easier way to write them.</p>
<p>Please drop in your code and ask it to re-write it for you. It's that simple and really helps!</p>
<h3 id="heading-example">Example</h3>
<p>Let's say we have a complex product structure in our API.</p>
<pre><code class="lang-json">{
  <span class="hljs-attr">"products"</span>: [
    {
      <span class="hljs-attr">"id"</span>: <span class="hljs-number">1</span>,
      <span class="hljs-attr">"name"</span>: <span class="hljs-string">"Product A"</span>,
      <span class="hljs-attr">"category"</span>: {
        <span class="hljs-attr">"id"</span>: <span class="hljs-number">10</span>,
        <span class="hljs-attr">"name"</span>: <span class="hljs-string">"Electronics"</span>,
        <span class="hljs-attr">"properties"</span>: {
          <span class="hljs-attr">"warranty"</span>: <span class="hljs-string">"1 year"</span>,
          <span class="hljs-attr">"returnPolicy"</span>: <span class="hljs-string">"30 days"</span>
        }
      },
      <span class="hljs-attr">"brand"</span>: {
        <span class="hljs-attr">"id"</span>: <span class="hljs-number">100</span>,
        <span class="hljs-attr">"name"</span>: <span class="hljs-string">"Brand X"</span>,
        <span class="hljs-attr">"properties"</span>: {
          <span class="hljs-attr">"country"</span>: <span class="hljs-string">"USA"</span>,
          <span class="hljs-attr">"established"</span>: <span class="hljs-string">"1995"</span>
        }
      },
      <span class="hljs-attr">"properties"</span>: {
        <span class="hljs-attr">"color"</span>: <span class="hljs-string">"black"</span>,
        <span class="hljs-attr">"weight"</span>: <span class="hljs-string">"1.2 kg"</span>
      }
    },
    {
      <span class="hljs-attr">"id"</span>: <span class="hljs-number">2</span>,
      <span class="hljs-attr">"name"</span>: <span class="hljs-string">"Product B"</span>,
      <span class="hljs-attr">"category"</span>: {
        <span class="hljs-attr">"id"</span>: <span class="hljs-number">11</span>,
        <span class="hljs-attr">"name"</span>: <span class="hljs-string">"Furniture"</span>,
        <span class="hljs-attr">"properties"</span>: {
          <span class="hljs-attr">"material"</span>: <span class="hljs-string">"wood"</span>,
          <span class="hljs-attr">"assemblyRequired"</span>: <span class="hljs-string">"yes"</span>
        }
      },
      <span class="hljs-attr">"brand"</span>: {
        <span class="hljs-attr">"id"</span>: <span class="hljs-number">101</span>,
        <span class="hljs-attr">"name"</span>: <span class="hljs-string">"Brand Y"</span>,
        <span class="hljs-attr">"properties"</span>: {
          <span class="hljs-attr">"country"</span>: <span class="hljs-string">"Germany"</span>,
          <span class="hljs-attr">"established"</span>: <span class="hljs-string">"2001"</span>
        }
      },
      <span class="hljs-attr">"properties"</span>: {
        <span class="hljs-attr">"dimensions"</span>: <span class="hljs-string">"100x50x30 cm"</span>,
        <span class="hljs-attr">"color"</span>: <span class="hljs-string">"brown"</span>
      }
    }
  ]
}
</code></pre>
<p>We want to sort the products based on the returnPolicy property. Another developed this function long ago; it's not easy to read, so we want to make it more readable and add TypeScript.</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">s</span>(<span class="hljs-params">p</span>)</span>{
  <span class="hljs-keyword">return</span> p.sort(<span class="hljs-function">(<span class="hljs-params">a,b</span>)=&gt;</span>a.category.properties.returnPolicy.localeCompare(b.category.properties.returnPolicy))
}
</code></pre>
<p>We can ask ChatGPT to make it more readable and add types. So this is the result it comes up with:</p>
<pre><code class="lang-ts"><span class="hljs-keyword">interface</span> Properties {
  returnPolicy?: <span class="hljs-built_in">string</span>;
  [key: <span class="hljs-built_in">string</span>]: <span class="hljs-built_in">any</span>;
}

<span class="hljs-keyword">interface</span> Category {
  id: <span class="hljs-built_in">number</span>;
  name: <span class="hljs-built_in">string</span>;
  properties: Properties;
}

<span class="hljs-keyword">interface</span> Product {
  id: <span class="hljs-built_in">number</span>;
  name: <span class="hljs-built_in">string</span>;
  category: Category;
  [key: <span class="hljs-built_in">string</span>]: <span class="hljs-built_in">any</span>;
}

<span class="hljs-comment">/**
 * Sort an array of products based on the "returnPolicy" property.
 * @param {Product[]} products - The array of products to be sorted.
 * @return {Product[]} - The sorted array of products.
 */</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">sortProductsByReturnPolicy</span>(<span class="hljs-params">products: Product[]</span>): <span class="hljs-title">Product</span>[] </span>{
  <span class="hljs-keyword">return</span> products.sort(<span class="hljs-function">(<span class="hljs-params">productA, productB</span>) =&gt;</span> {
    <span class="hljs-keyword">return</span> productA.category.properties.returnPolicy.localeCompare(
      productB.category.properties.returnPolicy
    );
  });
}
</code></pre>
<p>As you can see, it wrote a Product, Category, and generic Properties interface and applied it to the function. But also added some explicit comments to it.</p>
<p>So refactoring becomes a lot easier with ChatGPT!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<p>In short, ChatGPT can help developers in many ways. Whether you're just starting out or have been developing for years, ChatGPT can help you improve. This blog post provides seven tips for using ChatGPT, covering problem-solving and code readability. By using ChatGPT, you can write code faster and with fewer mistakes.</p>
<p>One of the best things about ChatGPT is that it can find errors in code. Even experienced developers make mistakes, and finding them can be tricky. ChatGPT makes it easy to find errors and fix them. ChatGPT can also help you explain what your code is doing and write better tests.</p>
<p>ChatGPT is also good at making code easier to read. Large codebases can be hard to maintain, primarily if the code needs better written. Using ChatGPT to improve code readability, you can make your code more accessible for other developers to understand.</p>
<p>One of the most powerful things about ChatGPT is that it can help developers work together better. Developers can work more effectively using ChatGPT to brainstorm solutions, find errors, and improve code quality. When combined with human experience, ChatGPT can help developers deliver better results and drive innovation.</p>
<p>In conclusion, ChatGPT is a valuable tool for developers of all levels. By following the tips in this blog post and using ChatGPT in your work, you can write better code, save time, and get better results. Whether you're a beginner or an expert, ChatGPT is worth exploring to see how it can help you and your team.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-thanks">Thanks!</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629789655319/nBF6anHH4w.png" alt="hashnode-footer.png" /></p>
<p><em>After reading this story, I hope you learned something new or are inspired to create something new! 🤗 If I left you with questions or something to say as a response, scroll down and type me a message, send me a</em> <a target="_blank" href="https://twitter.com/@devbyrayray"><em>DM on Twitter @DevByRayRay</em></a></p>
<p><em>Want to receive new posts in your mailbox? No, not only a link, just the whole article without any ads</em> 🤗 <em>or other stuff.</em> <a target="_blank" href="https://byrayraydev.substack.com/"><strong><em>Then subscribe to my newsletter</em></strong></a> <em>👍. I promise I won’t spam you, only the most important and best-quality content will be sent to you ✌️.</em></p>
<blockquote>
<p>Did you know that you can create a <a target="_blank" href="https://hashnode.com/@devbyrayray/joinme">Developer blog like this one, yourself</a>? It's entirely for free. 👍💰🎉🥳🔥</p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[ChatGPT + Bing = Awesome 🔥]]></title><description><![CDATA[Ladies and Gentlemen, hold on tight: the search game is about to change forever! Bing, the popular search engine, has just become even better with the integration of ChatGPT, and it's nothing short of extraordinary! In this blog post, we'll explore w...]]></description><link>https://hasnode.byrayray.dev/chatgpt-bing-awesome</link><guid isPermaLink="true">https://hasnode.byrayray.dev/chatgpt-bing-awesome</guid><category><![CDATA[AI]]></category><category><![CDATA[openai]]></category><category><![CDATA[Bing]]></category><category><![CDATA[Microsoft]]></category><dc:creator><![CDATA[Dev By RayRay]]></dc:creator><pubDate>Thu, 09 Feb 2023 15:46:36 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/ICdZeEGz-0I/upload/318968ff07564659fca1356238b072f6.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Ladies and Gentlemen, hold on tight: the search game is about to change forever! Bing, the popular search engine, has just become even better with the integration of ChatGPT, and it's nothing short of extraordinary! In this blog post, we'll explore why the combination of Bing and ChatGPT is a game-changer and how it will make your search experience even more impressive.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-chatgpt">ChatGPT</h2>
<p>ChatGPT is an advanced language model developed by OpenAI that understands natural language queries. It understands the context of your search and delivers precise, relevant results tailored to you. This makes it an excellent choice for search engines like Bing, as it eliminates the need to sift through irrelevant results and helps you find what you need more quickly.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-chatgpt-search-engine">ChatGPT + Search engine = 🔥</h2>
<p>Now, let's explore why this integration is so great! Firstly, ChatGPT understands the context of your search, so you'll get more relevant results. This means you don't need to waste time looking through irrelevant search results, and you can find what you need more quickly.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1675957445261/1f2e2ed7-2943-4f7d-b715-d56874f194ba.png" alt class="image--center mx-auto" /></p>
<p>One of the lovely details is that Bing will present the origin of the data it found. So it will still be valuable for us content creators to create that content.</p>
<p><mark>You can find some examples on the </mark> <a target="_blank" href="https://www.bing.com/new#examples"><mark>special Bing website</mark></a><mark>. Sadly enough, we still have to wait to try it out. But you can join </mark> <a target="_blank" href="https://www.bing.com/new"><mark>the waiting list</mark></a><mark>.</mark></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-qampa-in-bing">Q&amp;A in Bing</h2>
<p>The Bing + ChatGPT integration has an excellent Q&amp;A feature. You must type your question as if you were asking a friend, and ChatGPT will give you the best answer.</p>
<p>Bing is doing something unique by integrating ChatGPT into its search engine. It shows that the competition between search engines Bing and Google are getting tougher.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-search-engine-competition-war">Search engine competition war!</h2>
<p>Google should be worried. Bing and ChatGPT joining together give people a search engine that works better and is more personalized. ChatGPT can understand words people type in, give more exact results, and offer advice tailored to the person. This combination makes Bing + ChatGPT a serious threat to Google.</p>
<p>Furthermore, ChatGPT being incorporated into Bing shows a change in the search market towards more advanced and intelligent search experiences. As technology progresses, other search engines will likely do the same and add similar technology to their services. If Google does not keep up, it could be left behind in the search market and no longer be the leading search engine.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-nlp-in-search-engines-is-very-beneficial">NLP in search engines is very beneficial</h2>
<p>Last but not least, Bing + ChatGPT makes search simpler than ever. ChatGPT understands natural language queries, making it easy for everyone to get the answers they need, regardless of age, background, or tech knowledge. Teenagers who are tech-savvy and grandparents who are just beginning to explore search will find it easier to get the information they need.</p>
<p>If you want to see the presentation where ChatGPT gets introduced with Bing, check the Youtube video:</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://youtu.be/rOeRWRJ16yY">https://youtu.be/rOeRWRJ16yY</a></div>
<p> </p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In the end, adding ChatGPT to Bing is a game-changer that's making search even better. ChatGPT can understand natural language questions, give more exact results, and make the search easier. Bing + ChatGPT can take you on the most fantastic search journey ever! Why wait? Get ready to have a great time!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-thanks">Thanks!</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629789655319/nBF6anHH4w.png" alt="hashnode-footer.png" /></p>
<p><em>After reading this story, I hope you learned something new or are inspired to create something new! 🤗 If I left you with questions or something to say as a response, scroll down and type me a message, send me a</em> <a target="_blank" href="https://twitter.com/@devbyrayray"><em>DM on Twitter @DevByRayRay</em></a></p>
<p><em>Want to receive new posts in your mailbox? No, not only a link, just the whole article without any ads</em> 🤗 <em>or other stuff.</em> <a target="_blank" href="https://byrayraydev.substack.com/"><strong><em>Then subscribe to my newsletter</em></strong></a> <em>👍. I promise I won’t spam you, only the most important and best-quality content will be sent to you ✌️.</em></p>
<blockquote>
<p>Did you know that you can create a <a target="_blank" href="https://hashnode.com/@devbyrayray/joinme">Developer blog like this one, yourself</a>? It's entirely for free. 👍💰🎉🥳🔥</p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[Revolutionize Your Programming with AI, ChatGPT & GitHub Copilot]]></title><description><![CDATA[Are you a developer looking to stay ahead of the curve? Incorporating artificial intelligence (AI) into your work is no longer a luxury but necessary. This blog post will discuss the top five benefits of embracing AI and how it can revolutionize your...]]></description><link>https://hasnode.byrayray.dev/revolutionize-your-programming-with-ai-chatgpt-github-copilot</link><guid isPermaLink="true">https://hasnode.byrayray.dev/revolutionize-your-programming-with-ai-chatgpt-github-copilot</guid><category><![CDATA[AI]]></category><category><![CDATA[chatgpt]]></category><category><![CDATA[Developer]]></category><category><![CDATA[development]]></category><category><![CDATA[openai]]></category><dc:creator><![CDATA[Dev By RayRay]]></dc:creator><pubDate>Sun, 08 Jan 2023 14:15:25 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/OYzbqk2y26c/upload/5661bd84e246b21fc7b4236184e31b77.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Are you a developer looking to stay ahead of the curve? Incorporating artificial intelligence (AI) into your work is no longer a luxury but necessary. This blog post will discuss the top five benefits of embracing AI and how it can revolutionize your programming skills. Plus, we'll introduce you to a tool that makes it easy to use AI in your workflow. Don't get left behind – start incorporating AI into your projects today.</p>
<p><strong><em>Originally published on</em></strong> <a target="_blank" href="https://byrayray.dev/posts/2023-01-08-revolutionize-programming-ai-chatgpt-github-copilot"><strong><em>ByRayRay.dev</em></strong></a><strong><em>.</em></strong></p>
<p>For a few months, I've been investigating what AI can do for developers like myself. It took my interest when <a target="_blank" href="https://github.com/features/copilot">Github Copilot</a> was launched by Github. Then I didn't know that it was driven by a product called <a target="_blank" href="https://openai.com/blog/openai-codex/">OpenAI Codex</a>, which seems to be very powerful.</p>
<p>But especially since ChatGPT came by storm around November 2022, I'm incorporating it into my workflow. Because of that experience, I will predict the following.</p>
<blockquote>
<p><strong><em>Incorporating AI into your work as a developer is no longer optional. Those who refuse to adapt will eventually become obsolete as the industry moves forward with those who are utilizing AI to its full potential</em></strong></p>
</blockquote>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-tldr">TLDR;</h2>
<ul>
<li><p>Incorporating AI into your work as a developer is essential for staying competitive in the industry</p>
</li>
<li><p>AI can increase efficiency, enhance accuracy, improve decision-making, enhance collaboration, and future-proof your skills</p>
</li>
<li><p>GitHub Copilot is a tool that makes it easy to incorporate AI into your workflow</p>
</li>
<li><p>Don't get left behind – start using AI to revolutionize your programming skills today</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-ai-revolution-for-developers">AI Revolution For Developers</h2>
<p>AI will revolutionize the way we approach software development. It can help automate tasks, analyze data, and generate code. Incorporating AI into your work is seamless and straightforward with the right tools.</p>
<p>One such tool is GitHub Copilot, a plugin for your integrated development environment (IDE) that allows you to incorporate AI into your workflow easily. With GitHub Copilot, you can easily access AI models and incorporate them into your projects without leaving your IDE.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-5-reasons-why-developers-should-embrace-ai">5 Reasons Why Developers Should Embrace AI</h2>
<p>Last few years, there have been so many people saying that I would lose my job to AI. They predicted companies would no longer need developers because AI would all take over.</p>
<p>When you start using ChatGPT, you will soon find that you need to be specific in what you want. That's not the case. It would be best to tell it clearly and in-depth to get what you want.</p>
<p>Since most developers will know what they want and how to write the code or how the code should look, it's super helpful to let an AI help you as a coding buddy.</p>
<p>But beyond just the convenience factor, there are reasons why every programmer should embrace AI and incorporate it into their work. Here are five pros to consider:</p>
<ol>
<li><p>Efficiency: AI can automate tasks and processes and saves time for you to focus on more critical tasks.</p>
</li>
<li><p>Accuracy: AI can analyze data and make accurate decisions that humans may not be able to achieve on their own. For example, at this date, ChatGPT has data from the beginning of the internet until 2021. So all the things written since then are used to help you make decisions. (<strong><em>Yes, I know ChatGPT is not always giving the correct answer, but that will improve</em></strong>)</p>
</li>
<li><p>Improved Decision-Making: AI can help you make more informed decisions by providing insights and recommendations based on data analysis.</p>
</li>
<li><p>Enhanced Collaboration: AI can help teams collaborate more effectively by providing real-time analysis and insights.</p>
</li>
<li><p>Future-Proofing Your Skills: As AI advances, those familiar with it will have a competitive edge in the job market.</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-3-risks-of-not-using-ai-as-developers">3 Risks Of Not Using AI As Developers</h2>
<p>Of course, when there are good reasons to use AI as a developer, but there are also reasons why you shouldn't use it (yet). Let's discuss them.</p>
<ol>
<li><p>Initial Investment: Implementing AI into your workflow may require an initial investment in tools and resources. Right now, using Github Copilot requires a subscription of 100$ a month. In my opinion worth the money, but you can check it out for yourself with two months for free 👍</p>
</li>
<li><p>Complexity: AI can be complex and may require a learning curve to utilize its capabilities thoroughly. But to use AI in your flow, you don't need to learn all the details of AI. It's nice that you know some of the basics of how AI works. (this video by <a target="_blank" href="https://www.youtube.com/watch?v=5q87K1WaoFI">WIRED explains AI in 5 ways of difficult what machine learning is</a>. ML is the technology that helps AI learn from mistakes and improve problem-solving.)</p>
</li>
<li><p>Dependence on Technology: Relying on AI can create a dependence on technology, which could be problematic if it fails. So is relying on any technology we use in our life. It is also problematic if there is a bug in a Linux kernel, Visual Studio Code, Github actions, or the Azure servers we use for our pipelines. It's more problematic if the power goes off, but our civilization relies on technology daily.</p>
</li>
</ol>
<p>But after all, the pros of incorporating AI into our work as developers outweigh the cons. Better said, all these cons are things we should keep in mind and not real cons.</p>
<p>There is a higher risk if you are not using AI in your work. Because in the future, you will lose your job to developers embracing AI in their work.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-3-ideas-to-use-chatgpt-in-our-work">3 Ideas To Use ChatGPT In Our Work</h2>
<p>I already told you that Github Copilot is one way to use AI in your workflow as a developer. But I'm also using ChatGPT to help me explain things, give examples, and more. Here are a few ideas of what you can use.</p>
<h3 id="heading-1-ask-for-unit-tests">1. Ask For Unit Tests</h3>
<p>Ask to write a unit test for a particular piece of code and let it explain why it does it. For example, I gave a piece of code and asked to write a unit test for it with Jest. Yes, I could have done it myself, but this helped me to give an idea.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1673187000981/15f9c6e8-1179-4755-b243-a5600015a572.webp" alt class="image--center mx-auto" /></p>
<p>The answer was:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1673187020819/bb222a0b-f3fe-4f6a-8228-11d72e3d9629.webp" alt class="image--center mx-auto" /></p>
<h3 id="heading-2-ask-to-explain">2. Ask To Explain</h3>
<p>I asked ChatGPT to explain how to write a unit test for a BehaviourSubject in the RxJS library.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1673187044939/a5d8f44e-5a8b-4f22-bc66-442da3d510ff.webp" alt class="image--center mx-auto" /></p>
<p>The extensive answer was pretty good.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1673187068305/c7130487-259e-4ae8-bd68-14bea950c452.webp" alt class="image--center mx-auto" /></p>
<h3 id="heading-3-ask-to-do-certain-things">3. Ask To Do Certain Things</h3>
<p>I'm also frequently asking ChatGPT how I can do this or that. That is super useful. Because when you are going to Google the same thing, you have to scroll through so many results searching for that one clear example.</p>
<p>Here is an example:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1673187085034/af02ae17-e64e-4ede-b9a4-79833016c107.webp" alt class="image--center mx-auto" /></p>
<p>The answer:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1673187096199/d6fc7d7d-bb9b-4f68-8ff1-8f621faf7214.webp" alt class="image--center mx-auto" /></p>
<p>As you can see, this long answer helped my team and me a lot!</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>So don't be left behind. Embrace AI and see how it can benefit your work as a developer. Incorporating AI into your projects can be seamless and straightforward with the right tools and a willingness to learn.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-thanks">Thanks!</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629789655319/nBF6anHH4w.png" alt="hashnode-footer.png" /></p>
<p><em>After reading this story, I hope you learned something new or are inspired to create something new! 🤗 If I left you with questions or something to say as a response, scroll down and type me a message, send me a</em> <a target="_blank" href="https://twitter.com/@devbyrayray"><em>DM on Twitter @DevByRayRay</em></a></p>
<p><em>Want to receive new posts in your mailbox? No, not only a link, just the whole article without any ads</em> 🤗 <em>or other stuff.</em> <a target="_blank" href="https://byrayraydev.substack.com/"><strong><em>Then subscribe to my newsletter</em></strong></a> <em>👍. I promise I won’t spam you, only the most important and best-quality content will be sent to you ✌️.</em></p>
<blockquote>
<p>Did you know that you can create a <a target="_blank" href="https://hashnode.com/@devbyrayray/joinme">Developer blog like this one, yourself</a>? It's entirely for free. 👍💰🎉🥳🔥</p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[JavaScript Array Methods: A Beginner's Guide to includes()]]></title><description><![CDATA[The includes() method helps check whether an array contains a specific value. It is a simple and efficient way to validate if a value is in an array and can be particularly useful when working with large or complex data sets.
To use the includes() me...]]></description><link>https://hasnode.byrayray.dev/javascript-array-methods-a-beginners-guide-to-includes</link><guid isPermaLink="true">https://hasnode.byrayray.dev/javascript-array-methods-a-beginners-guide-to-includes</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[js]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[webdev]]></category><dc:creator><![CDATA[Dev By RayRay]]></dc:creator><pubDate>Fri, 30 Dec 2022 21:29:14 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/9ef3845f8d43419e70b63cff71ff9491.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The <code>includes()</code> method helps check whether an array contains a specific value. It is a simple and efficient way to validate if a value is in an array and can be particularly useful when working with large or complex data sets.</p>
<p>To use the <code>includes()</code> method, you call it on the array you want to search and pass in the value you are looking for as an argument. If the value is in the array, the <code>includes()</code> method will return a boolean value of <code>true</code>. If the value is not in the array, the <code>includes()</code> method will return <code>false</code>.</p>
<p><strong><em>Originally published on</em></strong> <a target="_blank" href="https://byrayray.dev/posts/2022-12-30-mastering-javascript-includes-array-method"><strong><em>ByRayRay.dev</em></strong></a><strong><em>.</em></strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-tldr">TLDR;</h2>
<p>For those that don't want to deep-dive into how to use the <code>includes()</code> method, here is the TLDR; 😉</p>
<ul>
<li><p>The <code>includes()</code> method is used to check if a value is in an array.</p>
</li>
<li><p>It returns a boolean value of <code>true</code> if the value is in the array and <code>false</code> if it is not.</p>
</li>
<li><p>You can pass in a second argument as the starting index to search for the value within a specific array range.</p>
</li>
<li><p>The <code>includes()</code> method is case-sensitive, so searching for an value with a different capitalization than it appears in the array will return <code>false</code>.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-search-for-a-value-in-a-javascript-array">Search for a value in a JavaScript array</h2>
<p>Let's dive into the code and see how to use the <code>includes()</code> method in JavaScript. Here is an example of how to use the <code>includes()</code> method:</p>
<p>%[https://runkit.com/devbyrayray/check-if-string-is-in-javascript-array-with-includes]</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-search-for-a-value-in-a-part-of-a-javascript-array">Search for a value in a part of a JavaScript array</h2>
<p>You can also use the <code>includes()</code> method to search for something inside a part of the array. To do this, you can give the <code>includes()</code> method a second number that tells it where to start looking. For example:</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://runkit.com/devbyrayray/search-for-a-value-in-a-part-of-a-javascript-array">https://runkit.com/devbyrayray/search-for-a-value-in-a-part-of-a-javascript-array</a></div>
<p> </p>
<p>Remember that the <code>includes()</code> method is picky about capital letters. If you want something spelled differently with capital letters, the <code>includes()</code> method will return <code>false</code>.</p>
<h2 id="heading-find-a-value-while-ignoring-the-case-sensitivity">Find a value while ignoring the case sensitivity</h2>
<p>There is an easy way to make the <code>includes()</code>method does not care about capital letters. We can use the <code>some()</code> method to look at each thing in the array. For each thing, we can use the <code>toLowerCase()</code>method to make all the letters lowercase. Then we can see if things are the same. For example:"</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://runkit.com/devbyrayray/find-a-value-while-ignoring-the-case-sensitivity-of-javascript-array-method-includes">https://runkit.com/devbyrayray/find-a-value-while-ignoring-the-case-sensitivity-of-javascript-array-method-includes</a></div>
<p> </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-advanced-scenarios-for-the-includes-method">Advanced scenario’s for the includes() method</h2>
<p>I wrote two real-world scenarios where the <code>includes()</code> method could be helpful. I hope you can use them for your situation.</p>
<h3 id="heading-filtering-a-list-of-email-addresses">Filtering a list of email addresses</h3>
<p>Imagine you have a list of email addresses you want to filter based on whether they contain a specific domain. You can use the <code>includes()</code> method to check if each email address contains the domain you are looking for and then add it to a new list if it does. For example:</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://runkit.com/devbyrayray/filtering-a-list-of-email-addresses">https://runkit.com/devbyrayray/filtering-a-list-of-email-addresses</a></div>
<p> </p>
<h3 id="heading-validating-user-input">Validating user input</h3>
<p>You have a form on your website where users can enter their zip codes. You can use the <code>includes()</code> method to check if the user's zip code is in a list of valid zip codes for your delivery area. For example:</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://runkit.com/devbyrayray/validating-user-input">https://runkit.com/devbyrayray/validating-user-input</a></div>
<p> </p>
<p>So whether you're trying to find a specific fruit in a list of fruits, check if someone's zip code is in the right place, or see which number appears the most in a list of numbers, the <code>includes()</code> the method can help you out. Remember to be careful about capital letters (unlike the <code>includes()</code> method) when you use it, and you'll be all set! Happy coding!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-thanks">Thanks!</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629789655319/nBF6anHH4w.png" alt="hashnode-footer.png" /></p>
<p><em>After reading this story, I hope you learned something new or are inspired to create something new! 🤗 If I left you with questions or something to say as a response, scroll down and type me a message, send me a</em> <a target="_blank" href="https://twitter.com/@devbyrayray"><em>DM on Twitter @DevByRayRay</em></a></p>
<p><em>Want to receive new posts in your mailbox? No, not only a link, just the whole article without any ads</em> 🤗 <em>or other stuff.</em> <a target="_blank" href="https://byrayraydev.substack.com/"><strong><em>Then subscribe to my newsletter</em></strong></a> <em>👍. I promise I won’t spam you, only the most important and best-quality content will be sent to you ✌️.</em></p>
<blockquote>
<p>Did you know that you can create a <a target="_blank" href="https://hashnode.com/@devbyrayray/joinme">Developer blog like this one, yourself</a>? It's entirely for free. 👍💰🎉🥳🔥</p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[How To Sum Total From Array Of Object Properties With JavaScript Reduce Method]]></title><description><![CDATA[Calculating the total price for your shopping cart was a hassle in the days before the JavaScript reduce method. In this post, I will show you how easy it is to use the reduce method to calculate the total price of a product array in the shopping car...]]></description><link>https://hasnode.byrayray.dev/how-to-sum-total-from-array-of-object-properties-with-javascript-reduce-method</link><guid isPermaLink="true">https://hasnode.byrayray.dev/how-to-sum-total-from-array-of-object-properties-with-javascript-reduce-method</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[javascript framework]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[webdev]]></category><dc:creator><![CDATA[Dev By RayRay]]></dc:creator><pubDate>Tue, 20 Dec 2022 08:44:08 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1671525807122/VXAnKf1Gj.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Calculating the total price for your shopping cart was a hassle in the days before the JavaScript <code>reduce</code> method. In this post, I will show you how easy it is to use the <code>reduce</code> method to calculate the total price of a product array in the shopping cart. The JavaScript <code>reduce</code> method is powerful and can calculate a total price based on an array of object properties.</p>
<p><strong><em>Originally published on</em></strong> <a target="_blank" href="https://byrayray.dev/posts/2022-12-19-sum-total-array-object-properties-javascript-reduce-method"><strong><em>ByRayRay.dev</em></strong></a><strong><em>.</em></strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-how-does-the-reduce-method-work">How does the reduce method work?</h2>
<p>The <code>reduce()</code> method in JavaScript is used to execute a function to each element in an array, resulting in a single output value. It operates on an array of elements, performing a computation on each element in the array and building up the result.</p>
<p>Here is the syntax for using the <code>reduce()</code> method:</p>
<pre><code class="lang-js">array.reduce(<span class="hljs-function">(<span class="hljs-params">accumulator, currentValue, currentIndex, array</span>) =&gt;</span> {
  <span class="hljs-comment">// code to be executed</span>
}, initialValue);
</code></pre>
<p>The <code>reduce()</code> method takes in a callback function as its first argument. This callback function is called for each element in the array and takes four parameters:</p>
<ul>
<li><p><code>accumulator</code>: This is the value returned in the final iteration. It starts with the initial value if provided or the first element of the array if no initial value is provided. And adds up every iteration.</p>
</li>
<li><p><code>currentValue</code>: This is the current element being processed in the array.</p>
</li>
<li><p><code>currentIndex</code> (<em>optional</em>): This is the index of the current item that is being processed in the array.</p>
</li>
<li><p><code>array</code> (<em>optional</em>): This is the array <code>reduce()</code> that was called upon.</p>
</li>
</ul>
<p>The callback function should return the updated value for the accumulator.</p>
<p>Here is a simple example of using <code>reduce()</code> to calculate all the numbers in an array:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> numbers = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>];

<span class="hljs-keyword">const</span> sum = numbers.reduce(<span class="hljs-function">(<span class="hljs-params">accumulator, currentValue</span>) =&gt;</span> {
  <span class="hljs-keyword">return</span> accumulator + currentValue;
}, <span class="hljs-number">0</span>);

<span class="hljs-built_in">console</span>.log(sum); <span class="hljs-comment">// 15</span>
</code></pre>
<p>Check <a target="_blank" href="https://runkit.com/devbyrayray/calculate-total-based-on-numbers-array-with-javascript-reduce">runkit example</a></p>
<p>In this example, the <code>reduce()</code> method is called on the <code>numbers</code> array and is passed a callback function that adds the accumulator and the current value. The initial value for the accumulator is 0.</p>
<p>The <code>reduce()</code> method iterates through the numbers in the array, starting with the first element, and applies the callback function to each element.</p>
<p>The returned value from the callback function becomes the new value for the accumulator, which is passed to the next iteration. This process continues until all elements in the array have been processed and the final value of the accumulator is returned.</p>
<p>Let's check how we can apply this to our product array of a fictional shopping cart.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-get-a-total-price-from-an-array-of-object-properties">Get a total price from an array of object properties</h2>
<p>Let's say you have an array of products in your shopping cart.</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> products = [
    {
      <span class="hljs-string">"price"</span>: <span class="hljs-number">10</span>,
      <span class="hljs-string">"title"</span>: <span class="hljs-string">"Item 1"</span>
    },
    {
      <span class="hljs-string">"price"</span>: <span class="hljs-number">20</span>,
      <span class="hljs-string">"title"</span>: <span class="hljs-string">"Item 2"</span>
    },
    {
      <span class="hljs-string">"price"</span>: <span class="hljs-number">30</span>,
      <span class="hljs-string">"title"</span>: <span class="hljs-string">"Item 3"</span>
    }
]
</code></pre>
<p>To calculate the prices, we first need an array of prices. We want to calculate the total price of our shopping cart. We can do that by using the <code>.map()</code> method. In the example below, we create a new array with only the prices of our products.</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> prices = shoppingCart.map(<span class="hljs-function">(<span class="hljs-params">product</span>) =&gt;</span> product.price)
</code></pre>
<p>After that, we can use that array to calculate the total price with the <code>reduce</code> method.</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> prices = shoppingCart.map(<span class="hljs-function">(<span class="hljs-params">product</span>) =&gt;</span> product.price)
<span class="hljs-keyword">const</span> total = prices.reduce(<span class="hljs-function">(<span class="hljs-params">acc, curr</span>) =&gt;</span> acc + curr)

<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'total: '</span>, total )
</code></pre>
<p>We can also write this shorter and chain the <code>map()</code> and <code>reduce()</code> methods.</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> totalPrice = shoppingCart.reduce(<span class="hljs-function">(<span class="hljs-params">acc, curr</span>) =&gt;</span> acc + curr.price, <span class="hljs-number">0</span>)

<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'total: '</span>, totalPrice )
</code></pre>
<p>Check <a target="_blank" href="https://runkit.com/devbyrayray/calculate-total-price-from-javascript-array-of-product-objects">runkit example</a></p>
<p>That was easy. 👍</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-thanks">Thanks!</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629789655319/nBF6anHH4w.png" alt="hashnode-footer.png" /></p>
<p><em>After reading this story, I hope you learned something new or are inspired to create something new! 🤗 If I left you with questions or something to say as a response, scroll down and type me a message, send me a</em> <a target="_blank" href="https://twitter.com/@devbyrayray"><em>DM on Twitter @DevByRayRay</em></a></p>
<p><em>Want to receive new posts in your mailbox? No, not only a link, just the whole article without any ads</em> 🤗 <em>or other stuff.</em> <a target="_blank" href="https://byrayraydev.substack.com/"><strong><em>Then subscribe to my newsletter</em></strong></a> <em>👍. I promise I won’t spam you, only the most important and best-quality content will be sent to you ✌️.</em></p>
<blockquote>
<p>Did you know that you can create a <a target="_blank" href="https://hashnode.com/@devbyrayray/joinme">Developer blog like this one, yourself</a>? It's entirely for free. 👍💰🎉🥳🔥</p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[Mastering The JavaScript Find() Method]]></title><description><![CDATA[Searching specific values in arrays is easy with the JavaScript find() method. It doesn't matter if you want to find a string, number, boolean, or property of an object in an array. In this post, I will show you how to find values very easily.
Origin...]]></description><link>https://hasnode.byrayray.dev/mastering-the-javascript-find-method</link><guid isPermaLink="true">https://hasnode.byrayray.dev/mastering-the-javascript-find-method</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[webdev]]></category><category><![CDATA[Developer]]></category><dc:creator><![CDATA[Dev By RayRay]]></dc:creator><pubDate>Wed, 14 Dec 2022 09:59:42 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1671010802757/aW6PFq8ho.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Searching specific values in arrays is easy with the JavaScript <code>find()</code> method. It doesn't matter if you want to find a <code>string</code>, <code>number</code>, <code>boolean</code>, or property of an object in an array. In this post, I will show you how to find values very easily.</p>
<p><strong><em>Originally published on</em></strong> <a target="_blank" href="https://byrayray.dev/posts/2022-12-14-mastering-javascript-find-array-method"><strong><em>ByRayRay.dev</em></strong></a><strong><em>.</em></strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-the-find-method">The find() method</h2>
<p>The <code>find()</code> Array method in JavaScript is super easy to use. The method returns the first item in the array that matches your condition. (<a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find">check the documentation on MDN Web Docs</a>)</p>
<p>In the find method, you pass an Arrow function with a parameter that will be equal to each item in the array. Internally the <code>find()</code> method will loop through all the items in the array trying to find your search value.</p>
<p>In the arrow function, we check if <code>student</code> is equal to 'Jake' or 'Rob'. It will return the string immediately when the value is found. It will return <code>undefined</code> when the value isn't found.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-find-a-string-in-an-array">Find a string in an array</h2>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> students = [
    <span class="hljs-string">'Jake'</span>,
    <span class="hljs-string">'Ray'</span>,
    <span class="hljs-string">'Lisa'</span>,
    <span class="hljs-string">'Isabella'</span>,
    <span class="hljs-string">'Tom'</span>,
    <span class="hljs-string">'Kevin'</span>,
    <span class="hljs-string">'Armin'</span>
]

students.find(<span class="hljs-function">(<span class="hljs-params">student</span>) =&gt;</span> student === <span class="hljs-string">'Jake'</span>); <span class="hljs-comment">// Returns 'Jake'</span>
students.find(<span class="hljs-function">(<span class="hljs-params">student</span>) =&gt;</span> student === <span class="hljs-string">'Rob'</span>); <span class="hljs-comment">// Returns undefined</span>
</code></pre>
<p><em>Check</em> <a target="_blank" href="https://runkit.com/devbyrayray/how-to-find-string-in-javascript-array-with-find-method"><em>runkit example</em></a><em>.</em></p>
<p>Now we are searching for 'Jake' in the <code>students</code> array. This method will return 'Jake' when it is found. When we search for 'Rob', it will return <code>undefined</code> because 'Rob' is not in the array.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-find-a-number-in-an-array">Find a number in an array</h2>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> numbers = [
    <span class="hljs-number">5000</span>,
    <span class="hljs-number">538</span>,
    <span class="hljs-number">78123</span>,
    <span class="hljs-number">2</span>,
    <span class="hljs-number">45</span>,
    <span class="hljs-number">34097</span>
]

numbers.find(<span class="hljs-function">(<span class="hljs-params">number</span>) =&gt;</span> number === <span class="hljs-number">538</span>); <span class="hljs-comment">// Returns '538'</span>
numbers.find(<span class="hljs-function">(<span class="hljs-params">number</span>) =&gt;</span> number === <span class="hljs-number">1</span>); <span class="hljs-comment">// Returns undefined</span>
</code></pre>
<p><em>Check</em> <a target="_blank" href="https://runkit.com/devbyrayray/how-to-find-number-in-javascript-array-with-find-method"><em>runkit example</em></a><em>.</em></p>
<p>Now we are searching for <code>538</code> in the <code>numbers</code> array. This method will return <code>538</code> when it is found. When we search for <code>1</code> it will return <code>undefined</code> because <code>1</code> is not in the array.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-find-an-object-property-value-in-the-array">Find an object property value in the array.</h2>
<p>When you want to find a property value in an array of objects, it is as easy as with singular values. In the example below, we try to find the first project with the type of 'development'. With the second example, we try to find a project where '2024-01-27' is between the <code>startDate</code> and the <code>endDate</code>.</p>
<blockquote>
<p>A few years ago, I created a package is-between-js for my personal usage. You can calculate if a specific value is between a minimal and a maximum number. You are free to use it <a target="_blank" href="https://www.npmjs.com/package/is-between-js">because it's free on NPM</a> and <a target="_blank" href="https://github.com/devbyray/is-between-js">GitHub</a> 😉</p>
</blockquote>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> { isBetween } <span class="hljs-keyword">from</span> <span class="hljs-string">"is-between-js"</span>;
<span class="hljs-keyword">const</span> dateNumber = <span class="hljs-function">(<span class="hljs-params">date</span>) =&gt;</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(date).getTime();

<span class="hljs-keyword">const</span> projects = [
    {
        <span class="hljs-attr">startDate</span>: <span class="hljs-string">'2022-11-26'</span>,
        <span class="hljs-attr">endDate</span>: <span class="hljs-string">'2023-11-26'</span>,
        <span class="hljs-attr">title</span>: <span class="hljs-string">'Build an API'</span>,
        <span class="hljs-attr">type</span>: <span class="hljs-string">'Development'</span>,
    },
  {
        <span class="hljs-attr">startDate</span>: <span class="hljs-string">'2022-11-26'</span>,
        <span class="hljs-attr">endDate</span>: <span class="hljs-string">'2023-11-26'</span>,
        <span class="hljs-attr">title</span>: <span class="hljs-string">'Build Frontend'</span>,
        <span class="hljs-attr">type</span>: <span class="hljs-string">'Development'</span>
    },
  {
        <span class="hljs-attr">startDate</span>: <span class="hljs-string">'2023-03-05'</span>,
        <span class="hljs-attr">endDate</span>: <span class="hljs-string">'2024-03-26'</span>,
        <span class="hljs-attr">title</span>: <span class="hljs-string">'Create marketing content'</span>,
        <span class="hljs-attr">type</span>: <span class="hljs-string">'Marketing'</span>
    },
  {
        <span class="hljs-attr">startDate</span>: <span class="hljs-string">'2022-11-26'</span>,
        <span class="hljs-attr">endDate</span>: <span class="hljs-string">'2024-03-26'</span>,
        <span class="hljs-attr">title</span>: <span class="hljs-string">'Project management'</span>,
        <span class="hljs-attr">type</span>: <span class="hljs-string">'Management'</span>
    },
]

<span class="hljs-built_in">console</span>.log(projects.find(<span class="hljs-function">(<span class="hljs-params">project</span>) =&gt;</span> project.type.toLowerCase() === <span class="hljs-string">'development'</span>))
<span class="hljs-built_in">console</span>.log(projects.find(<span class="hljs-function">(<span class="hljs-params">project</span>) =&gt;</span> isBetween(dateNumber(<span class="hljs-string">'2024-01-27'</span>)).min(dateNumber(project.startDate)).max(dateNumber(project.endDate)).calc()))
</code></pre>
<p><em>Check</em> <a target="_blank" href="https://runkit.com/devbyrayray/find-a-object-property-value-in-a-javascript-array"><em>runkit example</em></a><em>.</em></p>
<p>You can check if a property value equals a value by returning this with the arrow function <code>project.type === 'value'</code>. In this case, we modify the string to lowercase characters in the example above to match even though the capitalization isn't equal.</p>
<p>In the example above, we compare a few property values in the isBetween function, which returns a boolean to the find method. It's that easy!</p>
<p>As you've seen, you can find values of every data type in a JavaScript array. It is not difficult to learn JavaScript; just practice, practice, and practice 👍</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-thanks">Thanks!</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629789655319/nBF6anHH4w.png" alt="hashnode-footer.png" /></p>
<p><em>After reading this story, I hope you learned something new or are inspired to create something new! 🤗 If so, consider subscribing via email (scroll to the top of this page) or follow me here on Hashnode.</em></p>
<blockquote>
<p>Did you know that you can create a <a target="_blank" href="https://hashnode.com/@devbyrayray/joinme">Developer blog like this one, yourself</a>? It's entirely for free. 👍💰🎉🥳🔥</p>
</blockquote>
<p><em>If I left you with questions or something to say as a response, scroll down and type me a message. Please send me a</em> <a target="_blank" href="https://twitter.com/@devbyrayray"><em>DM on Twitter @DevByRayRay</em></a> <em>when you want to keep it private. My DM's are always open 😁</em></p>
]]></content:encoded></item><item><title><![CDATA[Why Use TypeScript For JavaScript Development Today]]></title><description><![CDATA[TypeScript is an open-source programming language developed and maintained by Microsoft. It is a typed superset of JavaScript, which means that all JavaScript code is valid TypeScript code, but TypeScript adds some additional features that make it ea...]]></description><link>https://hasnode.byrayray.dev/why-use-typescript-for-javascript-development-today</link><guid isPermaLink="true">https://hasnode.byrayray.dev/why-use-typescript-for-javascript-development-today</guid><category><![CDATA[TypeScript]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Developer]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[webdev]]></category><dc:creator><![CDATA[Dev By RayRay]]></dc:creator><pubDate>Thu, 08 Dec 2022 10:55:01 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1670496534728/JHknEpLyV.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>TypeScript is an open-source programming language developed and maintained by Microsoft. It is a typed superset of JavaScript, which means that all JavaScript code is valid TypeScript code, but TypeScript adds some additional features that make it easier to write and maintain large and complex codebases.</p>
<p><strong>One of the main reasons why TypeScript is essential is that it allows developers to add type annotations to their code. This means they can specify the data type of variables, function arguments, and return values, which can help prevent many common bugs and make the code easier to read and understand.</strong></p>
<p><em>Originally published on</em> <a target="_blank" href="https://byrayray.dev/posts/2022-12-08-why-use-typescript-for-javascript-development"><strong><em>ByRayRay.dev</em></strong></a><strong><em>.</em></strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-function-without-types">Function without types</h2>
<p>For example, consider the following JavaScript code:</p>
<pre><code class="lang-typescript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">add</span>(<span class="hljs-params">x, y</span>) </span>{
    <span class="hljs-keyword">return</span> x + y;
}

<span class="hljs-keyword">const</span> result = add(<span class="hljs-number">1</span>, <span class="hljs-string">"2"</span>);
</code></pre>
<p>In this code, the add function is supposed to add two numbers, but because JavaScript is a dynamically typed language, it will silently try to convert the string "2" to a number and then add it to 1, producing the wrong result. This can be very difficult to debug, especially in large and complex codebases.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-function-with-types">Function with types</h2>
<p>With TypeScript, we can add type annotations to the add function to specify that it takes two numbers as arguments and returns a number:</p>
<pre><code class="lang-typescript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">add</span>(<span class="hljs-params">x: <span class="hljs-built_in">number</span>, y: <span class="hljs-built_in">number</span></span>): <span class="hljs-title">number</span> </span>{
    <span class="hljs-keyword">return</span> x + y;
}

<span class="hljs-keyword">const</span> result = add(<span class="hljs-number">1</span>, <span class="hljs-string">"2"</span>); <span class="hljs-comment">// This will cause an error</span>
</code></pre>
<p>Now, if we try to pass a string as the second argument to the add function, the TypeScript compiler will give us an error, alerting us to the fact that there is a bug in our code. This can save us a lot of time and frustration, and it can help ensure that our code is correct and free of bugs.</p>
<p>Another reason why TypeScript is important is that it provides many features that are not available in vanilla JavaScript. For example, TypeScript supports classes, interfaces, and modules, which can help us organize our code more logically and maintainable way. It also supports type inference, which can automatically infer the types of variables and expressions based on the context in which they are used. This can save us a lot of time and effort, and it can make our code more concise and readable.</p>
<p>Overall, TypeScript is a valuable tool for writing great and readable JavaScript code. It allows us to add type annotations to our code, which can help prevent bugs and make the code easier to understand. It also provides additional features unavailable in vanilla JavaScript, which can help us write more modular and maintainable code. If you are working on a large or complex JavaScript project, it is worth considering using TypeScript.</p>
<blockquote>
<p>If you want to start learning TypeScript today? I wrote a great post "<a target="_blank" href="https://byrayray.dev/posts/2020-04-07-typescript-for-beginners-97b568d3e110"><strong>TypeScript for beginners</strong></a>" where I teach how you can use all the essential parts of TypeScript. As an example I use 🍕😅</p>
</blockquote>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629890886208/NhHYvPmBA.png" alt="divider-byrayray.png" /></p>
<h2 id="heading-thanks">Thanks!</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1629789655319/nBF6anHH4w.png" alt="hashnode-footer.png" /></p>
<p><em>After reading this story, I hope you learned something new or are inspired to create something new! 🤗 If so, consider subscribing via email (scroll to the top of this page) or follow me here on Hashnode.</em></p>
<blockquote>
<p>Did you know that you can create a <a target="_blank" href="https://hashnode.com/@devbyrayray/joinme">Developer blog like this one, yourself</a>? It's entirely for free. 👍💰🎉🥳🔥</p>
</blockquote>
<p><em>If I left you with questions or something to say as a response, scroll down and type me a message. Please send me a</em> <a target="_blank" href="https://twitter.com/@devbyrayray"><em>DM on Twitter @DevByRayRay</em></a> <em>when you want to keep it private. My DM's are always open 😁</em></p>
]]></content:encoded></item></channel></rss>