<?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[RSS Feed]]></title><description><![CDATA[Software Engineer and Technical Writer crafting pixel-perfect digital experiences with accessibility at the core. Beyond code, she’s a poet who turns fleeting moments into words.]]></description><link>https://chiamakaikeanyi.dev</link><generator>GatsbyJS</generator><lastBuildDate>Mon, 19 Jan 2026 17:19:25 GMT</lastBuildDate><item><title><![CDATA[2025, A Year In My Life]]></title><description><![CDATA[In 2025, I learned the quiet power of slowing down.
Not as an act of giving up, but as a deliberate choice—to choose myself, to stop…]]></description><link>https://chiamakaikeanyi.dev/2025-a-year-in-my-life/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/2025-a-year-in-my-life/</guid><pubDate>Thu, 01 Jan 2026 08:00:00 GMT</pubDate><content:encoded>&lt;p&gt;In 2025, I learned the quiet power of slowing down.
Not as an act of giving up, but as a deliberate choice—to choose myself, to stop sprinting toward imaginary finish lines, and to trust consistency over intensity.&lt;/p&gt;
&lt;p&gt;This was not a loud year.
It was a grounding one.&lt;/p&gt;
&lt;h2&gt;Moments That Mattered&lt;/h2&gt;
&lt;p&gt;One of the clearest reflections of this shift showed up in my work. I redesigned my personal website; this website you&apos;re currently on—not just a visual refresh, but a structural rethink. Cleaner, calmer, more intentional. I created space for both sides of me to coexist: the developer and the creative. The subtle Dev vs. Creative mode wasn’t a gimmick; it was an acknowledgment that I don’t need to flatten myself to fit into one box.&lt;/p&gt;
&lt;p&gt;At work, I also introduced ideas I’m genuinely proud of. I worked on interesting projects, with the highlights being the Listing Availability Calendar, Neighbourhood highlights and a company-wide AI hackathon in collaboration with Google.&lt;/p&gt;
&lt;p&gt;Another moment asked me to step forward. I was featured in &lt;a href=&quot;https://www.youtube.com/watch?v=OyuXSJ9pG6M&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Easy German video&lt;/a&gt;—something I had previously talked myself out of. The first time a friend told me about the meetup, I said no, convinced I wasn’t “good enough” to speak German on camera. The second time, I said yes.
Was I nervous? Absolutely.
Could I have spoken better without a camera pointed at me? Definitely.
But I showed up anyway. And that mattered more.
I learned that courage doesn’t always feel brave; sometimes it just feels like not backing out.&lt;/p&gt;
&lt;p&gt;When it comes to language learning, February marked the completion of my Duolingo lessons, and July brought a bigger milestone: finishing German B2. With that came a decision—I’m done with traditional classroom learning. From here on, I’ll continue learning passively, through conversations, media, and daily life. One clear takeaway from using Duolingo is that it works best not as a sole learning tool, but as a way to reinforce existing knowledge and gradually expand vocabulary.&lt;/p&gt;
&lt;p&gt;Another grounding moment came in the form of permanence: receiving my German Permanent Residency (Niederlassungserlaubnis). It was more than paperwork. It was a sense of belonging—of roots quietly growing beneath the surface.&lt;/p&gt;
&lt;p&gt;I also spent less time on social media—a small change with an outsized impact. My mind felt clearer. My attention returned. I was reminded that not everything needs commentary. And somewhere in between all this, I started a new chapter - a subtle shift that simply felt right.&lt;/p&gt;
&lt;p&gt;Travel added texture to the year. Copenhagen (for a second time), Malmö, Paris—and a constellation of German cities: Leipzig (for the third time), Frankfurt (Oder), Cologne, Düsseldorf, Bonn, Hamburg (for a second time), and Bremen. Each place reminded me that movement widens one&apos;s perspective.&lt;/p&gt;
&lt;p&gt;Aside from Amsterdam, Copenhagen is the second city where I noticed people gorgeously dressed in suits while cycling. In the city center, I couldn’t help but notice Tivoli everywhere—from Tivoli Gardens to Tivoli Park and even the food court.&lt;/p&gt;
&lt;p&gt;Paris, on the other hand, taught me that it isn’t always what it’s imagined to be. Trains get overcrowded, movement isn’t easy for people carrying baby strollers due to narrow train station barriers, and many stations require long climbs up and down staircases without escalators or elevators to fall back on. It also wasn’t possible to get a multi-day tourist pass, which meant paying a new fare each time one exited and re-entered a station or boarded a bus. A ticket agent mentioned that the city has phased out paper tickets, leaving tourists with a paid Île-de-France plastic card instead.
Still, some of the sights like Eiffel tower, Montmartre, Notre-Dame Cathedral, Louvre etc. made the trip worthwhile.&lt;/p&gt;
&lt;p&gt;At Bremen’s market square, I saw a reminder of The Bremen Town Musicians, the German fairy tale by the Brothers Grimm—a small but meaningful moment of cultural familiarity.&lt;/p&gt;
&lt;h2&gt;Conscious Non-Choices&lt;/h2&gt;
&lt;p&gt;I didn’t prepare for or write German C1. The motivation faded, and I let it go instead of forcing it. I didn’t enroll in driving school either—the timing didn’t feel right. Getting a German driver’s license as a first-time applicant can cost anywhere between €2,500 and €5,000 or more, depending on school rates and how many times the exam needed to be repeated. And I didn’t exercise as consistently as I promised myself I would, but I found other ways to stay active—like completing a 19.2 km group hike.&lt;/p&gt;
&lt;p&gt;These weren’t failures so much as negotiations with my energy and priorities.
Letting some goals rest made space for others to breathe.&lt;/p&gt;
&lt;h2&gt;What This Year Taught Me&lt;/h2&gt;
&lt;p&gt;This year showed me that progress doesn’t have to be dramatic to be real. That choosing myself sometimes looks like saying no, slowing down, or stopping halfway and deciding that’s enough—for now.&lt;/p&gt;
&lt;p&gt;I learned that consistency doesn’t shout.
It whispers.
It shows up quietly, again and again, without demanding applause.&lt;/p&gt;
&lt;h2&gt;Looking Ahead&lt;/h2&gt;
&lt;p&gt;At the end of 2026, I want to be able to say this:
I kept my life simple, stayed fit, made more meaningful connections, and set my priorities clear.&lt;/p&gt;
&lt;p&gt;If 2025 was about grounding, then 2026 will be about building—carefully, intentionally, and without losing myself in the process.&lt;/p&gt;
&lt;p&gt;Here’s to living—not rushing the years ahead. 🥂✨&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Accessibility as Core Architecture]]></title><description><![CDATA[Your product isn’t done without accessibility.
If accessibility isn’t considered from the start, someone is being excluded by default…]]></description><link>https://chiamakaikeanyi.dev/accessibility-as-core-architecture/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/accessibility-as-core-architecture/</guid><pubDate>Tue, 30 Dec 2025 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Your product isn’t done without accessibility.
If accessibility isn’t considered from the start, someone is being excluded by default.
Accessibility is a right, not a privilege.&lt;/p&gt;
&lt;p&gt;Yet accessibility is often treated like a checklist item — something to “add later.” A feature to ship after the &quot;real work&quot; is done, or a compliance task to rush through.&lt;/p&gt;
&lt;p&gt;That mindset is flawed.
Features are optional. Accessibility isn’t.&lt;/p&gt;
&lt;h2&gt;Imagine this Scenario&lt;/h2&gt;
&lt;p&gt;A user opens your web app to make a booking. They navigate using the keyboard instead of a mouse. Suddenly, they’re stuck. Focus jumps unpredictably, and there’s no clear way forward.&lt;/p&gt;
&lt;p&gt;At the same time, another user tries to read a thought-provoking article you just published — using a screen reader. The content isn’t readable; headings aren’t announced correctly. Navigation is confusing.&lt;/p&gt;
&lt;p&gt;The feature technically works.
But for these users, your product is unusable.
That’s real revenue lost due to negligence.
This is what happens when accessibility is treated as an afterthought.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;In Germany alone, around 7.9 million people have a recognized severe disability, amounting to roughly 9–10 % of the population — many of whom may rely on keyboards, screen readers, or alternative input methods to access the web and may experience barriers on many digital interfaces. - &lt;a href=&quot;https://www.destatis.de/DE/Themen/Gesellschaft-Umwelt/Gesundheit/Behinderte-Menschen/_inhalt.html&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Destatis&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;If a user can’t navigate your app with a keyboard, understand content with a screen reader, or interact with UI elements clearly, the product is broken for them.
That’s not missing functionality, that’s exclusion.&lt;/p&gt;
&lt;h2&gt;What Accessibility Really Means&lt;/h2&gt;
&lt;p&gt;Accessibility means designing and building products that everyone can use, including people with:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Visual impairments&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Hearing loss&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Motor limitations&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Cognitive differences&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Temporary disabilities (like a broken arm)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Situational constraints (bright sunlight, noisy environments, slow devices)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Accessibility isn’t about edge cases.
It’s about real people, in real situations every day.&lt;/p&gt;
&lt;h2&gt;Legal and Business Reality&lt;/h2&gt;
&lt;p&gt;Accessibility isn’t just ethical, it’s practical.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Many regions enforce accessibility standards (like WCAG)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Lawsuits over inaccessible websites are increasing.&lt;br/&gt;
1,202 digital accessibility-related lawsuits were filed in the United States in 2024. (Source: &lt;a href=&quot;https://www.accessibility.com/complete-report-2024-website-accessibility-lawsuits&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Accessibility.com&lt;/a&gt;)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Public sector and enterprise clients require compliance&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Excluding users means losing customers&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Building accessibility from the start reduces legal risk and expands your audience.&lt;/p&gt;
&lt;h2&gt;What Accessibility Means for Developers&lt;/h2&gt;
&lt;p&gt;For developers, accessibility shows up in everyday decisions. It starts with choosing the right elements.
These decisions shape how components are built and how users experience your application.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Using semantic HTML instead of div-heavy markup&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Making sure all interactions work with a keyboard&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Labeling inputs and buttons clearly&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Managing focus when content changes&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Providing meaningful error messages. &lt;br/&gt;
Avoid hiding error messages with &lt;code class=&quot;language-text&quot;&gt;display: none&lt;/code&gt; — use conditional rendering or visibility&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Valid input state --&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Email&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Invalid input state  --&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Email&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;aria-invalid&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;true&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;aria-describedby&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email-error&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email-error&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;error&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Please enter a valid email address&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Notice that aria- wasn&apos;t needed in the valid input state. Native HTML already solves keyboard interaction, focus behavior and screen reader announcements.&lt;/p&gt;
&lt;h2&gt;The “ARIA Everywhere” Trap&lt;/h2&gt;
&lt;p&gt;When accessibility issues surface, a common reaction is to add ARIA attributes everywhere.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;button&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;tabindex&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;0&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-label&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Submit form&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Submit&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This often feels like progress, but it usually isn’t.&lt;/p&gt;
&lt;p&gt;ARIA is not a replacement for semantic HTML. Misusing it can actually make accessibility worse by overriding native browser behavior or confusing screen readers.&lt;/p&gt;
&lt;p&gt;The first rule of ARIA is simple:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Don’t use ARIA if native HTML already does the job.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;The Real Cost of Adding Accessibility Later&lt;/h2&gt;
&lt;p&gt;When accessibility is postponed, it becomes expensive and fragile.&lt;/p&gt;
&lt;p&gt;Teams end up:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Rewriting components that weren’t built semantically&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Refactoring layouts to support keyboard navigation&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Patching issues to meet compliance deadlines&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Introducing regressions while fixing basic flows&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This creates accessibility debt - technical debt that directly impacts users.
Just like performance or security, accessibility is hardest to fix after the foundation is already laid.&lt;/p&gt;
&lt;h2&gt;Accessibility Improves Products for Everyone&lt;/h2&gt;
&lt;p&gt;Accessible products are better products.
Here’s the part many teams miss:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Clear headings help screen readers and skimming users&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Good color contrast improves readability for everyone&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Keyboard navigation benefits power users&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Descriptive error messages reduce support tickets&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Simple language improves comprehension across cultures&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Accessibility forces clarity, and clarity makes systems stronger.&lt;/p&gt;
&lt;h2&gt;Accessibility as Core Architecture&lt;/h2&gt;
&lt;p&gt;Accessibility decisions shape architecture from the start:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;How focus and state are managed&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;How layouts adapt and respond&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;How interactions are announced to assistive technologies.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These are foundational choices. Treating accessibility as core architecture ensures inclusive behavior is built in, not bolted on.&lt;/p&gt;
&lt;p&gt;Accessibility also isn’t owned by one role. It’s a shared responsibility:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Designers ensure clarity, contrast, and structure&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Developers use semantic HTML and accessible components&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Product teams prioritize inclusive user flows&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Leaders set accessibility as a non-negotiable standard&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When everyone owns it, accessibility becomes natural, not forced.&lt;/p&gt;
&lt;h2&gt;Final Thought&lt;/h2&gt;
&lt;p&gt;Accessibility is not a feature to add later.&lt;/p&gt;
&lt;p&gt;It’s the foundation for building software that works for everyone — keyboard users, screen reader users, mobile users, and people facing temporary or situational limitations.&lt;/p&gt;
&lt;p&gt;Start with it, design for it and ship with it, because inclusion should never be optional.
&lt;br/&gt;
Read my article on &lt;a href=&quot;/building-accessible-web-apps/&quot;&gt;Building Accessible Web Apps&lt;/a&gt; to learn more.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[How toSorted() Crashed Our Web App - And How We Fixed It]]></title><description><![CDATA[A few weeks ago, we ran into an unexpected issue that caused our Listing Availabilty page to crash for some landlords. This is the story of…]]></description><link>https://chiamakaikeanyi.dev/how-toSorted-function-crashed-our-web-app/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/how-toSorted-function-crashed-our-web-app/</guid><pubDate>Thu, 25 Sep 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;A few weeks ago, we ran into an unexpected issue that caused our Listing Availabilty page to crash for some landlords. This is the story of how a modern convenience bit us in the back, how we identified the culprit, and what we did to fix it.&lt;/p&gt;
&lt;h2&gt;What Happened&lt;/h2&gt;
&lt;p&gt;In modern JavaScript, Array.prototype.toSorted() is a safer alternative to Array.prototype.sort(). Unlike &lt;code class=&quot;language-text&quot;&gt;sort()&lt;/code&gt;, which mutates the original array, &lt;code class=&quot;language-text&quot;&gt;toSorted()&lt;/code&gt; returns a new, sorted copy of the array.&lt;/p&gt;
&lt;p&gt;That immutability is a big win for avoiding side effects in functional programming. Naturally, we introduced it in a recent pull request.&lt;/p&gt;
&lt;p&gt;We had a block of code that looked like this:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; sortedBlocks &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; blocks&lt;span class=&quot;token operator&quot;&gt;?.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;toSorted&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;sortByCreatedDateDescending&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;But here’s the catch:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;toSorted&lt;/code&gt; is part of the ECMAScript 2023 specification.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Many older browsers, and even some users on slightly outdated versions of Chrome, Firefox or Safari, don’t support it.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;So when those users hit our page, their browsers threw an error and the page broke.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;How We Discovered the Issue&lt;/h2&gt;
&lt;p&gt;Everything worked fine in development, staging, and production environments when we tried to reproduce it on our machines. This led us to question what could be peculiar to the landlord.&lt;/p&gt;
&lt;p&gt;We decided to figure out the issue using Rollbar (our error monitoring tool); at first, I filtered using &lt;code class=&quot;language-text&quot;&gt;email:&quot;...&quot;&lt;/code&gt; to see the errors this specific user encountered within the timeframe the bug was reported and then I saw:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;TypeError: e.toSorted is not a function&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Digging deeper with Rollbar occurrences tab, I saw that about 25 other landlords face this issue which was supposedly meant to be low priority since we initially assumed based on the bug report that only one landlord experience it.&lt;/p&gt;
&lt;p&gt;At this point, I suspected that &lt;code class=&quot;language-text&quot;&gt;toSorted()&lt;/code&gt; might be the issue. So I turned to my go-to compatibility checker: Can I use. A quick &lt;a href=&quot;https://caniuse.com/?search=toSorted&quot;&gt;search for toSorted&lt;/a&gt; confirmed my suspicion:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/caniuse.png?raw=true&quot; alt=&quot;Can I use&quot;&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;❌ Not supported in versions of Chrome &amp;#x3C; 110, Safari &amp;#x3C; 16.0, and Firefox &amp;#x3C; 115.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;As shown under Rollbar Detail section, the affected users had one thing in common: older browsers. The reported landlord was on Chrome 109.0.0.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/rollbar.png?raw=true&quot; alt=&quot;Old browser&quot;&gt;&lt;/p&gt;
&lt;p&gt;Well, that explains the bug.&lt;/p&gt;
&lt;p&gt;The modern &lt;code class=&quot;language-text&quot;&gt;toSorted()&lt;/code&gt; method was simply not available in older browsers. Unlike &lt;code class=&quot;language-text&quot;&gt;sort()&lt;/code&gt;, which has been supported since the earliest days of JavaScript, &lt;code class=&quot;language-text&quot;&gt;toSorted()&lt;/code&gt; is relatively new — and using it directly will throw a runtime error in unsupported environments.&lt;/p&gt;
&lt;h2&gt;The Fix&lt;/h2&gt;
&lt;p&gt;To fix the issue, I decided to revert to the good old &lt;code class=&quot;language-text&quot;&gt;sort()&lt;/code&gt; method, but with a defensive approach to preserve immutability:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// ❌ Crashes on old browsers&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; sortedBlocks &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; blocks&lt;span class=&quot;token operator&quot;&gt;?.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;toSorted&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;sortByCreatedDateDescending&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// ✅ Works everywhere&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; sortedBlocks &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;blocks&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;sort&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;sortByCreatedDateDescending&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;By spreading the &lt;code class=&quot;language-text&quot;&gt;blocks&lt;/code&gt; array first, I avoid mutating the original array, mimicking the behavior of &lt;code class=&quot;language-text&quot;&gt;toSorted()&lt;/code&gt; — but using syntax that works across all browsers.&lt;/p&gt;
&lt;p&gt;Once I deployed this fix, I used Browserstack to verify that the page doesn&apos;t crash anymore, and the Rollbar reports ceased.&lt;/p&gt;
&lt;h2&gt;Lessons Learned&lt;/h2&gt;
&lt;p&gt;Here are a few takeaways from this experience:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Always check browser compatibility when using newer JavaScript features. Can I use is your friend.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Don’t assume your development or staging environment matches production usage. You might be running the latest browser; your users might not.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Error monitoring tools are lifesavers. Without caniuse.com and Rollbar logs, this would’ve been much harder to debug.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;When in doubt, use feature detection or fallback logic to gracefully degrade functionality.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Final Thoughts&lt;/h2&gt;
&lt;p&gt;Modern JavaScript brings tons of new features that make our code cleaner and more maintainable. But with great syntax comes great responsibility.&lt;/p&gt;
&lt;p&gt;In our case, the shiny new &lt;code class=&quot;language-text&quot;&gt;toSorted()&lt;/code&gt; method was the culprit behind a pretty serious production issue — and a good reminder that backward compatibility still matters.&lt;/p&gt;
&lt;p&gt;So the next time you&apos;re tempted to reach for a new feature, remember to ask: &lt;em&gt;Can I use this&lt;/em&gt;?&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Easy Way to Get the Number of Days in a Month]]></title><description><![CDATA[Working with dates in JavaScript has a bit of a reputation for being messy. The Date object isn’t the most intuitive thing in the language…]]></description><link>https://chiamakaikeanyi.dev/easy-way-to-get-the-number-of-days-in-a-month/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/easy-way-to-get-the-number-of-days-in-a-month/</guid><pubDate>Fri, 25 Apr 2025 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Working with dates in JavaScript has a bit of a reputation for being messy. The Date object isn’t the most intuitive thing in the language, and even a simple task like figuring out how many days are in a month can seem harder than it should be.&lt;/p&gt;
&lt;p&gt;But here’s the good news: there&apos;s a surprisingly simple trick to get the number of days in any month using just one line of code. Let’s break it down in a way that makes sense, with examples.&lt;/p&gt;
&lt;h2&gt;Why is this Tricky?&lt;/h2&gt;
&lt;p&gt;It’s good to understand why this isn&apos;t as straightforward as you might think.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Some months have 30 days, some 31.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;February has 28 or 29, depending on the year (leap years).&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The solution is to use Day 0 to go backwards; JavaScript have date math magic we can use.&lt;/p&gt;
&lt;p&gt;In JavaScript, you can create a Date object like this:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;year&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; monthIndex&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; day&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here’s the weird but useful part: if you set the day to 0, JavaScript gives you the last day of the previous month.&lt;/p&gt;
&lt;p&gt;So if you want to find out how many days are in February 2024, this trick gives you the answer.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2024&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This doesn&apos;t give you a day in March, it gives you the last day of February. That’s February 29, 2024 — which is a leap year.&lt;/p&gt;
&lt;h2&gt;The One-Liner Magic&lt;/h2&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getDaysInMonth&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;year&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; month&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;year&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; month&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getDate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;How It Works:&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;we count months from 1 (Jan = 1), but JavaScript uses 0-based months (Jan = 0).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;So if you pass in (2024, 2), JavaScript interprets this as March 0, which gives you the last day of February.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;.getDate()&lt;/code&gt; then pulls out the day of the month, which is your answer.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token function&quot;&gt;getDaysInMonth&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2024&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// 29 (Leap year!)&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;getDaysInMonth&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2023&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// 28&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;getDaysInMonth&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2023&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// 31 (January)&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;getDaysInMonth&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2023&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// 30 (April)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If you want to get days in May, pass in 5 (because month = 5 means June, and day 0 gives you the last day of May). It’s a bit odd at first, but once you get used to it, this method becomes second nature.&lt;/p&gt;
&lt;h2&gt;Final Thoughts&lt;/h2&gt;
&lt;p&gt;Date handling in JavaScript isn’t always intuitive, but little tricks like this can make your life easier. Whether you&apos;re validating forms, setting up calendars, or building scheduling tools, this method will save you time and confusion.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[2024, A Year In My Life]]></title><description><![CDATA[If 2023 was the year that taught me the value of taking a step back to leap forward, then 2024 whispered an even deeper truth — life and…]]></description><link>https://chiamakaikeanyi.dev/2024-a-year-in-my-life/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/2024-a-year-in-my-life/</guid><pubDate>Wed, 01 Jan 2025 08:00:00 GMT</pubDate><content:encoded>&lt;p&gt;If &lt;a href=&quot;/2023-a-year-in-my-life&quot;&gt;2023&lt;/a&gt; was the year that taught me the value of taking a step back to leap forward, then 2024 whispered an even deeper truth — life and relationships are all about perspective.&lt;/p&gt;
&lt;h2&gt;Writing: The Battle of Physique&lt;/h2&gt;
&lt;p&gt;If you know me well, you already know that writing is one of my quiet joys. Last year, I penned a few pieces, but one stood out — &lt;em&gt;&lt;a href=&quot;https://medium.com/poesie/battle-of-physique-a154b689f6c6&quot;&gt;The Battle of Physique&lt;/a&gt;&lt;/em&gt;. It explored the judgmental nature of humans, the way we measure others by appearances before understanding their depths. It was a mirror, reflecting both my thoughts and the world around me.&lt;/p&gt;
&lt;h2&gt;Language: Cracking the Code&lt;/h2&gt;
&lt;p&gt;A little over two years in Germany, and the language was no longer just background noise — it was something I could finally grasp. And guess what? I aced my B1 German exam!
I also wrote the German Citizenship exam (Einbürgerungtest) and got the perfect score 33/33 🥁&lt;/p&gt;
&lt;p&gt;Each day, I push myself to improve, hoping that by this time next year, I’ll be weaving through conversations with even more confidence.&lt;/p&gt;
&lt;h2&gt;Music&lt;/h2&gt;
&lt;p&gt;In 2024, I casually explored music by taking guitar lessons. Along the way, I got the chance to play with a band, perform at Open Music Night, and record our own song, “S-Bahn Girl.”&lt;/p&gt;
&lt;h2&gt;Germany: A Shifting Perspective&lt;/h2&gt;
&lt;p&gt;My perception of Germany evolved dramatically over the past year. From the smelly, aggressive characters on steroids roaming the S and U-Bahn to the &lt;em&gt;near-Kafkaesque&lt;/em&gt; bureaucracy of the health and public offices - things that shouldn’t be as complicated as they are. And let’s not even talk about the endless paperwork; for a country labeled as &quot;first world,&quot; the intransparency of certain processes still baffles me.&lt;/p&gt;
&lt;p&gt;Despite this shifted perspective, it still has a lot to offer.&lt;/p&gt;
&lt;h2&gt;Wanderlust Chronicles&lt;/h2&gt;
&lt;p&gt;4 countries and several German cities (Frankfurt, Görlitz, Würzburg etc.) explored — each offering its own unique experience.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Czech Republic: Visiting Prague for the second time felt familiar rather than new. Without the rush of first impressions, I noticed the city more quietly—its history, its rhythm, and the way it unfolds at a slower pace.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Austria: Walking through Salzburg felt like stepping into my childhood memories of &lt;em&gt;The Sound of Music&lt;/em&gt;. Vienna, the world&apos;s most livable city, was lovely to be in, though I’m still trying to pinpoint exactly what keeps it at the top.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Belgium: Waffles, chocolate, and stunning architecture — what more could you ask for? Antwerp’s train station is a true architectural marvel, a blend of grandeur and precision. Meanwhile, Brussels’ station stood as a proud relic of the past, preserving the craftsmanship and heritage of the forefathers in the best way possible.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Luxembourg: A country that offers free public transport? Sign me up! Getting from one point to another was seamless and, more importantly, easy on the wallet.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;What&apos;s Next?&lt;/h2&gt;
&lt;p&gt;2025 is a blank canvas, waiting to be painted with new stories, lessons, and adventures. Here’s to writing the best chapters yet 🥂✨&lt;/p&gt;</content:encoded></item><item><title><![CDATA[How to Create Code Snippets in VS Code]]></title><description><![CDATA[Visual Studio Code (VS Code) is a widely used source code editor that offers a variety of features to enhance developer productivity. One of…]]></description><link>https://chiamakaikeanyi.dev/how-to-create-code-snippets-in-vscode/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/how-to-create-code-snippets-in-vscode/</guid><pubDate>Thu, 07 Mar 2024 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Visual Studio Code (VS Code) is a widely used source code editor that offers a variety of features to enhance developer productivity. One of such features is the ability to utilize code snippets, which can significantly streamline your coding experience. But do you know that you can create custom snippets?&lt;/p&gt;
&lt;p&gt;I recently discovered this in an attempt to rewrite some old tests to Cypress.
In this article, we will delve into the intricacies of creating and managing code snippets in VS Code.&lt;/p&gt;
&lt;!-- I found myself repeatedly having to type the Cypress reference and immediately thought of what to do. --&gt;
&lt;h2&gt;What are Code Snippets?&lt;/h2&gt;
&lt;p&gt;Code snippets are reusable blocks of code that can be inserted into your files to expedite coding, thereby saving you time.&lt;/p&gt;
&lt;p&gt;To see available snippets in VS Code, search for the Insert Snippet command in the Command Palette using the shortcut CMD + SHIFT + P or Ctrl + Shift + P for Windows.&lt;/p&gt;
&lt;h2&gt;Creating Custom Snippets&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Use the shortcut CMD + SHIFT + P or Ctrl + Shift + P and type Configure User Snippets&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/snippet-user.png?raw=true&quot; alt=&quot;Configure user snippets&quot;&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Upon selecting &quot;User Snippets,&quot; you&apos;ll be prompted to choose the language for which you want to create a snippet. You can also choose New Global Snippets file&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/snippet-global.png?raw=true&quot; alt=&quot;Global snippets&quot;&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Add the trigger for your custom snippet
&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/snippet-cyref.png?raw=true&quot; alt=&quot;Custom snippet&quot;&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In the opened JSON file, add a new snippet entry in the required format and save the file to apply the changes. VS Code uses JSON files to define snippets.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/snippet-rule.png?raw=true&quot; alt=&quot;Snippet rule&quot;&gt;&lt;/p&gt;
&lt;h2&gt;Setting Tab Completion and Triggering Snippets&lt;/h2&gt;
&lt;p&gt;VS Code allows you to customize how snippets are triggered.&lt;/p&gt;
&lt;p&gt;To set up tab completion:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Open the settings.json file with the Preferences: Open User Settings (JSON) command in the Command Palette&lt;/li&gt;
&lt;li&gt;Add &lt;code class=&quot;language-text&quot;&gt;&quot;editor.tabCompletion&quot;: &quot;on&quot;&lt;/code&gt; between the two curly braces {} in the file and save&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;With tab completion configured, simply type the snippet trigger and press the Tab key to insert the snippet.
From now onwards, typing &lt;code class=&quot;language-text&quot;&gt;cyref&lt;/code&gt; would insert the Cypress reference code snippet (&lt;code class=&quot;language-text&quot;&gt;// / &amp;lt;reference types=&quot;cypress&quot; /&gt;&lt;/code&gt;) into our files.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/snippet-trigger.png?raw=true&quot; alt=&quot;Triggering cyref&quot;&gt;&lt;/p&gt;
&lt;h2&gt;Removing Snippets&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Navigate to the snippet by searching for User Snippets command in the Command Palette&lt;/li&gt;
&lt;li&gt;Locate the snippet in the JSON file&lt;/li&gt;
&lt;li&gt;Delete the corresponding entry and save the file to remove the snippet&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can also choose to delete the file entirely if you only have one snippet configured.
To do this, take note of the file location and run the commands below. In my case, the snippets are located in &lt;code class=&quot;language-text&quot;&gt;Library/Application Support/Code/User/snippets&lt;/code&gt;&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;➜  ~ &lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; Library/Application&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt; Support/Code/User/snippets
➜  &lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;# cyref.code-snippets // the output&lt;/span&gt;
➜  &lt;span class=&quot;token function&quot;&gt;rm&lt;/span&gt; cyref.code-snippets&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Conclusion:&lt;/h2&gt;
&lt;p&gt;Creating and managing snippets in Visual Studio Code can significantly enhance your coding workflow. By customizing snippets, adjusting tab completion settings, and removing unnecessary snippets, you can tailor your development environment to suit your specific needs.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Finding Incorrect Data Types with MongoDB Queries]]></title><description><![CDATA[Recently, we encountered an issue in our system where the internet connection speed was being stored incorrectly. Instead of always being…]]></description><link>https://chiamakaikeanyi.dev/finding-incorrect-data-types-with-mongodb-queries/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/finding-incorrect-data-types-with-mongodb-queries/</guid><pubDate>Thu, 15 Feb 2024 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Recently, we encountered an issue in our system where the &lt;strong&gt;internet connection speed&lt;/strong&gt; was being stored incorrectly. Instead of always being saved as an integer, some values were stored as floating-point numbers (&lt;code class=&quot;language-text&quot;&gt;double&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;This might sound small, but it led to &lt;strong&gt;inconsistent data&lt;/strong&gt; and confusing behavior in our application.&lt;/p&gt;
&lt;h2&gt;The Background&lt;/h2&gt;
&lt;p&gt;Our field &lt;code class=&quot;language-text&quot;&gt;features.internetSpeed&lt;/code&gt; is supposed to represent internet speed in whole megabits per second. For example:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;json&quot;&gt;&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;features&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;internetSpeed&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;384&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;However, during a review, we noticed that some listings had values like:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;json&quot;&gt;&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;features&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;internetSpeed&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;384.54&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This meant we had some records stored as doubles instead of integers.&lt;/p&gt;
&lt;h2&gt;Detecting the Problem&lt;/h2&gt;
&lt;p&gt;MongoDB stores numbers with a specific BSON type. Integers and doubles are different types. To confirm which records were affected, we used a query that checks the BSON type of the field:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;json&quot;&gt;&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;features.internetSpeed&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;$type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here’s what’s happening in this query:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;features.internetSpeed → the field we’re inspecting.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;$type: 1 → tells MongoDB to return only documents where this field is stored as a double.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;By running this query, we quickly identified that 19 listings still had their internet speed saved as doubles although we stopped using this data type a while ago.&lt;/p&gt;
&lt;h2&gt;Why This Matters&lt;/h2&gt;
&lt;p&gt;Finding the affected documents by data type was crucial because:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;It allowed us to quantify the issue (exactly 19 listings).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;It gave us a clear target set for a migration script to fix.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;It ensured that we weren’t just guessing—we had verified data from the database itself.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Lessons Learned&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;MongoDB &lt;code class=&quot;language-text&quot;&gt;$type&lt;/code&gt; is powerful: It’s not just about values, but about the underlying storage type.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Type enforcement matters: Even if values look right, the wrong type can lead to subtle bugs.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Monitoring data health: Queries like this should be part of regular audits when schema expectations change.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;By leveraging MongoDB’s &lt;code class=&quot;language-text&quot;&gt;$type&lt;/code&gt; query operator, we were able to find all the records where the internet connection speed was incorrectly stored as a double. This gave us confidence to move forward with a migration, knowing we had full visibility into the scope of the problem.&lt;/p&gt;
&lt;p&gt;Sometimes the fix starts not with code, but with asking the right question of the database.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[How ESLint Made Our Codebase Breathe Again]]></title><description><![CDATA[Every engineer has had that moment: opening a file and being greeted by chaos. Lines of imports scattered in no particular order. Some…]]></description><link>https://chiamakaikeanyi.dev/how-eslint-made-our-codebase-breathe-again/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/how-eslint-made-our-codebase-breathe-again/</guid><pubDate>Thu, 25 Jan 2024 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Every engineer has had that moment: opening a file and being greeted by chaos. Lines of imports scattered in no particular order. Some duplicated, others grouped inconsistently — almost like a visual reminder of how many hands had touched the file over time.&lt;/p&gt;
&lt;p&gt;That’s how it felt every time I opened a file in our frontend repositories. It worked, the code always ran. But it didn’t feel right; it was messy, inconsistent, and every new import added to the tangle.&lt;/p&gt;
&lt;p&gt;And that’s where this story begins — not with a broken feature or a failing test, but with a quiet frustration and a small, simple goal:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Leave the codebase cleaner than I found it.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;The Chaos of Imports&lt;/h2&gt;
&lt;p&gt;In the wild, our imports looked something like this:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; Link &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;react-router-dom&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; Toaster &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;../Toaster&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; PropTypes &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;prop-types&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; React&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; useState&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; useRef&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; useEffect&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; useCallback &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;react&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; classNames &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;classnames&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Nothing technically wrong — but visually? Hard to scan, hard to maintain.&lt;/p&gt;
&lt;p&gt;I imagined what it could look like instead:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; React&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; useCallback&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; useEffect&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; useRef&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; useState &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;react&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; PropTypes &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;prop-types&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; Link &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;react-router-dom&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; classNames &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;classnames&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; Toaster &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;../Toaster&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Same imports, different energy.&lt;/p&gt;
&lt;p&gt;It reads naturally — from framework to libraries to internal components. You can almost feel the logic.&lt;/p&gt;
&lt;h2&gt;The Idea: Automate Boring Stuffs&lt;/h2&gt;
&lt;p&gt;That small spark led me to ESLint — specifically, its sort-imports and import/order rules.&lt;/p&gt;
&lt;p&gt;The goal wasn’t just to enforce order; it was to encode our sense of craftsmanship into the code itself.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;sort-imports ensures the items on each line stay sorted.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Using the configuration:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;&quot;sort-imports&quot;: [
      &quot;error&quot;,
      {
        ignoreCase: true,
        ignoreDeclarationSort: true,
        ignoreMemberSort: false,
        memberSyntaxSortOrder: [&quot;all&quot;, &quot;single&quot;, &quot;multiple&quot;, &quot;none&quot;],
        allowSeparatedGroups: false,
      },
    ],&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; React&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; useEffect&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; useState&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; useCallback &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;react&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;is corrected to&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; React&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; useCallback&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; useEffect&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; useState &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;react&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;import/order organizes entire groups — built-ins, externals, internals — like chapters in a well-structured book.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I configured them to follow this pattern:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;[[&quot;builtin&quot;, &quot;external&quot;], &quot;internal&quot;, [&quot;parent&quot;, &quot;sibling&quot;]]&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And because conventions matter, I gave &lt;code class=&quot;language-text&quot;&gt;react&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;react-dom&lt;/code&gt;, and &lt;code class=&quot;language-text&quot;&gt;PropTypes&lt;/code&gt; reserved spots at the top — the familiar trio that should always greet you when you open a React file.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;&quot;import/order&quot;: [
      &quot;error&quot;,
      {
        groups: [[&quot;builtin&quot;, &quot;external&quot;], &quot;internal&quot;, &quot;parent&quot;, &quot;sibling&quot;],
        pathGroups: [
          {
            pattern: &quot;react&quot;,
            group: &quot;external&quot;,
            position: &quot;before&quot;,
          },
          {
            pattern: &quot;react-dom&quot;,
            group: &quot;external&quot;,
            position: &quot;before&quot;,
          },
          {
            pattern: &quot;prop-types&quot;,
            group: &quot;external&quot;,
            position: &quot;before&quot;,
          },
        ],
        pathGroupsExcludedImportTypes: [&quot;react&quot;, &quot;react-dom&quot;, &quot;prop-types&quot;],
        &quot;newlines-between&quot;: &quot;never&quot;,
        alphabetize: {
          order: &quot;asc&quot;,
          caseInsensitive: true,
        },
      },
    ],&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The result? Code that looks and feels organized:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/import_chaos.webp?raw=true&quot; alt=&quot;Package import chaos&quot;&gt;&lt;/p&gt;
&lt;p&gt;Every file started to breathe better.&lt;/p&gt;
&lt;h2&gt;The Fixing Marathon&lt;/h2&gt;
&lt;p&gt;I ran &lt;code class=&quot;language-text&quot;&gt;yarn lint --fix&lt;/code&gt; with the same nervous excitement as running tests after a big refactor.
Some files cleaned themselves up perfectly. Others resisted.
After the auto-fix, I was left staring at 225 stubborn files that needed manual care — one by one.&lt;/p&gt;
&lt;p&gt;It wasn’t glamorous work, but it was meaningful. Each file I fixed became a little more readable, a little more consistent.&lt;/p&gt;
&lt;p&gt;And consistency is contagious.&lt;/p&gt;
&lt;h2&gt;The Hidden Problem: Duplicate Imports&lt;/h2&gt;
&lt;p&gt;While working on the imports, I found another recurring issue — duplicate imports.
Same package imported twice in the same file. Easy to miss, but messy and unnecessary.&lt;/p&gt;
&lt;p&gt;Examples like these kept popping up:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; useHistory &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;react-router-dom&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; useFeatureFlags &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;../../contexts/FeatureFlagContext&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; Link &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;react-router-dom&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So I added one more rule to our ESLint configuration:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;&quot;no-duplicate-imports&quot;: &quot;error&quot;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now, ESLint not only helps us keep things tidy — it protects us from repeating the same mistakes.&lt;/p&gt;
&lt;h2&gt;Final Thoughts&lt;/h2&gt;
&lt;p&gt;At first glance, sorting imports doesn’t seem revolutionary. But it’s symbolic of something deeper: Care.
When developers take time to improve the small things — the things no one notices until they’re wrong — they build a culture of pride and respect for the codebase.&lt;/p&gt;
&lt;p&gt;Every lint rule, every refactor, every cleanup is a way of saying:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;“I was here — and I left it better than I found it.”&lt;/p&gt;
&lt;/blockquote&gt;</content:encoded></item><item><title><![CDATA[2023, A Year In My Life]]></title><description><![CDATA[2022 taught me that the world is laden with so much goodness but we need to explore and not merely exist; 2023 taught me that not everything…]]></description><link>https://chiamakaikeanyi.dev/2023-a-year-in-my-life/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/2023-a-year-in-my-life/</guid><pubDate>Mon, 01 Jan 2024 08:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;a href=&quot;/2022-a-year-in-my-life&quot;&gt;2022 taught me&lt;/a&gt; that the world is laden with so much goodness but we need to explore and not merely exist; 2023 taught me that not everything works the way we envisage and it&apos;s okay to rethink and re-strategize in order to achieve our goals. It also taught me that the adventure we look for in other places may be closer to us than we imagine.&lt;/p&gt;
&lt;p&gt;Come with me on a short cruise to view a snapshot of my year.&lt;/p&gt;
&lt;h2&gt;Relationship ‍&lt;/h2&gt;
&lt;p&gt;Though I kept in touch with the connections I made in 2022 and made acquaintances with a few people, I was more in my own space in 2023; it gave room for retrospection.&lt;/p&gt;
&lt;h2&gt;Writing&lt;/h2&gt;
&lt;p&gt;I have to admit that I shouldn&apos;t feel unhappy for not doing a lot of writings in 2023. I spent my time doing useful things, so it was properly allotted. I&apos;ll write when I can.&lt;/p&gt;
&lt;p&gt;I was able to write a poetry piece titled &lt;a href=&quot;https://medium.com/poesie/yearnings-unveiled-d6730c7da730&quot;&gt;Yearnings Unveiled&lt;/a&gt; which explores people&apos;s disinterest when they ask the question “How are you?”.&lt;/p&gt;
&lt;p&gt;Kudos to keeping this blog running for 5 years now. It&apos;s worth celebrating 🥳 🎉&lt;/p&gt;
&lt;h2&gt;Language&lt;/h2&gt;
&lt;p&gt;I spent a huge chunk of the last quarter improving my language skills &lt;em&gt;um genau zu sein&lt;/em&gt; German.
&lt;em&gt;Manchmal verstehe ich es, aber ich kann meine Gefühle nicht so ausdrücken, wie ich es möchte. Ich muss mein Deutsch verbessern&lt;/em&gt;.&lt;/p&gt;
&lt;h2&gt;Travelling&lt;/h2&gt;
&lt;p&gt;I visited 3 countries - United Kingdom (London), Canada (Toronto and London Ontario) and Netherlands (Amsterdam) and learnt different things about the cities I explored and the people which is one way of broadening my horizon.&lt;/p&gt;
&lt;h2&gt;Got Featured&lt;/h2&gt;
&lt;p&gt;I had a chat with Deutsche Welle about &lt;a href=&quot;https://www.dw.com/en/japa-nigeria-hello-cold-germany/video-68114575&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;my relocation and the challenges I face in my new environment&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Actually, based on my experience, there&apos;s no perfect country; each one come with its set of pros and cons.
View the &lt;a href=&quot;https://www.dw.com/en/japa-why-do-many-nigerians-want-to-migrate/a-68144940&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;broadcast schedule&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;What&apos;s Next?&lt;/h2&gt;
&lt;p&gt;It&apos;s a new chapter and I have plans for the year but who am I to say how things would go?
I can only do my part and leave the rest.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;A man&apos;s heart deviseth his way: but the Lord directeth his steps (Proverbs 16:9)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Cheers to more adventures 🥂✨🚀&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Diagramming with Mermaid]]></title><description><![CDATA[Embarking on your coding journey often involves wrangling complex ideas and processes. Visualizing these concepts can be a game-changer, and…]]></description><link>https://chiamakaikeanyi.dev/diagramming-with-mermaid/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/diagramming-with-mermaid/</guid><pubDate>Thu, 26 Oct 2023 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Embarking on your coding journey often involves wrangling complex ideas and processes. Visualizing these concepts can be a game-changer, and that&apos;s where Mermaid diagrams come to the rescue. In this beginner-friendly guide, we&apos;ll explore the world of Mermaid diagrams, and showcase examples to get you started on the right track.&lt;/p&gt;
&lt;h2&gt;What is it?&lt;/h2&gt;
&lt;p&gt;Mermaid is a JavaScript based diagramming tool that transforms your text-based syntax into easy-to-understand diagrams. It supports various types of diagrams, such as flowcharts, pie charts, sequence diagrams, Git graphs, and more, making it easier to communicate and understand complex systems.&lt;/p&gt;
&lt;h2&gt;Why use it?&lt;/h2&gt;
&lt;p&gt;If you&apos;ve ever struggled with updating process diagrams using tools like Draw.io or Excalidraw, Mermaid is here to make your life easier. Once you update the text, the diagram gets updated seamlessly. Mermaid diagrams are easy to create, share, collaborate on, maintain, and update.&lt;/p&gt;
&lt;h2&gt;Getting Started&lt;/h2&gt;
&lt;p&gt;The &lt;a href=&quot;https://mermaid.live/edit&quot;&gt;official live editor&lt;/a&gt; provides a playground to explore the possibilities..&lt;/p&gt;
&lt;p&gt;To use this in GitHub or VSCode, enclose your code in triple backticks block and then specify mermaid as the code type &lt;code class=&quot;language-text&quot;&gt;```mermaid ```&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;You need to download &lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=bierner.markdown-mermaid&quot;&gt;Markdown Preview Mermaid Support&lt;/a&gt; or any similar extension to enable you visualize the diagram in VSCode.&lt;/p&gt;
&lt;p&gt;In Notion,&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open the document&lt;/li&gt;
&lt;li&gt;Type &lt;code class=&quot;language-text&quot;&gt;/code&lt;/code&gt; or triple backticks (```) to use the code option&lt;/li&gt;
&lt;li&gt;Update the code type to &quot;Mermaid&quot;&lt;/li&gt;
&lt;li&gt;Type your flow in mermaid syntax and&lt;/li&gt;
&lt;li&gt;Click on Preview to view the resulting diagram&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Examples&lt;/h2&gt;
&lt;p&gt;Below are Markdown-inspired text definitions and the resulting Mermaid diagrams.&lt;/p&gt;
&lt;h3&gt;Flow chart&lt;/h3&gt;
&lt;p&gt;Explains how things get done, with steps shown as boxes and the order they happen, connected by arrows.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;mermaid&quot;&gt;&lt;pre class=&quot;language-mermaid&quot;&gt;&lt;code class=&quot;language-mermaid&quot;&gt;  &lt;span class=&quot;token keyword&quot;&gt;flowchart&lt;/span&gt; LR
    A&lt;span class=&quot;token text string&quot;&gt;[Visit Registration Page]&lt;/span&gt; &lt;span class=&quot;token inter-arrow-label&quot;&gt;&lt;span class=&quot;token arrow-head arrow operator&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;token label property&quot;&gt;Provide Details&lt;/span&gt;&lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;/span&gt; B&lt;span class=&quot;token text string&quot;&gt;[Submit Form]&lt;/span&gt;
    B &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;span class=&quot;token label property&quot;&gt;|Validate and Store|&lt;/span&gt; C&lt;span class=&quot;token text string&quot;&gt;[Create Account]&lt;/span&gt;
    C &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;span class=&quot;token label property&quot;&gt;|Send Confirmation Email|&lt;/span&gt; D&lt;span class=&quot;token text string&quot;&gt;{Is confirmation successful?}&lt;/span&gt;
    D &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;span class=&quot;token label property&quot;&gt;|Yes|&lt;/span&gt; E&lt;span class=&quot;token text string&quot;&gt;[(User Registered)]&lt;/span&gt;
    D &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;span class=&quot;token label property&quot;&gt;|No|&lt;/span&gt; F&lt;span class=&quot;token text string&quot;&gt;[User Not Registered]&lt;/span&gt;
    E &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;span class=&quot;token label property&quot;&gt;|No|&lt;/span&gt; G&lt;span class=&quot;token text string&quot;&gt;([End])&lt;/span&gt;
    F &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;span class=&quot;token label property&quot;&gt;|No|&lt;/span&gt; G&lt;span class=&quot;token text string&quot;&gt;([End])&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/mermaid_flowchart.png?raw=true&quot; alt=&quot;Flow chart&quot;&gt;&lt;/p&gt;
&lt;p&gt;The LR specifies the chart&apos;s direction (Left to Right). You can also choose TD for Top to Down arrangement.
The alphabets represents the node ID and can be substituted with what you want to use as an identifier.&lt;/p&gt;
&lt;h3&gt;Sequence Diagram&lt;/h3&gt;
&lt;p&gt;Likened to a timeline that shows how different steps in a process happen one after the other.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;mermaid&quot;&gt;&lt;pre class=&quot;language-mermaid&quot;&gt;&lt;code class=&quot;language-mermaid&quot;&gt;    &lt;span class=&quot;token keyword&quot;&gt;sequenceDiagram&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;participant&lt;/span&gt; User
    &lt;span class=&quot;token keyword&quot;&gt;participant&lt;/span&gt; Platform
    &lt;span class=&quot;token keyword&quot;&gt;participant&lt;/span&gt; Course

    User &lt;span class=&quot;token arrow operator&quot;&gt;-&gt;&gt;&lt;/span&gt; Platform&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Login
    User &lt;span class=&quot;token arrow operator&quot;&gt;-&gt;&gt;&lt;/span&gt; Platform&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Browse Courses
    User &lt;span class=&quot;token arrow operator&quot;&gt;-&gt;&gt;&lt;/span&gt; Course&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Select Course
    Platform &lt;span class=&quot;token arrow operator&quot;&gt;-&gt;&gt;&lt;/span&gt; Course&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Retrieve Course Details
    Course &lt;span class=&quot;token arrow operator&quot;&gt;-&gt;&gt;&lt;/span&gt; Course&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Fetches Course from database
    Course &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&gt;&lt;/span&gt; User&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Return course details
    User &lt;span class=&quot;token arrow operator&quot;&gt;-&gt;&gt;&lt;/span&gt; Platform&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Enroll in Course
    &lt;span class=&quot;token keyword&quot;&gt;Note left of&lt;/span&gt; User&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Prevent multiple enrolment
    Platform &lt;span class=&quot;token arrow operator&quot;&gt;-&gt;&gt;&lt;/span&gt; Course&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Add User to Course
    Course &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&gt;&lt;/span&gt; Platform&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Enrollment Successful
    Platform &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&gt;&lt;/span&gt; User&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Confirmation Message&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/mermaid_sequence_diagram.png?raw=true&quot; alt=&quot;Sequence Diagram&quot;&gt;&lt;/p&gt;
&lt;h3&gt;Mind map&lt;/h3&gt;
&lt;p&gt;Mind maps are like helpful doodles that make it easy to show and remember ideas. They&apos;re great for connecting information in a simple and understandable way.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;mermaid&quot;&gt;&lt;pre class=&quot;language-mermaid&quot;&gt;&lt;code class=&quot;language-mermaid&quot;&gt;mindmap
      root&lt;span class=&quot;token text string&quot;&gt;(Summer Vacation))&lt;/span&gt;
        Destinations
          Europe
            France&lt;span class=&quot;token text string&quot;&gt;(Paris)&lt;/span&gt;
            Italy&lt;span class=&quot;token text string&quot;&gt;(Rome)&lt;/span&gt;
          Asia
            Japan&lt;span class=&quot;token text string&quot;&gt;(Tokyo)&lt;/span&gt;
        Budget
          Airfare
          Hotels
          Food
        Activities
          Sightseeing
          Adventure Sports
        Accommodation
          Hotels
          Vacation Rentals&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/mermaid_mindmap.png?raw=true&quot; alt=&quot;Mind map&quot;&gt;&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;You&apos;ve only begun to explore the world of Mermaid diagrams. Whether you&apos;re mapping out a project, documenting code, or clarifying a process, Mermaid simplifies it all. It&apos;s not just useful in corporate settings for brainstorming with your team or presenting processes to stakeholders; you can also apply it in your personal life for event planning and more.&lt;/p&gt;
&lt;p&gt;Consider exploring &lt;a href=&quot;https://docs.mermaidchart.com/mermaid/intro&quot;&gt;other types of diagrams&lt;/a&gt; that Mermaid supports to enhance your project documentation and collaboration.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Trust works!]]></title><description><![CDATA[I recently read the book "Trust Works! Four Keys to Building Lasting Relationships" and would like to share my key take aways. Trust Works…]]></description><link>https://chiamakaikeanyi.dev/trust-works/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/trust-works/</guid><pubDate>Thu, 17 Aug 2023 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I recently read the book &quot;Trust Works! Four Keys to Building Lasting Relationships&quot; and would like to share my key take aways.&lt;/p&gt;
&lt;p&gt;Trust Works! Four Keys to Building Lasting Relationships is a book written by Ken Blanchard, Cynthia Olmstead, and Martha Lawrence which focuses on the importance of trust in building and maintaining personal and professional relationships. Building trust takes a long time but it can be broken in a blink of an eye if the 4 concepts stated in the book are not applied.&lt;/p&gt;
&lt;p&gt;The book hinges on the &lt;strong&gt;ABCD trust model&lt;/strong&gt; which plays a huge role in cultivating trust. The model states that one should imbibe these behaviours written below inorder to build trust or clear misconceptions.&lt;/p&gt;
&lt;h1&gt;Able&lt;/h1&gt;
&lt;p&gt;Demonstrating competence in one&apos;s area of responsibility is crucial for building trust. When individuals are confident in your abilities, they are more likely to trust your judgment and decisions.&lt;/p&gt;
&lt;p&gt;To Demonstrate competence, you have to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Get quality results&lt;/li&gt;
&lt;li&gt;Resolve problems&lt;/li&gt;
&lt;li&gt;Develop skills&lt;/li&gt;
&lt;li&gt;Be good at what you do&lt;/li&gt;
&lt;li&gt;Get experience&lt;/li&gt;
&lt;li&gt;Use skills to assist others&lt;/li&gt;
&lt;li&gt;Be the best at what you do&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;Believable&lt;/h1&gt;
&lt;p&gt;Being open and transparent in communication, acting with integrity, admitting mistakes, and addressing concerns genuinely helps to establish a foundation of trust. When someone tells you something in confidence, keep it to yourself and not tell everyone that cares to listen.&lt;/p&gt;
&lt;p&gt;To Act with integrity, you have to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Keep confidences&lt;/li&gt;
&lt;li&gt;Admit when you&apos;re wrong&lt;/li&gt;
&lt;li&gt;Be honest&lt;/li&gt;
&lt;li&gt;Don&apos;t talk behind backs&lt;/li&gt;
&lt;li&gt;Be sincere&lt;/li&gt;
&lt;li&gt;Be non-judgmental&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;Connected&lt;/h1&gt;
&lt;p&gt;Genuine concern for the well-being and success of others. Showing empathy, understanding, and support creates an environment where people feel valued and cared for, enhancing trust.&lt;/p&gt;
&lt;p&gt;To show that you Care about others, you have to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Listen well&lt;/li&gt;
&lt;li&gt;Praise others&lt;/li&gt;
&lt;li&gt;Show interest in others&lt;/li&gt;
&lt;li&gt;Share about yourself&lt;/li&gt;
&lt;li&gt;Work well with others&lt;/li&gt;
&lt;li&gt;Show empathy for others&lt;/li&gt;
&lt;li&gt;Ask for input&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;Dependable&lt;/h1&gt;
&lt;p&gt;Consistently delivering on promises and commitments. When individuals can rely on each other to follow through on their commitments, it builds a sense of dependability and reliability thereby fostering trust.&lt;/p&gt;
&lt;p&gt;To show that you can be reliable, you have to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Do what you say you&apos;ll do&lt;/li&gt;
&lt;li&gt;Be timely&lt;/li&gt;
&lt;li&gt;Be responsive&lt;/li&gt;
&lt;li&gt;Be organized&lt;/li&gt;
&lt;li&gt;Follow-up&lt;/li&gt;
&lt;li&gt;Be consistent&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;By applying these behaviours that align with the 4 core elements of trust in your daily life, you would show people that you&apos;re &lt;em&gt;Able&lt;/em&gt; through your deeds, &lt;em&gt;Believable&lt;/em&gt; through your words and actions, &lt;em&gt;Connected&lt;/em&gt; during conversations and &lt;em&gt;Dependable&lt;/em&gt; when push comes to shove.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Accelerate]]></title><description><![CDATA[Accelerate, a book co-authored by Nicole Forsgren, Jez Humble, and Gene Kim delves into the world of software development, focusing on the…]]></description><link>https://chiamakaikeanyi.dev/accelerate/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/accelerate/</guid><pubDate>Thu, 27 Jul 2023 02:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Accelerate, a book co-authored by Nicole Forsgren, Jez Humble, and Gene Kim delves into the world of software development, focusing on the principles of Lean, DevOps, and their impact on organizational performance. The book draws from extensive research to uncover the practices that separate high-performing teams from the rest.&lt;/p&gt;
&lt;p&gt;It addresses the pressing need for organizations to adapt and excel in the rapidly evolving technological landscape and sets the stage for understanding why high-performing technology organizations are crucial for success in today&apos;s competitive markets.&lt;/p&gt;
&lt;p&gt;TLDR;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Have transformational leadership.&lt;/li&gt;
&lt;li&gt;Promote a culture of collaboration, trust, learning and experimentation. Culture predicts both delivery and organizational performance as it determines employees job satisfaction level.&lt;/li&gt;
&lt;li&gt;Collaboration is key; who is on the team matters less than how team members interact and structure their work.&lt;/li&gt;
&lt;li&gt;Never use velocity to measure team productivity or compare teams; use it to measure capacity. Teams have different contexts and when velocity is used as a measurent tool, teams inflate their estimates and focus on completing as many stories as possible at the expense of collaboration with other teams.&lt;/li&gt;
&lt;li&gt;Get rid of deployment pain by adopting continuous integration and delivery.&lt;/li&gt;
&lt;li&gt;Adopt Trunk-based development.&lt;/li&gt;
&lt;li&gt;Failures should lead to inquiry, not scapegoating; don&apos;t punish employees for accidental human error, but rather treat it as an opportunity to improve observability and system guards to help prevent catastrophic failures.&lt;/li&gt;
&lt;li&gt;There&apos;s no trade-off between speed and stability for high performing organizations.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Key Findings&lt;/h2&gt;
&lt;p&gt;The authors introduce the concept of the &quot;Four Key Metrics&quot; that are crucial for measuring and improving the performance of a software development team. These metrics are often known as DORA metrics and include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Lead Time / Cycle Time&lt;/strong&gt;: The time it takes to move from a code commit to a successfully deployed product. Shorter lead times signify faster and more efficient development processes.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Deployment Frequency&lt;/strong&gt;: This metric gauges how often code is deployed to production. It is a crucial indicator of a team&apos;s agility and responsiveness to change. A high deployment frequency is associated with increased innovation and faster time-to-market.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Mean Time to Recovery (MTTR) / Time to Restore Service&lt;/strong&gt;: The time it takes to recover from a service outage or failure. This is a critical metric that reflects a team&apos;s resilience and recovery capabilities. Rapid response to incidents is vital in maintaining a seamless user experience.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Change Failure Rate&lt;/strong&gt;: The percentage of changes that result in a failure. Low failure rates are indicative of robust development practices; high-performing teams experience fewer failures when introducing changes, showcasing the robustness of their processes&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;Delivery lead time and deployment frequency measure the team&apos;s velocity while mean time to recovery and change failure rate measure the quality and stability of a project.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;By systematically calculating these metrics, organizations can strategically direct management and development teams towards improvement opportunities, showcase the tangible impact of engineering efforts on business outcomes, and gain insights that facilitate well-informed decision-making, ultimately leading to the prompt delivery of value to customers.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/software_delivery_performance.jpg?raw=true&quot; alt=&quot;Software Delivery Performance&quot;&gt;&lt;/p&gt;
&lt;p&gt;Furthermore, Accelerate sheds light on pivotal practices and cultural elements crucial for achieving high performance. These include continuous integration, continuous delivery, observability, transformational leadership, and a culture characterized by collaboration, trust, learning, and experimentation.&lt;/p&gt;
&lt;p&gt;Despite the acknowledged truth that people are an organization&apos;s greatest asset, they often find themselves treated as replaceable resources. The book underscores the significance of valuing employees, emphasizing that when individuals are treated with respect, they are motivated to go above and beyond, propelling the organization toward success. Notably, the text highlights innovative approaches adopted by industry giants, such as Google&apos;s 20% time policy, which grants employees a dedicated portion of their work week for personal projects, and IBM&apos;s THINK Friday initiative, reserving Friday afternoons for uninterrupted learning without meetings.&lt;/p&gt;
&lt;p&gt;In the realm of leadership, the importance of transformational leaders is emphasized. These leaders possess a visionary outlook, inspire team members, stimulate intellectual growth, provide support, and commend performance.&lt;/p&gt;
&lt;p&gt;A transformative leader:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Demonstrates a clear understanding of the team&apos;s goals and objectives.&lt;/li&gt;
&lt;li&gt;Grasps the organization&apos;s Objectives and Key Results (OKRs).&lt;/li&gt;
&lt;li&gt;Expresses positive sentiments about the team, fostering a sense of value among its members.&lt;/li&gt;
&lt;li&gt;Encourages individuals to explore opportunities beyond their comfort zones.&lt;/li&gt;
&lt;li&gt;Challenges team members to approach problems with fresh perspectives.&lt;/li&gt;
&lt;li&gt;Considers the feelings and perspectives of team members before making decisions.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In essence, the cultivation of a transformational leadership approach is identified as essential for achieving superior organizational outcomes.&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;As organizations continue to navigate the challenges of the digital age, the principles outlined in Accelerate serve as a roadmap for achieving excellence in software delivery and organizational success. By focusing on the four key metrics and adopting best practices, teams can not only keep up with the rapidly evolving tech landscape but proactively drive advancements and innovative solutions.&lt;/p&gt;
&lt;p&gt;A combination of tools like GitHub, Jira and Swarmia or related tools provide a comprehensive way to measure developer productivity if you don&apos;t want to write scripts to calculate these.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[2022, A Year In My Life]]></title><description><![CDATA[When we quit limiting ourselves and open up to a world of possibilities, we'll soar.
2021 taught me that with grace, preparation and…]]></description><link>https://chiamakaikeanyi.dev/2022-a-year-in-my-life/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/2022-a-year-in-my-life/</guid><pubDate>Sun, 01 Jan 2023 08:00:00 GMT</pubDate><content:encoded>&lt;p&gt;When we quit limiting ourselves and open up to a world of possibilities, we&apos;ll soar.
&lt;a href=&quot;/2021-a-year-in-my-life&quot;&gt;2021 taught me&lt;/a&gt; that with grace, preparation and flexibility, anyone can progress in certain aspects of life; 2022 taught me that the world is laden with so much goodness but we need to explore and not merely exist.&lt;/p&gt;
&lt;p&gt;In this article, I will write on a few areas of my life that I&apos;m grateful for:&lt;/p&gt;
&lt;h2&gt;Relationship ‍&lt;/h2&gt;
&lt;p&gt;I made a couple of friends; I&apos;ll say travel buddies with who I explored some places and countries. I feel like the easiest way to bond with people is over activities and I stepped out to do that a lot more than I&apos;ve ever done.&lt;/p&gt;
&lt;h2&gt;Writing&lt;/h2&gt;
&lt;p&gt;I slacked in this aspect; the zeal to write diminished in 2021 😞. I&apos;m hoping to find myself again and resuscitate that zeal this year.&lt;/p&gt;
&lt;h2&gt;Language&lt;/h2&gt;
&lt;p&gt;German can be hard especially with the articles and rules, no present participle etc. I learnt a lot in the past year and would continue learning. Los geht&apos;s!&lt;/p&gt;
&lt;h2&gt;Travelling&lt;/h2&gt;
&lt;p&gt;This was one thing I really spent much time doing in the past year; I explored many cities and 5 countries - Copenhagen Denmark, Oslo Norway, Stockholm Sweden, United Kingdom (London, Brighton, Sheffield, Doncaster) and Prague Czech Republic. Travelling helps you view life through the lens of different people; I met both friendly and reserved people during my escapade.&lt;/p&gt;
&lt;h2&gt;What&apos;s Next?&lt;/h2&gt;
&lt;p&gt;The year has presented a clean slate and I don&apos;t know what God has in stock for me in this new year. I pray that the chapters of my year bring more reasons to be joyful.&lt;/p&gt;
&lt;p&gt;I hope for an exciting 2023 - being in God&apos;s will, exploring more and living my best life.&lt;/p&gt;
&lt;p&gt;Cheers to the new year 🥂✨🚀&lt;/p&gt;</content:encoded></item><item><title><![CDATA[How to Update Git Commit Messages]]></title><description><![CDATA[Have you ever been in a situation where you press the Enter key after typing  and then realize that you made a mistake in your commit…]]></description><link>https://chiamakaikeanyi.dev/how-to-update-git-commit-messages/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/how-to-update-git-commit-messages/</guid><pubDate>Thu, 10 Mar 2022 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Have you ever been in a situation where you press the &lt;kbd&gt;Enter&lt;/kbd&gt; key after typing &lt;code class=&quot;language-text&quot;&gt;git commit -m &quot;Commit message&quot;&lt;/code&gt; and then realize that you made a mistake in your commit message or could have structured it in a better manner?&lt;/p&gt;
&lt;p&gt;Keep reading this article to understand how to update your Git commit messages.&lt;/p&gt;
&lt;p&gt;The set of commands needed depends on:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The state - whether the commit is recent or not&lt;/li&gt;
&lt;li&gt;The host - where the commit resides (local or remote repository)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Recent Git Commits&lt;/h2&gt;
&lt;p&gt;The &lt;code class=&quot;language-text&quot;&gt;--amend&lt;/code&gt; command is useful for changing recent commits.&lt;/p&gt;
&lt;p&gt;If you are yet to push the code to the remote repository, use:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;sh&quot;&gt;&lt;pre class=&quot;language-sh&quot;&gt;&lt;code class=&quot;language-sh&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; commit &lt;span class=&quot;token parameter variable&quot;&gt;--amend&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;New commit message&quot;&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; push origin &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;BRANCH_NAME&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;However, if you have pushed the code to the remote repository, use:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;sh&quot;&gt;&lt;pre class=&quot;language-sh&quot;&gt;&lt;code class=&quot;language-sh&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; commit &lt;span class=&quot;token parameter variable&quot;&gt;--amend&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;New commit message&quot;&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; push --force-with-lease origin &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;BRANCH_NAME&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Some people use &lt;code class=&quot;language-text&quot;&gt;--force&lt;/code&gt; but it is not advisable to do so; &lt;code class=&quot;language-text&quot;&gt;--force&lt;/code&gt; overwrites a remote branch with your local changes however, &lt;code class=&quot;language-text&quot;&gt;--force-with-lease&lt;/code&gt; do not overwrite the remote branch if more commits have been pushed to it by another contributor; the push fails and you would be able to pull the changes before attempting to push again.&lt;/p&gt;
&lt;h2&gt;Previous or Multiple Git Commits&lt;/h2&gt;
&lt;p&gt;Use &lt;code class=&quot;language-text&quot;&gt;git rebase&lt;/code&gt; when you need to update the Git commit message of earlier or multiple commits. Assuming you want to update the Git message of any/all of the last 3 commits, you can use the interactive Git rebase.&lt;/p&gt;
&lt;p&gt;To do this, navigate to the branch and type:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;sh&quot;&gt;&lt;pre class=&quot;language-sh&quot;&gt;&lt;code class=&quot;language-sh&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; rebase &lt;span class=&quot;token parameter variable&quot;&gt;-i&lt;/span&gt; HEAD~3&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This will autostash your changes and in this scenario show the last 3 commits.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;pick 62189aj9 Introduce usecase (#120)
pick 71f3n138 Write an example (#121)
pick b5gkwd2g Explain rebase (#122)

# Rebase ge816a67..b5gkwd2g onto ge816a67 (3 commands)
#
# Commands:
# p, pick &amp;lt;commit&gt; = use commit
# r, reword &amp;lt;commit&gt; = use commit, but edit the commit message
# e, edit &amp;lt;commit&gt; = use commit, but stop for amending
# s, squash &amp;lt;commit&gt; = use commit, but meld into previous commit
# f, fixup [-C | -c] &amp;lt;commit&gt; = like &quot;squash&quot; but keep only the previous
#                    commit&apos;s log message, unless -C is used, in which case
#                    keep only this commit&apos;s message; -c is same as -C but
#                    opens the editor
# x, exec &amp;lt;command&gt; = run command (the rest of the line) using shell
# b, break = stop here (continue rebase later with &apos;git rebase --continue&apos;)
# d, drop &amp;lt;commit&gt; = remove commit
# l, label &amp;lt;label&gt; = label current HEAD with a name
# t, reset &amp;lt;label&gt; = reset HEAD to a label&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To commence updating the messages:&lt;/p&gt;
&lt;p&gt;Press &lt;kbd&gt;i&lt;/kbd&gt; to enter an interactive mode. Navigate to the lines you want to update using your arrow keys and change &lt;code class=&quot;language-text&quot;&gt;pick&lt;/code&gt; to &lt;code class=&quot;language-text&quot;&gt;reword&lt;/code&gt;&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;pick 62189aj9 Introduce usecase (#120)
reword 71f3n138 Write an example (#121)
reword b5gkwd2g Explain rebase (#122)&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Press &lt;kbd&gt;esc&lt;/kbd&gt; to leave the interactive mode.&lt;/p&gt;
&lt;p&gt;Then, press &lt;kbd&gt;SHIFT + :&lt;/kbd&gt; and type &lt;code class=&quot;language-text&quot;&gt;wq&lt;/code&gt; to write your changes and quit the editor.&lt;/p&gt;
&lt;p&gt;An editor will be displayed to enable you update the commit message of each selected commit - one at a time. Based on the previous choice, this will list the last 3 commits and pre-load the message you need the update:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Write an example &amp;lt;!-- Change the message to what you want --&gt;

- Introduce usecase

- Write an example

- Explain rebase

# Please enter the commit message for your changes. Lines starting
# with &apos;#&apos; will be ignored, and an empty message aborts the commit.
# Date:      Wed Mar 9 21:51:30 2022 +0100
#
# interactive rebase in progress; onto ge816a67
# Last commands done (2 commands done):
#    pick 62189aj9 Introduce usecase (#120)
#    reword 71f3n138 Write an example (#121)
# Next command to do (1 remaining command):
#    reword b5gkwd2g Explain rebase (#122)&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Push the updated changes:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;sh&quot;&gt;&lt;pre class=&quot;language-sh&quot;&gt;&lt;code class=&quot;language-sh&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; push --force-with-lease origin &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;BRANCH_NAME&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;hr&gt;
&lt;div class=&quot;info&quot;&gt;
Asides from using the rebase command to update commit messages, it can act as a cleaner alternative to the merge command when integrating changes from another branch.
&lt;/div&gt;
&lt;p&gt;Should you merge or rebase? I&apos;ve been using merge for a long time but since I understood &lt;a href=&quot;https://git-scm.com/book/en/v2/Git-Branching-Rebasing&quot;&gt;how rebase works&lt;/a&gt;, it became my preferred option. It helps maintain a clean log as merge commits aren&apos;t added as part of the commit history.&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Whether you need to update a recent commit using &lt;code class=&quot;language-text&quot;&gt;git commit --amend -m &quot;New commit message&quot;&lt;/code&gt; or an older &lt;a href=&quot;/how-to-write-good-git-commit-messages/&quot;&gt;commit message&lt;/a&gt; using &lt;code class=&quot;language-text&quot;&gt;git rebase -i HEAD~n&lt;/code&gt;, this article explains the approach to achieve your aim.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[2021, A Year In My Life]]></title><description><![CDATA[Life do not happen by chance but as a result of grace and meaningful planning. 2020 taught me to appreciate freedom; 2021 taught me that…]]></description><link>https://chiamakaikeanyi.dev/2021-a-year-in-my-life/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/2021-a-year-in-my-life/</guid><pubDate>Thu, 03 Feb 2022 11:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Life do not happen by chance but as a result of grace and meaningful planning. &lt;a href=&quot;/2020-a-year-in-my-life&quot;&gt;2020 taught me to appreciate freedom&lt;/a&gt;; 2021 taught me that with grace, preparation and flexibility, anyone can progress in certain aspects of life. It was an eventful year and I&apos;m ever grateful to God for His mercies. The eventful nature spanned till the early days of this year thus having to write this article at this time.&lt;/p&gt;
&lt;p&gt;In this article, I will write on a few areas of my life that I&apos;m grateful for:&lt;/p&gt;
&lt;h2&gt;Relationship ‍&lt;/h2&gt;
&lt;p&gt;Maintaining vertical (God) and horiontal (humans) relationships is a major force of life. Despite all the bustle and hustle, if the Lord doesn&apos;t bless us, we labour in vain.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Except the LORD build the house, they labour in vain that build it: except the LORD keep the city, the watchman waketh but in vain. – Psalm 127:1&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;God has been ever faithful to me and has shown me favour; I remain grateful to Him for the love and favour. All I can say is &lt;em&gt;Chukwu okike dalu!&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Writing&lt;/h2&gt;
&lt;p&gt;I wrote some articles in 2021 though not as much as I would have loved to. But hey! I know you understand that I needed to prioritize my examinations and the eventful nature of the year - I tried out a lot of new things. I also published &lt;a href=&quot;https://chiamakaikeanyi.dev/what-is-event-bubbling-and-capturing-and-how-to-handle-them/&quot;&gt;a guest article&lt;/a&gt; on LogRocket and hope to write more articles this year.&lt;/p&gt;
&lt;h2&gt;Language&lt;/h2&gt;
&lt;p&gt;I achieved 164 day streak learning French and Deutsch on Duolingo but in a bid to achieve mastery in Deutsch, I started exploring YouTube videos.&lt;/p&gt;
&lt;h2&gt;Travelling&lt;/h2&gt;
&lt;p&gt;Travelling helps one gain insight into a lot of things in life: openness, tolerance, and accomodating other cultures. I see this as a means of widening one&apos;s horizon.&lt;/p&gt;
&lt;p&gt;2021 gave me the opportunity to explore other countries; I left the geographical location I&apos;ve known all through my life to explore other areas. I travelled to two countries - Accra Ghana and Berlin Germany, and I&apos;m grateful for all I&apos;ve learnt therein.&lt;/p&gt;
&lt;h2&gt;What&apos;s Next?&lt;/h2&gt;
&lt;p&gt;Opportunities come knocking even when we aren&apos;t seeking; I hope for an awesome 2022 - being in God&apos;s will, exploring more and living my best life.&lt;/p&gt;
&lt;p&gt;Cheers to the new year 🥂✨&lt;/p&gt;</content:encoded></item><item><title><![CDATA[What is Event Bubbling and Capturing and how to handle them?]]></title><description><![CDATA[I wrote an article for LogRocket on Deep Dive into Event Bubbling and Capturing. In the article, I explained how event bubbling and…]]></description><link>https://chiamakaikeanyi.dev/what-is-event-bubbling-and-capturing-and-how-to-handle-them/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/what-is-event-bubbling-and-capturing-and-how-to-handle-them/</guid><pubDate>Thu, 29 Jul 2021 07:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I wrote an article for LogRocket on &lt;a href=&quot;https://blog.logrocket.com/deep-dive-into-event-bubbling-and-capturing/&quot;&gt;Deep Dive into Event Bubbling and Capturing&lt;/a&gt;. In the article, I explained how event bubbling and capturing works with a practical example.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://blog.logrocket.com/deep-dive-into-event-bubbling-and-capturing/&quot;&gt;Read the article on LogRocket blog&lt;/a&gt; or continue below.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;If an element and its parent have an event handler for the same event, which element would fire first when triggered?&lt;/p&gt;
&lt;p&gt;Propagating events in JavaScript using bubbling and capturing provides developers with an answer to this question. In this article, you&apos;ll learn how event bubbling and capturing work, compare different methods for accessing event properties, and run through a few different examples and use cases.&lt;/p&gt;
&lt;p&gt;Let’s get started!&lt;/p&gt;
&lt;h2&gt;What is event capturing?&lt;/h2&gt;
&lt;p&gt;In event capturing, which is also known as trickling, the outer event handler fires before the specific handler fires. For example, the event on the &lt;code class=&quot;language-text&quot;&gt;div&lt;/code&gt; shown on the image triggers before the event on the button:&lt;/p&gt;
&lt;div class=&quot;note&quot;&gt;
Event capturing hierarchy = document → html → body → parent → child
&lt;/div&gt;
&lt;p&gt;Capturing has a higher priority than bubbling, meaning that capturing event handlers are executed before bubbling event handlers, as shown by the phases of event propagation:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Capturing phase : the event moves down towards the element&lt;/li&gt;
&lt;li&gt;Target phase:  the event reaches the target element&lt;/li&gt;
&lt;li&gt;Bubbling phase:  the event bubbles up from the element&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;What is event bubbling?&lt;/h2&gt;
&lt;p&gt;Event bubbling follows the opposite order as event capturing. An event propagates from a child HTML element, then moves up the DOM hierarchy to its parent elements:&lt;/p&gt;
&lt;div class=&quot;note&quot;&gt;
Event bubbling hierarchy = child → parent → body → html → document
&lt;/div&gt;
&lt;h2&gt;Listening to propagation events&lt;/h2&gt;
&lt;p&gt;We can listen to these propagation events using the &lt;code class=&quot;language-text&quot;&gt;addEventListener()&lt;/code&gt; method, which is appended to HTML nodes. It accepts three arguments: an event name, a callback function, and an optional capture value, which is set to &lt;code class=&quot;language-text&quot;&gt;false&lt;/code&gt; by default:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;element&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; handler&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Capture value is empty&lt;/h3&gt;
&lt;p&gt;Let’s review what will happen if a user clicks on the button when the capturing value is left blank:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;element&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; handler&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The click event begins in the capturing phase. It searches the parent elements of the target for any element with the event handler. It will &lt;em&gt;not find any event handler&lt;/em&gt; for the capturing phase.&lt;/p&gt;
&lt;p&gt;Next, it trickles down to the target. Once all events for the phase are executed, the event moves to its bubbling phase. It executes any event handler set on the target element. It propagates up again, searching through the target’s parent elements for any event handler for the bubbling phase. Now, the event cycle is complete.&lt;/p&gt;
&lt;h3&gt;Capture value is &lt;code class=&quot;language-text&quot;&gt;true&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;Let’s consider what happens if the capturing value is set to true:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;element&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; handler&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The code snippet above will follow the same order as when the value was empty. The key difference is that the event handler will execute any event handler it finds before trickling down to the target.&lt;/p&gt;
&lt;h2&gt;Accessing event object properties&lt;/h2&gt;
&lt;p&gt;There are differences in the methods used by handlers to access event object properties:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;event.target&lt;/code&gt;: refers to the DOM element that triggered the event&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;event.eventPhase&lt;/code&gt;: returns the current phase of event propagation (capturing: 1, target: 2, bubbling: 3)&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;event.currentTarget&lt;/code&gt;: refers to the DOM element that handles the event. It is usually accessed with the &lt;a href=&quot;https://chiamakaikeanyi.dev/demystifying-this-call-apply-and-bind/&quot;&gt;this&lt;/a&gt; keyword.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that if an event listener is attached to the parent, but event propagation is stopped by the child, &lt;code class=&quot;language-text&quot;&gt;event.currentTarget&lt;/code&gt; refers to the DOM element that stopped the propagation.&lt;/p&gt;
&lt;h2&gt;Event bubbling structure&lt;/h2&gt;
&lt;p&gt;Now that we understand how event bubbling and capturing work, let’s try an example! Let’s say we have the following DOM structure and the following event listener, respectively:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;cta_button&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Click me&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;document
  &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;.cta_button&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;click&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;type&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; event fired on &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;nodeName&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;Click event fired on BUTTON&lt;/code&gt; would be logged to the console.&lt;/p&gt;
&lt;h2&gt;Nested DOM structure&lt;/h2&gt;
&lt;p&gt;Let’s see what happens when the DOM structure is nested and uses the same event listener attached to the parent element:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;cta_container&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;cta_button&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Watch me bubble&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;document
  &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;.cta_container&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;click&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;type&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; event fired on &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;nodeName&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In the code snippet above, we set a click event listener on the &lt;code class=&quot;language-text&quot;&gt;div&lt;/code&gt;, the parent element of the button. When clicked, it logs the type of event fired and the element it is fired on.&lt;/p&gt;
&lt;p&gt;When users click the &lt;code class=&quot;language-text&quot;&gt;Watch me bubble&lt;/code&gt; button, the event is directed to the button. If an event handler is set for the button, the event is triggered. Otherwise, the event bubbles, or propagates, to the parent &lt;code class=&quot;language-text&quot;&gt;div&lt;/code&gt;, and a click event is fired on the parent. If the event is not handled, the process continues to the next parent at the outer bound until it eventually reaches the document object.&lt;/p&gt;
&lt;p&gt;Even though you clicked on the button, the information logged to the console is &lt;code class=&quot;language-text&quot;&gt;Click event fired on DIV&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Attach event listener to button&lt;/h2&gt;
&lt;p&gt;What happens when we also attach an event listener to the button?&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;cta_container&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;cta_button&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Watch me bubble&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;document
  &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;.cta_container&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;click&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;type&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; event fired on &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;nodeName&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

document
  &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;.cta_button&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;click&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;type&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; event fired on &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;nodeName&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The output becomes &lt;code class=&quot;language-text&quot;&gt;Click event fired on BUTTON&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;Click event fired on DIV&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;As you can see, the event bubbled to the parent. You can use the &lt;code class=&quot;language-text&quot;&gt;event.bubbles&lt;/code&gt; property to ascertain whether an event bubbles:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;document
  &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;.cta_button&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;click&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
      &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;type&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; event fired on &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;nodeName&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;. Does it bubble? &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;bubbles&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Stopping the propagation&lt;/h2&gt;
&lt;p&gt;An event on a DOM element propagates to all of its parent elements unless it is stopped. Although there is usually no need to prevent bubbling, it can be useful in certain cases. For example, stopping the propagation can prevent event handlers from interfering with each other.&lt;/p&gt;
&lt;p&gt;Consider handling drag-and-drop using &lt;code class=&quot;language-text&quot;&gt;mousemove&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;mouseup&lt;/code&gt; events. Stopping the propagation may prevent browser bugs that arise as a result of users randomly moving the mouse.&lt;/p&gt;
&lt;p&gt;Calling &lt;code class=&quot;language-text&quot;&gt;event.stopPropagation()&lt;/code&gt; on the child element prevents it from bubbling to the parent element:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;.cta_button&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;click&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token parameter&quot;&gt;event&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;stopPropagation&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// ...&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Let’s stop the propagation for our example from the previous section where we clicked a button:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;cta_container&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;cta_button&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Watch the bubble stop&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Let’s add the event listeners:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;document
  &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;.cta_container&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;click&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;type&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; event fired on &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;nodeName&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

document
  &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;.cta_button&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;click&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;stopPropagation&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;type&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; event fired on &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;nodeName&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The event was prevented from bubbling using &lt;code class=&quot;language-text&quot;&gt;event.stopPropagation()&lt;/code&gt;. The output becomes &lt;code class=&quot;language-text&quot;&gt;Click event fired on BUTTON&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Prevent browser default&lt;/h2&gt;
&lt;p&gt;Let’s say you want to allow the propagation to continue, but you want to prevent the browser from performing its default action if there is no listener handling the event. You can use &lt;code class=&quot;language-text&quot;&gt;event.preventDefault()&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;.cta_button&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;click&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token parameter&quot;&gt;event&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;preventDefault&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// ...&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Event bubbling use case&lt;/h2&gt;
&lt;p&gt;Let’s apply what we’ve covered and create a shopping list app that strikes an item once you purchase it. In this scenario, adding individual event listeners won’t be feasible because you may decide to add a new item in the future.&lt;/p&gt;
&lt;p&gt;Instead, you need to attach the event listener to the parent element of the list. The event listener will handle the click event from the children through event bubbling.&lt;/p&gt;
&lt;p&gt;In the code snippet below, we list our shopping items:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ul&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;list&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;item&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;MacBook Pro&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;item&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Logitech MX Keys&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;item&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Sony a6400 camera&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;item&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Boya universal cardioid microphone&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;item&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Light ring&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Attached an event listener to &lt;code class=&quot;language-text&quot;&gt;&amp;lt;ul&gt;&lt;/code&gt;, as seen below:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;.list&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;click&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token parameter&quot;&gt;event&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;target&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;classList&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;toggle&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;purchased&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can &lt;a href=&quot;https://codepen.io/chiamakaikeanyi/pen/mdWPoGK&quot;&gt;view this code on CodePen&lt;/a&gt; and open the console to view bubbling in action.&lt;/p&gt;
&lt;h2&gt;Event capturing structure&lt;/h2&gt;
&lt;p&gt;During event delegation, where event bubbling is not supported, event capturing becomes especially beneficial for attaching events to dynamic content. For example, you may need to handle events like &lt;code class=&quot;language-text&quot;&gt;focus&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;blur&lt;/code&gt; for which bubbling is not supported.&lt;/p&gt;
&lt;p&gt;To catch an event on the capturing phase, you need to set the &lt;code class=&quot;language-text&quot;&gt;useCapture&lt;/code&gt; option to &lt;code class=&quot;language-text&quot;&gt;true&lt;/code&gt;. Remember, by default, it is set to &lt;code class=&quot;language-text&quot;&gt;false&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;element&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; handler&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Let’s consider a nested DOM structure:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;cta_container&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;cta_button&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Watch me capture&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We’ll set the &lt;code class=&quot;language-text&quot;&gt;useCapture&lt;/code&gt; option of the parent element to &lt;code class=&quot;language-text&quot;&gt;true&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;.cta_container&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;.cta_container&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
  &lt;span class=&quot;token string&quot;&gt;&apos;click&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;type&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; event fired on &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;nodeName&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

document
  &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;.cta_button&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;click&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;type&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; event fired on &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;nodeName&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Contrary to what we get using bubbling, the output is &lt;code class=&quot;language-text&quot;&gt;Click event fired on DIV&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;Click event fired on BUTTON&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Event capturing use case&lt;/h2&gt;
&lt;p&gt;Let’s continue our example from earlier when we built a shopping list. If you wanted to add an input field to the shopping list that enables you to set a budget for each item, the event listener attached to the parent would not apply to those input fields.&lt;/p&gt;
&lt;p&gt;Let’s take the code for our shopping list and an event listener:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;h1&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;title&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Shopping List&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;h1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ul&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;list&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;item&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    MacBook Pro
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;budget&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;number&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;1&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;item&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    Logitech MX Keys
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;budget&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;number&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;1&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;item&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    Sony a6400 camera
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;budget&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;number&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;1&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;item&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    Boya universal cardioid microphone
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;budget&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;number&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;1&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;item&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    Light ring
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;budget&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;number&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;1&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;.list&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;focus&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;type&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; event fired on &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;nodeName&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;target&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;style&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;background &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;#eee&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;target:&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;target&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;currentTarget:&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;currentTarget&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;eventPhase:&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;eventPhase&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;When you focus the cursor on any input field, nothing happens. However, when you set the &lt;code class=&quot;language-text&quot;&gt;useCapture&lt;/code&gt; option to &lt;code class=&quot;language-text&quot;&gt;true&lt;/code&gt;, you’ll achieve the desired result:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;.list&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
  &lt;span class=&quot;token string&quot;&gt;&apos;focus&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;type&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; event fired on &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;nodeName&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;target&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;style&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;background &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;#eee&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;target:&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;target&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;currentTarget:&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;currentTarget&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;eventPhase:&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;eventPhase&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can &lt;a href=&quot;https://codepen.io/chiamakaikeanyi/pen/yLbbVGp?editors=1011&quot;&gt;view this list on CodePen&lt;/a&gt;, and open the console to view capturing in action.&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;A strong understanding of event bubbling and capturing is essential for handling user events in JavaScript. In this tutorial, we learned how event propagation works in JavaScript, following the sequence of capturing, target phase, and bubbling.&lt;/p&gt;
&lt;p&gt;Note that bubbling always propagates from a child element to the parent, while capturing propagates from the parent element to the child. To remember the propagation order, you can think of “bubble up and trickle down”.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[How to copy text with ease in JavaScript using the Clipboard API]]></title><description><![CDATA[Copying text especially code snippets or API key from web pages is a herculean task and I know a lot of developers would find the process of…]]></description><link>https://chiamakaikeanyi.dev/how-to-copy-text-with-ease-in-javascript-using-the-clipboard-api/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/how-to-copy-text-with-ease-in-javascript-using-the-clipboard-api/</guid><pubDate>Thu, 13 May 2021 16:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Copying text especially code snippets or API key from web pages is a herculean task and I know a lot of developers would find the process of selecting a combination of the CTRL or CMD key with the C key boring. This even gets more tasking when the snippet span through several lines.&lt;/p&gt;
&lt;p&gt;I implemented the &lt;em&gt;copy to clipboard&lt;/em&gt; feature on this site to improve your experience while reading my articles. In this article, I&apos;ll write about how I achieved this.&lt;/p&gt;
&lt;p&gt;I created this feature using the Clipboard API which is available on the &lt;code class=&quot;language-text&quot;&gt;navigator.clipboard&lt;/code&gt; object. &lt;a href=&quot;https://caniuse.com/?search=navigator.clipboard&quot;&gt;According to Can I Use&lt;/a&gt;, the Clipboard API is supported by major browsers and writing to the clipboard is available through user-initiated event callbacks like a click.&lt;/p&gt;
&lt;h2&gt;Handling a code block&lt;/h2&gt;
&lt;p&gt;Given the code,&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;stripHTML&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; code&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token regex&quot;&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-source language-regex&quot;&gt;(&amp;lt;([^&gt;]+)&gt;)&lt;/span&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-flags&quot;&gt;gi&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You need to add a copy functionality to make users aware that they can copy the code snippet.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;copy&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Copy&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To mitigate errors, you need to check for the availability of the Clipboard API before usage:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;navigator&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;clipboard&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// Clipboard API is not available&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then, add a click event listener to the &lt;em&gt;Copy&lt;/em&gt; text:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;.copy&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;click&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token parameter&quot;&gt;event&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;navigator&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;clipboard&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// Clipboard API is not available&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To copy the snippet to the Clipboard, grab the innerText of the element&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; codeBlock &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;.code&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;innerText&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Call the &lt;code class=&quot;language-text&quot;&gt;navigator.clipboard.writeText()&lt;/code&gt; method afterwards in a try/catch block to handle unforeseen errors. This yields the code:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;.copy&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;click&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token parameter&quot;&gt;event&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;navigator&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;clipboard&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// Clipboard API is not available&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; codeBlock &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;.code&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;innerText&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; navigator&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;clipboard&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;writeText&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;codeBlock&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;target&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;textContent &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Copied to clipboard&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;catch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;err&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;Failed to copy!&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; err&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Handling multiple code blocks&lt;/h2&gt;
&lt;p&gt;To attach the click event on multiple code elements, add the same class to the elements and call &lt;code class=&quot;language-text&quot;&gt;querySelectorAll()&lt;/code&gt; on the elements, then use &lt;code class=&quot;language-text&quot;&gt;forEach()&lt;/code&gt; to iterate over them.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelectorAll&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;.code&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;item&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  item&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;click&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token parameter&quot;&gt;event&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;navigator&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;clipboard&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token comment&quot;&gt;// Clipboard API is not available&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; navigator&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;clipboard&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;writeText&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;target&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;innerText&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;catch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;err&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;Failed to copy!&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; err&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;The ability to copy text to the clipboard with a single button click is an essential feature in web pages. I hope this helps.&lt;/p&gt;
&lt;p&gt;View the &lt;a href=&quot;https://codepen.io/chiamakaikeanyi/pen/KKwpQmo&quot;&gt;single clipboard content&lt;/a&gt; and &lt;a href=&quot;https://codepen.io/chiamakaikeanyi/pen/PopNopd&quot;&gt;multiple clipboard contents&lt;/a&gt; on Codepen.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[How to Group Tabs in Google Chrome]]></title><description><![CDATA[We easily get distracted by information vying for our attention on a daily basis. As a result, people tend to open a lot of tabs on their…]]></description><link>https://chiamakaikeanyi.dev/how-to-group-tabs-on-google-chrome/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/how-to-group-tabs-on-google-chrome/</guid><pubDate>Thu, 01 Apr 2021 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;We easily get distracted by information vying for our attention on a daily basis. As a result, people tend to open a lot of tabs on their personal computers and hardly return to them once their attention is diverted to something else. This results in tab clutter evident among professionals.&lt;/p&gt;
&lt;p&gt;The Google Chrome team analyzed this situation and released the tab group feature in the Google Chrome browser. For people with a lot of tabs opened and sometimes finding it difficult to navigate to the right tab, this is a useful feature. It makes it easy for users to organize tabs into different categories.&lt;/p&gt;
&lt;h2&gt;Steps Involved&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Right-click on a tab and select &lt;strong&gt;Add tab to new group&lt;/strong&gt; to create a tab group for the first time.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/tab-grouping1.png?raw=true&quot; alt=&quot;Add tab to new group&quot;&gt;&lt;/p&gt;
&lt;ol start=&quot;2&quot;&gt;
&lt;li&gt;A pop-up displays, assign a name to the group and choose a suitable color to distinguish the group.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/tab-grouping2.png?raw=true&quot; alt=&quot;Name the tab group&quot;&gt;&lt;/p&gt;
&lt;ol start=&quot;3&quot;&gt;
&lt;li&gt;You can add tabs to an existing group or create a new group for it. Right-click on another tab and click &lt;strong&gt;Add tab to group&lt;/strong&gt;, then, select an existing group you want to add it or select &lt;strong&gt;New group&lt;/strong&gt; to create a new group. Alternatively, you can drag a tab into an existing tab group and release your mouse once the tab has an outline of the desired tab group color.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/tab-grouping3.png?raw=true&quot; alt=&quot;Add tab to an existing group&quot;&gt;&lt;/p&gt;
&lt;p&gt;Collapse the tabs to help you stay organized. Note that you can drag a tab group to any position to reorder it.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/tab-grouping4.png?raw=true&quot; alt=&quot;Collapse tab groups&quot;&gt;&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Tab group is useful when you&apos;re working on different things at once and need to easily keep track of them. I hope this comes in handy and you share this article with your friends to help them stay organized and get rid of tab clutter.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[How to Setup SonarQube in VS Code]]></title><description><![CDATA[Have you been in a situation where you commit your code and SonarQube adds comments identifying bad coding styles to be resolved? You make…]]></description><link>https://chiamakaikeanyi.dev/how-to-setup-sonarqube-in-vscode/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/how-to-setup-sonarqube-in-vscode/</guid><pubDate>Thu, 04 Mar 2021 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Have you been in a situation where you commit your code and SonarQube adds comments identifying bad coding styles to be resolved? You make the changes and commit again and the issue still persists? This can be frustrating due to the continuous loop you find yourself in a bid to resolve the issue.&lt;/p&gt;
&lt;p&gt;In this article, you’ll learn how to set up SonarQube in Visual Studio Code (VS Code) to help combat the write and commit loop.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;SonarQube is an open-source platform developed by SonarSource for continuous inspection of code quality to perform automatic reviews with static analysis of code to detect bugs, code smells, and security vulnerabilities on 20+ programming languages. It offers reports on duplicated code, coding standards, unit tests, code coverage, code complexity, comments, bugs, and security vulnerabilities. - Wikipedia&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;Configuration Steps:&lt;/h2&gt;
&lt;p&gt;You would install SonarLint extension and bind the extension to your SonarQube server.&lt;/p&gt;
&lt;h3&gt;Step 1: Install SonarLint&lt;/h3&gt;
&lt;p&gt;SonarLint is an extension published by SonarSource that helps you detect and fix quality issues as you write code in JavaScript, TypeScript, Python, Java, HTML and PHP.&lt;/p&gt;
&lt;p&gt;In this step, you would need to add the extension to your VS Code. To access the extension,&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Go to VS Code View menu › Extensions&lt;/li&gt;
&lt;li&gt;Search for SonarLint in the marketplace&lt;/li&gt;
&lt;li&gt;Click on the extension&lt;/li&gt;
&lt;li&gt;Click on Install&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You can also &lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=SonarSource.sonarlint-vscode&quot;&gt;visit the Visual Studio Code marketplace to install SonarLint&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;SonarLint requires a JDK to be installed. A notification showing &lt;code class=&quot;language-text&quot;&gt;Java 8 or more recent is required to run. Please download and install a recent JRE.&lt;/code&gt; displays if you don&apos;t have the required JDK installed. Click on &lt;strong&gt;Get the Java Runtime Environment&lt;/strong&gt; to download and install the required JDK.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/notification.jpg?raw=true&quot; alt=&quot;Notification &quot;&gt;&lt;/p&gt;
&lt;h3&gt;Step 2: Open VS Code Global Settings&lt;/h3&gt;
&lt;p&gt;Changes made in this file are global. So, it will affect all your projects accessed with VS Code.&lt;/p&gt;
&lt;p&gt;To access the settings.json file,&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Press &lt;kbd&gt;CTRL + SHIFT + P&lt;/kbd&gt; or &lt;kbd&gt;Command + SHIFT + P&lt;/kbd&gt;&lt;/li&gt;
&lt;li&gt;Type &lt;strong&gt;Open Settings&lt;/strong&gt; and choose &lt;strong&gt;Preferences: Open Settings (JSON)&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You can also use the steps below if you have some settings already configured:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Click on the gear icon usually at the bottom-left corner of VS Code by default&lt;/li&gt;
&lt;li&gt;Click on the settings option to access the user settings&lt;/li&gt;
&lt;li&gt;Expand the Extensions category and navigate to the SonarLint section&lt;/li&gt;
&lt;li&gt;Under Sonarlint › Connected Mode › Connections: SonarQube, click on Edit in settings.json. This pre-populates the settings file with the key and an empty array as shown below:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;json&quot;&gt;&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token property&quot;&gt;&quot;sonarlint.connectedMode.connections.sonarqube&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;

  &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Step 3: Add SonarQube configuration&lt;/h3&gt;
&lt;p&gt;Add your server URL and token to settings.json&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;json&quot;&gt;&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token property&quot;&gt;&quot;sonarlint.connectedMode.connections.sonarqube&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;serverUrl&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;https://sonar.domain.com&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;token&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;V2VkIE1...&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Step 4: Generate SonarQube User Token&lt;/h3&gt;
&lt;p&gt;Access your SonarQube server e.g. &lt;a href=&quot;https://sonar.domain.com&quot;&gt;https://sonar.domain.com&lt;/a&gt; and log in with your credentials. Then, navigate to your Account settings at the top-right corner of the web page.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/account_settings.jpg?raw=true&quot; alt=&quot;Account settings&quot;&gt;&lt;/p&gt;
&lt;p&gt;Click on the Security tab and generate a token or use an existing token if you saved it somewhere. Copy the generated token and set it to the token in the example above.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/token.jpg?raw=true&quot; alt=&quot;Obtain a token&quot;&gt;&lt;/p&gt;
&lt;h3&gt;Step 5: Obtain the Project Key&lt;/h3&gt;
&lt;p&gt;Go to the SonarQube server, click on the Projects tab and find the project you need to configure. The key is usually in the URL e.g. &lt;a href=&quot;https://sonar.domain.com/dashboard?id=my-project-key&quot;&gt;https://sonar.domain.com/dashboard?id=my-project-key&lt;/a&gt;. It is also located at the bottom-right corner of the page. Copy the key. Now, you&apos;ll configure the project binding and set the copied project key to projectKey in the object.&lt;/p&gt;
&lt;h3&gt;Step 6: Configure the Project Binding&lt;/h3&gt;
&lt;p&gt;Configure the project binding in Sonarlint › Connected Mode: Project. This binds the current workspace folder to a SonarQube project. Binding a workspace folder to a project allows you to use the same code analyzers, rules and configuration that are defined in the server, as well as issue suppressions.&lt;/p&gt;
&lt;p&gt;To achieve this, create a folder named .vscode within the root directory of your application and add a file named settings.json within the .vscode folder. Changes made in this file are local. So, it will affect only the current folder.&lt;/p&gt;
&lt;p&gt;Add your configuration to the workspace settings. Ensure you enclose the snippet with curly braces.&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;json&quot;&gt;&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;sonarlint.connectedMode.project&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;projectKey&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;my-project-key&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Identifying SonarQube issues locally is hard. But, configuring it locally, helps you to identify the issues easily. I hope this helps you and your team.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[How to add a README to your GitHub Profile]]></title><description><![CDATA[GitHub released a feature to enable users add README to their GitHub profile. In this article I share steps on how to achieve this. Most…]]></description><link>https://chiamakaikeanyi.dev/how-to-add-a-readme-to-your-github-profile/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/how-to-add-a-readme-to-your-github-profile/</guid><pubDate>Thu, 25 Feb 2021 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;GitHub released a feature to enable users add README to their GitHub profile. In this article I share steps on how to achieve this.&lt;/p&gt;
&lt;p&gt;Most developers want to secure better jobs, get awesome opportunities or relocate to a different country. The GitHub profile README gives you the avenue to tell people who you are, what you do and how to connect with you. It&apos;s your space; make good use of it.&lt;/p&gt;
&lt;h2&gt;Getting Started&lt;/h2&gt;
&lt;p&gt;The GitHub profile README feature supports HTML, markdown, images etc. and is positioned above pinned repositories hence draws attention. Note that your repository must be public before your GitHub profile README can be displayed.&lt;/p&gt;
&lt;p&gt;To get started, visit &lt;a href=&quot;https://github.com/new&quot;&gt;https://github.com/new&lt;/a&gt; and create a new repository with the same name and letter case as your GitHub username. Once you type your username, a screen similar to the image above would be displayed.&lt;/p&gt;
&lt;p&gt;Initialize a README file and create the repository or clone the repository and create a README.md file locally. Initializing a README file populates the README.md with the default content similar to what is shown below. It generates your profile automatically.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;### Hi there 👋
&amp;lt;!--
**chiamakaikeanyi/chiamakaikeanyi** is a ✨ _special_ ✨
repository because its `README.md` (this file) appears on
your GitHub profile.
Here are some ideas to get you started:
- 🔭 I’m currently working on ...
- 🌱 I’m currently learning ...
- 👯 I’m looking to collaborate on ...
- 🤔 I’m looking for help with ...
- 💬 Ask me about ...
- 📫 How to reach me: ...
- 😄 Pronouns: ...
- ⚡ Fun fact: ...
--&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Edit the README.md and push the changes or just commit to the repository&apos;s main GitHub branch if you&apos;re using GitHub web interface.&lt;/p&gt;
&lt;p&gt;That&apos;s it! Creating a GitHub profile README in 4 steps.&lt;/p&gt;
&lt;p&gt;Check out &lt;a href=&quot;https://wesbos.com/mastering-markdown&quot;&gt;Wes Bos&apos; Mastering Markdown Mini Series&lt;/a&gt; if you&apos;re not conversant with Markdown.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[2020, A Year In My Life]]></title><description><![CDATA[Most times, we do not appreciate what we have till we lose it. 2019 gave us freedom, 2020 brought physical confinement. 2020 was a year that…]]></description><link>https://chiamakaikeanyi.dev/2020-a-year-in-my-life/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/2020-a-year-in-my-life/</guid><pubDate>Fri, 01 Jan 2021 20:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Most times, we do not appreciate what we have till we lose it. &lt;a href=&quot;/2019-a-year-in-my-life&quot;&gt;2019&lt;/a&gt; gave us freedom, 2020 brought physical confinement. 2020 was a year that taught us to be grateful for the things we see as little and take for granted - being alive, free and healthy.&lt;/p&gt;
&lt;p&gt;There&apos;s a lot to be thankful for in the year of the new normal. I actualized 90% of my goals for the year.&lt;/p&gt;
&lt;h2&gt;Relationship ‍&lt;/h2&gt;
&lt;p&gt;I spent most of my time indoors. Albeit, I met wonderful people online. In 2020, I established a closer online contact with my acquaintances. If statistics were to be taken, 2020 would be the year I spent the most number of hours on social platforms. I also spent the most time with my family since leaving home in 2016 in search of greener pastures. I can&apos;t substitute the memories shared within those months for anything in the world. I also maintained my relationship with my God.&lt;/p&gt;
&lt;h2&gt;Career&lt;/h2&gt;
&lt;p&gt;Despite people losing their jobs in 2020, I switched jobs for a better place. I had to study lines of codes across a lot of applications written by others. It was tough at first but the &lt;a href=&quot;/how-mpharmas-onboarding-process-sets-you-up-for-success&quot;&gt;atmosphere at the workplace&lt;/a&gt; helped me fit in quickly.&lt;/p&gt;
&lt;h2&gt;Writing&lt;/h2&gt;
&lt;p&gt;I improved and explored more writing options as planned. Since I began writing, 2020 was my first year of being paid for my article. I published &lt;a href=&quot;https://blog.logrocket.com/which-chrome-devtools-improve-accessibility/&quot;&gt;a guest article on LogRocket&lt;/a&gt;. I would dedicate more time to guest articles this year as one way to diversify my source of income.&lt;/p&gt;
&lt;h2&gt;Poetry&lt;/h2&gt;
&lt;p&gt;Poetry is one of the ways through which I express my thoughts. I published 10 musings in the form of &lt;a href=&quot;https://medium.com/poesie/archive/2020&quot;&gt;poems and spoken words&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;New Language&lt;/h2&gt;
&lt;p&gt;I started learning French on Duolingo in addition to German that I was previously learning. I hit 184 day streak. I haven&apos;t been this consistent. Feel free to &lt;a href=&quot;https://www.duolingo.com/profile/chiamaka_i&quot;&gt;add me&lt;/a&gt;, let&apos;s hit the target.&lt;/p&gt;
&lt;h2&gt;Fitness&lt;/h2&gt;
&lt;p&gt;I enrolled into Nike Training Club, became consistent, and completed 53 workouts. It&apos;s not a means of losing weight but just to tone muscles, stay fit and flexible.&lt;/p&gt;
&lt;h2&gt;What&apos;s Next?&lt;/h2&gt;
&lt;p&gt;Life is full of uncertainties and I&apos;ve learnt to embrace growth over goal mindset. All I wish for in 2021 is to be consistent, remain in God&apos;s will and put a smile on the faces of people around me.&lt;/p&gt;
&lt;p&gt;Cheers to the new year 🥂&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Leveraging Chrome developer tools to improve accessibility]]></title><description><![CDATA[Many designers and developers view accessibility as an afterthought. However, adhering to accessibility best practices leads to a higher…]]></description><link>https://chiamakaikeanyi.dev/leveraging-chrome-developer-tools-to-improve-accessibility/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/leveraging-chrome-developer-tools-to-improve-accessibility/</guid><pubDate>Fri, 20 Nov 2020 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Many designers and developers view accessibility as an afterthought. However, adhering to accessibility best practices leads to a higher customer retention rate and increases generated revenue. Browsers have evolved with more features to support accessibility.&lt;/p&gt;
&lt;p&gt;I wrote an article for LogRocket on &lt;a href=&quot;https://blog.logrocket.com/which-chrome-devtools-improve-accessibility/&quot;&gt;Which Chrome DevTools improve accessibility?&lt;/a&gt;. The tutorial explains how to boost accessibility with Lighthouse audits, Chrome&apos;s accessibility pane, and other features to improve user retention and revenue on your site.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://blog.logrocket.com/which-chrome-devtools-improve-accessibility/&quot;&gt;Read the article on LogRocket blog&lt;/a&gt; or continue below.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;In this article, you’ll learn how to leverage Chrome Developer Tools (DevTools) to identify and fix the accessibility bottlenecks of web pages you build.&lt;/p&gt;
&lt;p&gt;This article is for people who are familiar with accessibility best practices. You also need to have a basic understanding of DevTools.&lt;/p&gt;
&lt;h2&gt;Overview&lt;/h2&gt;
&lt;p&gt;As a frontend engineer who cares about how software solutions I build improve user experience, I use Chrome DevTools a lot.&lt;/p&gt;
&lt;p&gt;Chrome DevTools is a suite of web developer tools built into the Google Chrome browser. It divides into a series of panels which are further organized into panes.&lt;/p&gt;
&lt;p&gt;Try navigating a web page with a keyboard or assistive technology. Is the experience smooth? Are the elements standard-compliant? What can you do to improve its current state? With DevTools, you can identify and fix these issues.&lt;/p&gt;
&lt;p&gt;To access the DevTools panel, visit the webpage you want to audit using Google Chrome. Then, use the shortcut &lt;kbd&gt;Command + Shift + C&lt;/kbd&gt; on a Mac or &lt;kbd&gt;Control + Shift + C&lt;/kbd&gt; on Windows and Linux to view the DevTools.&lt;/p&gt;
&lt;p&gt;You would explore the different accessibility-related features in Chrome DevTools:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Lighthouse Audits panel&lt;/li&gt;
&lt;li&gt;Elements Inspector&lt;/li&gt;
&lt;li&gt;Contrast Ratio&lt;/li&gt;
&lt;li&gt;Accessibility Pane&lt;/li&gt;
&lt;li&gt;Emulating Colour Preferences&lt;/li&gt;
&lt;li&gt;Emulating Vision Deficiencies&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Lighthouse Audits Panel&lt;/h2&gt;
&lt;p&gt;The &lt;a href=&quot;https://developers.google.com/web/tools/lighthouse/&quot;&gt;Lighthouse&lt;/a&gt; Audits panel powered by &lt;a href=&quot;https://www.deque.com/axe/&quot;&gt;aXe&lt;/a&gt; is a good tool for auditing accessibility. The audit report is informative. It states what failed, why it failed, and provide links to resources to help you learn more.&lt;/p&gt;
&lt;p&gt;To audit a webpage, first open DevTools and click the Lighthouse panel. Uncheck other options, leaving only the accessibility option checked.&lt;/p&gt;
&lt;p&gt;Then, select the device you’d like to perform an audit on and click &lt;strong&gt;Generate Report&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/audits_panel.png?raw=true&quot; alt=&quot;Lighthouse Audits Panel&quot;&gt;&lt;/p&gt;
&lt;p&gt;Click the various sections of the generated report for tips on improving the &lt;a href=&quot;https://web.dev/accessibility-scoring&quot;&gt;accessibility score&lt;/a&gt;. The details on the passed audits are also useful.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/accessibility_score.png?raw=true&quot; alt=&quot;Lighthouse generated report&quot;&gt;&lt;/p&gt;
&lt;p&gt;There is detailed &lt;a href=&quot;https://web.dev/heading-order&quot;&gt;audit documentation for heading order&lt;/a&gt; provided as a resource for a failed heading order.&lt;/p&gt;
&lt;p&gt;It specifies the importance of the element that failed, how the Lighthouse heading levels audit fails, and how to fix poorly structured headings, among other information.&lt;/p&gt;
&lt;h2&gt;Elements inspector&lt;/h2&gt;
&lt;p&gt;The Inspect Element feature in DevTools gives you access to a tooltip with accessibility features at a glance. It shows up whenever you inspect an element on a web page.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/elements_inspector.png?raw=true&quot; alt=&quot;Elements inspector&quot;&gt;&lt;/p&gt;
&lt;p&gt;It displays the following properties:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Contrast Ratio: Measures the difference in brightness between the foreground and background color of the text.&lt;/li&gt;
&lt;li&gt;Name: The visible text&lt;/li&gt;
&lt;li&gt;Role: The function of the element (region, heading, button etc.). It displays “generic” for elements like &lt;code class=&quot;language-text&quot;&gt;&amp;lt;div&gt;&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;&amp;lt;span&gt;&lt;/code&gt; that have no semantic meaning&lt;/li&gt;
&lt;li&gt;Keyboard-focusable: Shows if you can focus on an element using your keyboard. A grey color shows that the element is not keyboard-focusable. Green shows that the element is keyboard-accessible.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Contrast Ratio&lt;/h2&gt;
&lt;p&gt;The Contrast Ratio feature measures the difference in brightness between the foreground and background color of the content of web pages. This will help when choosing the color scheme for your web pages during the design phase. Always ask yourself if the color you are about to choose meets the accessibility standard.&lt;/p&gt;
&lt;p&gt;A high contrast ratio is the desired value for any content viewed by users. Low vision users or users affected by environmental factors may not be able to see the content on your web page if you don’t maintain a high contrast ratio.&lt;/p&gt;
&lt;p&gt;Imagine a user viewing a web page with a low contrast ratio under the effect of sunlight. The user’s experience would be terrible.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;WCAG requires “at least 4.5:1” contrast, so you cannot round a contrast ratio up to 4.5:1. For example, #777777 is a commonly-used shade of gray with a 4.48:1 contrast ratio. It does not meet the WCAG contrast threshold.
&lt;a href=&quot;https://webaim.org/articles/contrast/&quot;&gt;Contrast and Color Accessibility&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/contrast_ratio.png?raw=true&quot; alt=&quot;Contrast Ratio&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;The Contrast Ratio section of the Color Picker shows 2 checkmarks and the value of 10.39.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;You can use the color picker to choose colors that meet the standard. To access this feature, inspect a text using the Element Inspector tool. Then, locate the color property on the styles pane.&lt;/p&gt;
&lt;p&gt;Click the elements color preview, which is a small square on the left-hand side of the value. Locate the current contrast ratio section and click on the downward pointing arrow to view more details.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/contrast_ratio_passed.png?raw=true&quot; alt=&quot;Good contrast Ratio&quot;&gt;&lt;/p&gt;
&lt;p&gt;A single checkmark indicates that the element meets the &lt;a href=&quot;https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html&quot;&gt;minimum recommendation&lt;/a&gt; (AA). Strive to meet the &lt;a href=&quot;https://www.w3.org/WAI/WCAG21/Understanding/contrast-enhanced&quot;&gt;enhanced recommendation&lt;/a&gt; (AAA) indicated by two checkmarks.&lt;/p&gt;
&lt;p&gt;A line or two appears on the color palette. Clicking on the region a bit higher reduces it to the minimum recommendation. Anything beyond that would not meet the minimum recommendation.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/contrast_ratio_failed.png?raw=true&quot; alt=&quot;Bad contrast Ratio&quot;&gt;&lt;/p&gt;
&lt;p&gt;The Contrast Ratio section of the Color Picker shows 1 checkmark and a value of 3.69.&lt;/p&gt;
&lt;h2&gt;Accessibility pane&lt;/h2&gt;
&lt;p&gt;The Accessibility pane provides insight into the accessibility tree, ARIA attributes, and computed accessibility properties of DOM nodes.&lt;/p&gt;
&lt;p&gt;You may already be familiar with ARIA, but here’s a brief description for those who do not know what it is.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Accessible Rich Internet Applications (ARIA), referred to as the Web Accessibility Initiative Accessible Rich Internet Applications (WAI-ARIA), is defined by WAI as a way to make web content and web applications (especially dynamic content and advanced user interfaces) more accessible to people with disabilities.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Check out the code snippet for a modal below:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-modal&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;true&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Add modal content&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The &lt;code class=&quot;language-text&quot;&gt;aria-modal&lt;/code&gt; attribute adds semantic meaning to the div. Assistive technologies such as a braille or screen reader would perceive the div as a modal, which is the intended behavior.&lt;/p&gt;
&lt;p&gt;ARIA however, may hurt the accessibility of web pages if not properly used. Note the first rule of ARIA use:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;If you can use a native HTML element [HTML5.1] or attribute with the semantics and behavior you require already built in, instead of re-purposing an element and adding an ARIA role, state or property to make it accessible, then do so. - &lt;a href=&quot;https://www.w3.org/TR/using-aria/#rule1&quot;&gt;Using ARIA&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;To use the accessibility pane, open DevTools. Then, inspect any element on the page. Click the accessibility pane located under the elements panel.&lt;/p&gt;
&lt;p&gt;The accessibility pane is often hidden, so open DevTools and press Command+Shift+P on Mac or Control+Shift+P on Windows and Linux to open the command menu. The command menu is an autocomplete search field. Search for Show Accessibility, and then press Enter to run a command that opens the pane.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/accessibility_pane.png?raw=true&quot; alt=&quot;Accessibility pane&quot;&gt;&lt;/p&gt;
&lt;p&gt;The information on the &lt;strong&gt;accessibility tree&lt;/strong&gt; displays elements from the DOM tree that are useful for perceiving the content of the page by assistive technologies.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;ARIA attributes&lt;/strong&gt; list the properties on these elements. The &lt;strong&gt;computed properties&lt;/strong&gt; section displays properties computed by the browser.&lt;/p&gt;
&lt;p&gt;It’s okay if the inspected element has no value specified for these ARIA attributes and properties. Semantic elements do not need them, as they already have meaning.&lt;/p&gt;
&lt;p&gt;Going through these details will help you check if you are building for a wider audience or restricting your scope.&lt;/p&gt;
&lt;h2&gt;Emulating color preferences&lt;/h2&gt;
&lt;p&gt;Dark mode helps the eyes by exposing it to less light. You can use the DevTools to simulate how users perceive your web pages. The available options are no-preference, light, and dark.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: This is only available on websites that implement the &lt;a href=&quot;https://drafts.csswg.org/mediaqueries-5/#prefers-color-scheme&quot;&gt;Media Queries Level 5&lt;/a&gt; user preference media feature.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/preferred_color_scheme.png?raw=true&quot; alt=&quot;Color preferences&quot;&gt;&lt;/p&gt;
&lt;p&gt;To access this feature, open DevTools and press &lt;kbd&gt;Command+Shift+P&lt;/kbd&gt; on Mac or &lt;kbd&gt;Control+Shift+P&lt;/kbd&gt; on Windows and Linux to open the Command Menu. Then, search for and select &lt;strong&gt;Show Rendering&lt;/strong&gt; to enable the rendering tab.&lt;/p&gt;
&lt;p&gt;Finally, navigate to &lt;strong&gt;Emulate CSS media feature prefers-color-scheme&lt;/strong&gt; section and select an option from the available options.&lt;/p&gt;
&lt;h2&gt;Emulating vision deficiencies&lt;/h2&gt;
&lt;p&gt;Emulating vision deficiencies is one of the key accessibility features to use to ensure that you &lt;a href=&quot;https://www.w3.org/WAI/GL/low-vision-a11y-tf/wiki/Overview_of_Low_Vision#Color_Perception&quot;&gt;leave no user behind&lt;/a&gt;. Consider not using color or images alone to convey information. Chrome DevTools has this feature built-in.&lt;/p&gt;
&lt;p&gt;To access this feature, open DevTools and press &lt;kbd&gt;Command+Shift+P&lt;/kbd&gt; on Mac or &lt;kbd&gt;Control+Shift+P&lt;/kbd&gt; on Windows and Linux to open the Command Menu. Then, search for and select &lt;strong&gt;Show Rendering&lt;/strong&gt; to enable to rendering tab. Navigate to the Emulate Vision Deficiencies pane and select an option from the available options.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/vision_deficiencies.png?raw=true&quot; alt=&quot;Vision deficiencies&quot;&gt;&lt;/p&gt;
&lt;p&gt;The available options are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;No emulation: No vision deficiency&lt;/li&gt;
&lt;li&gt;Blurred vision: Decreased clarity in vision&lt;/li&gt;
&lt;li&gt;Protanopia: Inability to perceive red light&lt;/li&gt;
&lt;li&gt;Deuteranopia: Inability to perceive green light&lt;/li&gt;
&lt;li&gt;Tritanopia: Inability to perceive blue light&lt;/li&gt;
&lt;li&gt;Achromatopsia: Absence of color vision. Sees only black, white, and shades of grey.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Knowing that people who visit your website do not always perceive it as you do will help you build each feature you ship with accessibility in mind.&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;DevTools have evolved with more features to support accessibility that are not known by developers. In this article, you explored features you can leverage to improve website accessibility.&lt;/p&gt;
&lt;p&gt;You used the Lighthouse Audits panel to audit the web page and fix failed audits, as well as the Elements Inspector to view the contrast ratio, name, role and keyboard-focusable properties at a glance. You used Contrast Ratio to ensure that foreground and background colors meet the recommended contrast ratio. Finally, You used the Accessibility Pane to gain insight into the accessibility tree, ARIA attributes and computed accessibility properties of DOM nodes.&lt;/p&gt;
&lt;p&gt;You also emulated color preferences and vision deficiencies your users may have.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Event Debouncing and Throttling in JavaScript]]></title><description><![CDATA[Key stroke, click, resize, scroll events, etcetera add performance overhead to applications if we respond to these events each time they are…]]></description><link>https://chiamakaikeanyi.dev/event-debouncing-and-throttling-in-javascript/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/event-debouncing-and-throttling-in-javascript/</guid><pubDate>Thu, 01 Oct 2020 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Key stroke, click, resize, scroll events, etcetera add performance overhead to applications if we respond to these events each time they are fired. The aim is to limit the number of times a function is called in response to events.&lt;/p&gt;
&lt;p&gt;In this article, I’ll explain how debounce and throttle works and how to use these rate-limiting techniques to improve the performance of your applications.
Request Animation Frame is also another way to handle rate-limiting but we will not cover it in this article.&lt;/p&gt;
&lt;h2&gt;Debounce&lt;/h2&gt;
&lt;p&gt;Debounce is a rate-limiting technique that forces a function to execute only once after a set time. It is a higher-order function, i.e. a function that returns another function. It forms a closure around the function parameters.&lt;/p&gt;
&lt;p&gt;Sample use cases:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Updating the search result as the user types in a search term.&lt;/li&gt;
&lt;li&gt;Validating an input field as the user inputs a value.&lt;/li&gt;
&lt;li&gt;Automatically saving contents of a page as the user types.&lt;/li&gt;
&lt;li&gt;Updating details of selected items as the user modifies the selection.&lt;/li&gt;
&lt;li&gt;Updating contents of a cart as the user clicks the add to cart button several times in succession.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When a user inputs a search term into a search field and a function is called for each keystroke, it harms performance and add unnecessary load to the backend services. Debounce solves this problem. It delays the function invocation until a certain number of keystrokes are recorded or the user stops typing, thereby optimizing resources.&lt;/p&gt;
&lt;p&gt;We have two methods of debouncing:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Trailing Debounce&lt;/li&gt;
&lt;li&gt;Leading Debounce&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Trailing Debounce&lt;/h3&gt;
&lt;p&gt;This is the default way of debouncing. It postpones execution until after an interval has elapsed since the last time the function was invoked. Simply put, it groups successive events and sends the requests as one to the backend service.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/**
 * @param {*} ctx The context
 * @param {function} func The function to execute after the debounce time
 * @param {number} delay The amount of time to wait
 * @return {function} The debounced function
 */&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;debounce&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;context&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; func&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; delay&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; timeout&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;arguments&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;timeout&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token function&quot;&gt;clearTimeout&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;timeout&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

    timeout &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;setTimeout&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token function&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;apply&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;context&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; arguments&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; delay&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Our function passed as a parameter spreads its parameters to allow the debounce function receive any number of parameters to pass to the callback.&lt;/p&gt;
&lt;p&gt;Once you pass the function and set the time interval, a debounced function is returned that you can pass to the event listeners.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; debouncedSearchState &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;debounce&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token parameter&quot;&gt;searchTerm&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getSearchResult&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;searchTerm&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// an expensive function&lt;/span&gt;
  &lt;span class=&quot;token number&quot;&gt;1000&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The code snippet below calls the debounced function in response to the onChange event handler, &lt;em&gt;debouncedSearchState&lt;/em&gt; after the time interval has elapsed.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;onChange&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;debouncedSearchState&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;searchTerm&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Leading Debounce&lt;/h3&gt;
&lt;p&gt;You may prefer not to keep the user waiting but trigger an action in response to an event immediately. Then, stop triggering in response to successive requests until there is a pause in the requests.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://codepen.io/chiamakaikeanyi/pen/RwrOgGq&quot;&gt;View the code on CodePen&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Throttle&lt;/h2&gt;
&lt;p&gt;Throttle prevents a function from executing more than once every specified amount of time.
It guarantees the function execution once every specified amount of time. Throttle is unlike debounce that do not execute the function if there is no pause in successive requests made.&lt;/p&gt;
&lt;p&gt;Sample use case:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Requesting more content when the user is close to the bottom of a page during an infinite scroll.&lt;/li&gt;
&lt;li&gt;Checking the scroll position at a set interval to trigger a CSS animation.&lt;/li&gt;
&lt;li&gt;Preventing a function call when a button is clicked to avoid spam click.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;throttle&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;context&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; func&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; limit&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; lastFunc&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; lastRan&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;arguments&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;lastRan&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token function&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;apply&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;context&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; arguments&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
      lastRan &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Date&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;now&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token function&quot;&gt;clearTimeout&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;lastFunc&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
      lastFunc &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;setTimeout&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Date&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;now&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; lastRan &lt;span class=&quot;token operator&quot;&gt;&gt;=&lt;/span&gt; limit&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
          &lt;span class=&quot;token function&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;apply&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;context&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; arguments&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
          lastRan &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Date&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;now&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; limit &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Date&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;now&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; lastRan&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;iframe height=&quot;350&quot; style=&quot;width: 100%;&quot; scrolling=&quot;no&quot; title=&quot;Debounce and Throttle&quot; src=&quot;https://codepen.io/chiamakaikeanyi/embed/RwrOgGq?height=339&amp;theme-id=dark&amp;default-tab=js,result&quot; frameborder=&quot;no&quot; loading=&quot;lazy&quot; allowtransparency=&quot;true&quot; allowfullscreen=&quot;true&quot;&gt;
  See the Pen &lt;a href=&apos;https://codepen.io/chiamakaikeanyi/pen/RwrOgGq&apos;&gt;Debounce and Throttle&lt;/a&gt; by Chiamaka Ikeanyi
  (&lt;a href=&apos;https://codepen.io/chiamakaikeanyi&apos;&gt;@chiamakaikeanyi&lt;/a&gt;) on &lt;a href=&apos;https://codepen.io&apos;&gt;CodePen&lt;/a&gt;.
&lt;/iframe&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;Use debounce and throttle to optimize your JavaScript event handlers and improve your application performance and user experience. Both are similar but have their use cases.&lt;/p&gt;
&lt;p&gt;Conclusively, use &lt;em&gt;debounce&lt;/em&gt; to group successive events and &lt;em&gt;throttle&lt;/em&gt; to guarantee function execution once every specified amount of time.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Using Chrome DevTools to Emulate Vision Deficiencies]]></title><description><![CDATA[The more customer-focused a business is, the more people they put into consideration during brainstorming sessions. This lead to better…]]></description><link>https://chiamakaikeanyi.dev/using-chrome-devtools-to-emulate-vision-deficiencies/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/using-chrome-devtools-to-emulate-vision-deficiencies/</guid><pubDate>Thu, 03 Sep 2020 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;The more customer-focused a business is, the more people they put into consideration during brainstorming sessions. This lead to better design decisions and user experience which in turn yields more revenue. Simply put, businesses built with empathy in mind leads to more revenue being generated.&lt;/p&gt;
&lt;p&gt;Emulating vision deficiencies on your website or web application is one of the key accessibility features to consider to ensure that you leave no one behind. Luckily enough, web developer tools has evolved over the years with a lot more support for accessibility.&lt;/p&gt;
&lt;p&gt;In this guide, you will emulate different vision deficiencies your users may have. This would enable you build usable software solutions.&lt;/p&gt;
&lt;h2&gt;Prerequisite&lt;/h2&gt;
&lt;p&gt;Before you begin, you would need a Google Chrome browser&lt;/p&gt;
&lt;h2&gt;Usage&lt;/h2&gt;
&lt;p&gt;The entire process involves 4 steps.&lt;/p&gt;
&lt;h3&gt;Step 1 - Accessing the DevTools&lt;/h3&gt;
&lt;p&gt;Before you can proceed, you need to open the DevTools panel.&lt;/p&gt;
&lt;p&gt;To access the DevTools panel, use &lt;kbd&gt;CTRL + Shift + J&lt;/kbd&gt; on Windows and Linux environments or &lt;kbd&gt;Command + Option + J&lt;/kbd&gt; on a Mac environment.&lt;/p&gt;
&lt;h3&gt;Step 2 - Accessing the Command Menu&lt;/h3&gt;
&lt;p&gt;Use &lt;kbd&gt;Control + Shift + P&lt;/kbd&gt; to access the command menu on Windows and Linux environments. On a Mac environment, use &lt;kbd&gt;Command + Shift + P&lt;/kbd&gt;.&lt;/p&gt;
&lt;h3&gt;Step 3 - Enable the Rendering Tab&lt;/h3&gt;
&lt;p&gt;Type and select &lt;em&gt;rendering&lt;/em&gt; in the search field to enable the rendering tab if it is not already enabled.&lt;/p&gt;
&lt;h3&gt;Step 4 - Emulate Vision Deficiencies&lt;/h3&gt;
&lt;p&gt;Navigate to Emulate vision deficiencies section and select an option from the available options.&lt;/p&gt;
&lt;p&gt;The available options are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;No emulation: No vision deficiency&lt;/li&gt;
&lt;li&gt;Blurred vision: Decreased clarity in vision&lt;/li&gt;
&lt;li&gt;Protanopia: Inability to perceive red light&lt;/li&gt;
&lt;li&gt;Deuteranopia: Inability to perceive green light&lt;/li&gt;
&lt;li&gt;Tritanopia: Inability to perceive blue light&lt;/li&gt;
&lt;li&gt;Achromatopsia: Absence of color vision. Sees only black, white, and shades of gray.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;In this article, you emulated the different vision deficiencies your users may have. Now, knowing that people who visit your websites or use your web applications do not always perceive it as you do will enable you consider inclusion for each feature you ship to your users.&lt;/p&gt;
&lt;p&gt;Read my article on &lt;a href=&quot;/building-accessible-web-apps/&quot;&gt;Building Accessible Web Apps&lt;/a&gt; to understand more about accessibility.&lt;/p&gt;
&lt;p&gt;Never forget the mantra:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Leave no one behind.&lt;/p&gt;
&lt;/blockquote&gt;</content:encoded></item><item><title><![CDATA[How mPharma's onboarding process sets you up for success ]]></title><description><![CDATA[I, like many others set goals and build atomic habits to help achieve these goals. One of my goals last year was to explore new grounds…]]></description><link>https://chiamakaikeanyi.dev/how-mpharmas-onboarding-process-sets-you-up-for-success/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/how-mpharmas-onboarding-process-sets-you-up-for-success/</guid><pubDate>Thu, 06 Aug 2020 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I, like many others set goals and build atomic habits to help achieve these goals. One of my goals last year was to explore new grounds.&lt;/p&gt;
&lt;p&gt;Sequel to this, I left &lt;a href=&quot;https://www.konga.com/?k_id=1042900&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Konga&lt;/a&gt;, one of the 2 major players in the e-commerce sector in Nigeria to &lt;a href=&quot;https://mpharma.com&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;mPharma&lt;/a&gt;; a company headquartered in Ghana, with the vision of providing access to safe and affordable health care in Africa.&lt;/p&gt;
&lt;p&gt;The interview process was a long one. All the 4 stages were done virtually. It took series of months to finally get through to the last stage . Despite being long, it was realistic. I solved a problem similar to what I was expected to solve if I succeed and finally get hired.&lt;/p&gt;
&lt;p&gt;Throughout the onboarding process, it was clear to me that the company is organised. I was being set up for all round success. I would share the things &lt;strong&gt;mpharmily&lt;/strong&gt; as fondly called did so well that made me &lt;em&gt;doff my hat&lt;/em&gt; for the human capital team. This is from the perspective of a new hire on the Engineering team. I hope your team would borrow a leaf from mPharma.&lt;/p&gt;
&lt;h2&gt;I received a warm welcome&lt;/h2&gt;
&lt;p&gt;I felt special on my first day as people from different departments flooded Slack with awesome welcome messages. One of the notes that stood out was the one that read &lt;em&gt;Akwaaba&lt;/em&gt;, meaning welcome in Ghana. I quickly headed over to Google Translate to get the appropriate response  - &lt;em&gt;medaase&lt;/em&gt; (pronounced &apos;me-daa-si&apos;) which means thank you in Twi. 😄&lt;/p&gt;
&lt;h2&gt;The team is proactive&lt;/h2&gt;
&lt;p&gt;Prior to my first day, I received an email from the human capital team requesting for necessary information to help the team prepare me for my first day. The team set up my email account and shared the necessary documents that would enable me understand the mPharma process.&lt;/p&gt;
&lt;p&gt;My manager wasn&apos;t left out. On the first day, he set up a meeting to walk me through solutions the team is building. He also showed me the applications dependent on other chapters that I need to know about and requested that I should be given access to them and invited to meetings.&lt;/p&gt;
&lt;p&gt;My team mates were responsive. They had answers to majority of my questions. I kept them flowing as I needed to understand the process and architecture of the existing systems.&lt;/p&gt;
&lt;h2&gt;Series of meetings to understand the process&lt;/h2&gt;
&lt;p&gt;The first week was lined up with schedules to help me understand the problem mPharma is solving. The human capital team shared the itinerary on the first day to help me prepare questions for the team to answer. Each team had representatives that expounded what the department do and the challenges they aim to solve. At the end of the meeting with each team, I was expected to comfortably respond to a set of questions regarding the departments; tools they use, challenges they are faced with and their approach towards solving the problems.&lt;/p&gt;
&lt;p&gt;Being a data-driven organisation, the Engineering team is at the helm of affairs. The information gathered from the teams enlightened me on the intersection of the Engineering team and other teams toward meeting organisational goals.&lt;/p&gt;
&lt;p&gt;I met awesome individuals with a large heart happy to have me join the team and ready to make my integration process as smooth as possible.&lt;/p&gt;
&lt;h2&gt;Meeting with the crew&lt;/h2&gt;
&lt;p&gt;On my second day, the VP of Engineering set up a Zoom call so I could meet the crew. The crew consists of different chapters further divided into squads. I couldn&apos;t say much during the meeting as I was looking at new faces from different parts of the world who I would be working with.&lt;/p&gt;
&lt;h2&gt;The team assigns you a buddy&lt;/h2&gt;
&lt;p&gt;At mPharma, new employees are assigned a buddy. What makes it different is that the employee must be someone that is not on the same team with you. Your buddy is expected to answer any question you may have regarding the mPharma way of life. This approach aims to expand your network so, you&apos;re not just expected to interact with your squad, chapter or crew alone.&lt;/p&gt;
&lt;h2&gt;You are expected to go through the mPharma academy&lt;/h2&gt;
&lt;p&gt;The academy is made up of courses to help you integrate better at the workplace. It consists of courses on communication, workplace best practices, time and stress management, leadership and teamwork, emotional intelligence etc.&lt;/p&gt;
&lt;p&gt;Every new hire is expected to complete the academy within the specified time. It was stressful at first for me but I quickly had to adjust my schedule to enable me complete the courses. There is a curriculum for the first 30, 60 and 90 days. After each round, you are expected to fill a survey. The survey helps the human capital team understand how new employees cope with the onboarding process.&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Onboarding process can be tough, but a well planned process helps in a seamless integration of new employees. mPharma did really well in making the process a memorable one.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Receiving a warm welcome let me know that I am in an environment where I can be free to air my opinions.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The team being proactive is a sign that there is no room to slack.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Series of meetings to understand the process is a hint that to properly build solutions, I need to understand the problem.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Meeting with the crew showed me that beyond the work, there is a human side of being part of mpharmily.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The team assigning me a buddy in a different team let me know that to excel in my career, I need to expand my network.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Going through the mPharma academy prepared me for work-life balance, demo days, managing my emotions at the workplace and overall, to be a team player.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The onboarding process was a lot like building atomic habits because with each of these salient points, I&apos;m being moulded into a better employee and set up for all round success.&lt;/p&gt;
&lt;p&gt;Feel free to reach out to me on &lt;a href=&quot;https://twitter.com/chiamakaikeanyi&quot;&gt;Twitter&lt;/a&gt; regarding what you feel about the process and what works at the organisation you work. I will be glad to hear from you.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Hoisting]]></title><description><![CDATA[Hoisting is a popularly known term in JavaScript but do you understand how it works? If you've been able to invoke a function on a line…]]></description><link>https://chiamakaikeanyi.dev/hoisting/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/hoisting/</guid><pubDate>Thu, 02 Jul 2020 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Hoisting is a popularly known term in JavaScript but do you understand how it works? If you&apos;ve been able to invoke a function on a line prior to the line it was declared, read on to understand why.&lt;/p&gt;
&lt;p&gt;In this article, we&apos;ll explore how hoisting works in JavaScript. But before we proceed, you need to understand certain concepts.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;In JavaScript, there are two stages during code execution: the compilation phase and the execution phase.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Calling an undefined variable results to a reference error&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;myVariable&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Uncaught ReferenceError: myVariable is not defined&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;An undeclared variable is assigned the type of undefined&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;typeof&lt;/span&gt; myVariable&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// undefined&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now that you understand these points, let&apos;s find out what hoisting means.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Hoisting is the act of putting variable and function declarations into memory during the compile phase. It is a general way of thinking about how execution contexts (the creation and execution phases) work in JavaScript.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Let&apos;s look at some code snippets for better understanding.&lt;/p&gt;
&lt;h2&gt;Variable Declaration&lt;/h2&gt;
&lt;p&gt;The widely known way of declaring a variable is:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; a &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Read more&apos;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// let or const&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Declaration and initialization takes place.&lt;/p&gt;
&lt;p&gt;Now, let&apos;s look at other scenarios where this is not the case.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Initialize a. Declares it if it&apos;s not already declared. No hoisting occurs.&lt;/span&gt;
a &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Read&apos;&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;a &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos; &apos;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; b&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// &apos;Read undefined&apos;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// Declare and initialize b. The value of b is not hoisted.&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; b &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;more&apos;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Wouldn&apos;t this result to a reference error since the variable was called before it was declared? you may ask. Well, that is not the case because of hoisting. Only the declaration (var b), not the initialization (=&apos;more&apos;) is hoisted. This results to b being assigned a value of undefined.&lt;/p&gt;
&lt;p&gt;The code is executed in this order:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Initialize a. Declares it if it&apos;s not already declared. No hoisting occurs.&lt;/span&gt;
a &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Read&apos;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; b &lt;span class=&quot;token comment&quot;&gt;// Stores the variable b in memory&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;a &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos; &apos;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; b&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// &apos;Read undefined&apos;&lt;/span&gt;
b &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;more&apos;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;But, you can use a variable before it is declared.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;a &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Read&apos;&lt;/span&gt;
b &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;more&apos;&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;a &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos; &apos;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; b&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// &apos;Read more&apos;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// Declare b. b is hoisted&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; b&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&apos;info&apos;&gt;
JavaScript only hoists declarations, not initializations. The value of an initialized variable returns undefined once it is used.
&lt;p&gt;However, in strict mode, variables cannot be used if they are not declared.&lt;/p&gt;
&lt;/div&gt;
&lt;h2&gt;Function Scoped Variables&lt;/h2&gt;
&lt;p&gt;Note that hoisting is scoped. This means that if variables are defined within a function, it is made available &lt;em&gt;only&lt;/em&gt; within that function scope. Using it outside the scope results to a reference error. It is made available to the global scope only if it is declared outside a function.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;b&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Uncaught ReferenceError: b is not defined&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getB&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; b
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;b&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  b &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;more&apos;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;getB&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Undefined&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To avoid this bug, ensure to declare and initialize variables before using them.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getB&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; b &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;more&apos;&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;b&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;getB&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// more&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Function Declarations&lt;/h2&gt;
&lt;p&gt;The general way of working with functions is to declare it before you invoke it. However, in very rare cases, you may mistakenly use a function before you declare it in your code. Hoisting makes it work and not throw an error.&lt;/p&gt;
&lt;p&gt;The code snippet below shows the generally known way of declaring and invoking a function.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getTheLastDigitFromUrl&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; digit &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; url &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; url&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token regex&quot;&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-source language-regex&quot;&gt;([\d]+)&lt;/span&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-flags&quot;&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;digit &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; digit&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; digit&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; url
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;getTheLastDigitFromUrl&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;https://chiamakaikeanyi.dev/20200702&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;//20200702&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now, what happens when the function is invoked before declaration?&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token function&quot;&gt;getTheLastDigitFromUrl&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;https://chiamakaikeanyi.dev/20200702&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;//20200702&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getTheLastDigitFromUrl&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; digit &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; url &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; url&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token regex&quot;&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-source language-regex&quot;&gt;([\d]+)&lt;/span&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-flags&quot;&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;digit &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; digit&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; digit&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; url
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Nothing special, it yields the same result as the first scenario when the function is declared before being called. This is due to hoisting. Function declarations are hoisted. So we can invoke a function before we declare it.&lt;/p&gt;
&lt;h2&gt;Function Expressions&lt;/h2&gt;
&lt;p&gt;Function expressions are not hoisted. If you invoke a function expression before assigning a function to it, it results to a type error.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token function&quot;&gt;getTheLastDigitFromUrl&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;https://chiamakaikeanyi.dev/20200702&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// Uncaught TypeError: getTheLastDigitFromUrl is not a function&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;getTheLastDigitFromUrl&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; digit &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; url &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; url&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token regex&quot;&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-source language-regex&quot;&gt;([\d]+)&lt;/span&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-flags&quot;&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;digit &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; digit&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; digit&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; url
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;getTheLastDigitFromUrl&lt;/code&gt; is a variable initialized with undefined, so, invoking it as a function results to a type error.&lt;/p&gt;
&lt;h2&gt;Hoisting Variables vs Functions&lt;/h2&gt;
&lt;p&gt;Function declarations are hoisted before variable assignments. Let&apos;s execute the code below:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;typeof&lt;/span&gt; getB&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Output: function&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; getB &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Read&apos;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getB&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; b &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;more&apos;&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;b&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Same occurs for variable declarations:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;typeof&lt;/span&gt; getB&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Output: function&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; getB

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getB&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; b &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;more&apos;&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;b&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Notice that although the variable was declared before the function, the type logged to the console is function.&lt;/p&gt;
&lt;h2&gt;Strict Mode&lt;/h2&gt;
&lt;p&gt;In strict mode, variables cannot be used if they are not declared. Doing this throws an error.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token string&quot;&gt;&apos;use strict&apos;&lt;/span&gt;

console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;a&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Uncaught ReferenceError: a is not defined&lt;/span&gt;
a &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Read more&apos;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;The let and const Keywords&lt;/h2&gt;
&lt;p&gt;Variables and constants declared with let or const are hoisted but unlike var, they are not initialized with undefined. Using them before initialization results to a reference error rather than undefined. Variables declared with let is block scoped ({}) NOT function scope.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;a&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Uncaught ReferenceError: b is not defined&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; a &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Read more&apos;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;However, when &lt;code class=&quot;language-text&quot;&gt;let&lt;/code&gt; is moved to the top, it is hoisted. This is an antipattern though.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; a
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;a&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
a &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Read more&apos;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Using const,&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;a &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Read&apos;&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;a &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos; &apos;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; b&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Uncaught ReferenceError: Cannot access &apos;b&apos; before initialization&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// Declare b. b is not hoisted&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; b &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;more&apos;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;Note that you cannot declare the const variable without initialization. Attempting to do so results to a syntax error&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;a &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Read&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;a &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot; &quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; b&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// Declare b. b is not hoisted&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; b
b &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;more&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Uncaught SyntaxError: Missing initializer in const declaration&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Points to Note&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;JavaScript only hoist declarations. Initializations are not hoisted.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Always declare variables at the top of every scope to avoid bugs.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Function declarations are hoisted while function expressions are not.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Variables and constants declared with let or const are hoisted but unlike var, they are not initialized with undefined. Using them before initialization results to a reference error rather than undefined.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Prefer let and const over var.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Having gone through and understood hoisting as a concept in JavaScript, it is pertinent to note that we should form a habit of declaring and initializing JavaScript variables before they are used. In ES 5, using the strict mode is encouraged to expose the loop holes.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[How to Create a Custom Message on your Terminal]]></title><description><![CDATA[Do you use your terminal a lot? I bet you would want to add some text to look at each time you launch your terminal. In this article, you…]]></description><link>https://chiamakaikeanyi.dev/how-to-create-a-custom-message-on-your-terminal/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/how-to-create-a-custom-message-on-your-terminal/</guid><pubDate>Thu, 04 Jun 2020 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Do you use your terminal a lot? I bet you would want to add some text to look at each time you launch your terminal. In this article, you would create a custom message on your terminal using Figlet.&lt;/p&gt;
&lt;h2&gt;Prerequisite&lt;/h2&gt;
&lt;p&gt;If you are running on a macOS and don&apos;t have Homebrew installed, you need to install CLI tools for Xcode and Homebrew. If you are running on a different operating system, skip Step 1.&lt;/p&gt;
&lt;h2&gt;Step 1: Install Homebrew&lt;/h2&gt;
&lt;p&gt;Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple’s macOS.&lt;/p&gt;
&lt;p&gt;Before installing Homebrew, you need to install the CLI tools for Xcode. Open your terminal and run the command:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;xcode-select —-install&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If you get an error, run &lt;code class=&quot;language-text&quot;&gt;xcode-select -r&lt;/code&gt; to reset xcode-select.&lt;/p&gt;
&lt;p&gt;Then, install Homebrew.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;/usr/bin/ruby &lt;span class=&quot;token parameter variable&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/Homebrew/install/master/install&lt;span class=&quot;token variable&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Step 2: Install Figlet&lt;/h2&gt;
&lt;p&gt;Figlet is a command-line utility that generates text banners in a variety of typefaces, composed of letters made up of conglomerations of smaller ASCII characters.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;brew &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; figlet   &lt;span class=&quot;token comment&quot;&gt;# macOS&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;apt&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; figlet    &lt;span class=&quot;token comment&quot;&gt;# Debian/Ubuntu&lt;/span&gt;
yum &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; figlet    &lt;span class=&quot;token comment&quot;&gt;# CentOS/RHEL&lt;/span&gt;
dnf &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; figlet    &lt;span class=&quot;token comment&quot;&gt;# Fedora 22+&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Once you have installed figlet, you can view all the fonts in the terminal by running the command:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;showfigfonts&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To view how your message would be displayed using different fonts, type &lt;code class=&quot;language-text&quot;&gt;showfigfonts&lt;/code&gt; on your terminal, followed by your message. In this scenario, I&apos;ll be using &lt;strong&gt;{ } is poetry&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;showfigfonts &lt;span class=&quot;token string&quot;&gt;&quot;{ } is poetry&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The basic way of using figlet is by providing the text that you want to transform as an argument.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;figlet &lt;span class=&quot;token string&quot;&gt;&apos;{ } is poetry&apos;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To check the manual, run &lt;code class=&quot;language-text&quot;&gt;man figlet&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;You can specify your desired font, using the -f flag.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;figlet &lt;span class=&quot;token parameter variable&quot;&gt;-f&lt;/span&gt; weird &lt;span class=&quot;token string&quot;&gt;&apos;{ } is poetry&apos;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;For a clearer output, you can use the -k flag to add a little space between the printed characters. This is evident when you use a compact font. Try running the two commands below and notice the difference.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;figlet &lt;span class=&quot;token parameter variable&quot;&gt;-f&lt;/span&gt; small &lt;span class=&quot;token string&quot;&gt;&apos;{ } is poetry&apos;&lt;/span&gt;

figlet &lt;span class=&quot;token parameter variable&quot;&gt;-k&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-f&lt;/span&gt; small &lt;span class=&quot;token string&quot;&gt;&apos;{ } is poetry&apos;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Use the -c flag to centralize your text and the -r to display the text at the right.&lt;/p&gt;
&lt;h2&gt;Step 3: Add Colors&lt;/h2&gt;
&lt;p&gt;To go a bit further with the customization, add colors to the text. The -e option of the echo command is used for parsing of the escape sequences.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token entity&quot; title=&quot;\e&quot;&gt;\e&lt;/span&gt;[32mDon’t let the noise of others’ opinions drown your own inner voice&lt;span class=&quot;token entity&quot; title=&quot;\e&quot;&gt;\e&lt;/span&gt;[0m&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To use the colors alongside figlet, run&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token entity&quot; title=&quot;\e&quot;&gt;\e&lt;/span&gt;[32m&quot;&lt;/span&gt;                    &lt;span class=&quot;token comment&quot;&gt;# Invoke a color&lt;/span&gt;
figlet &lt;span class=&quot;token parameter variable&quot;&gt;-f&lt;/span&gt; slant &lt;span class=&quot;token string&quot;&gt;&quot;{ } is poetry&quot;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;# Use a slant font&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token entity&quot; title=&quot;\e&quot;&gt;\e&lt;/span&gt;[0m&quot;&lt;/span&gt;                     &lt;span class=&quot;token comment&quot;&gt;# Reset the color&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The “\e[32m” sequence adds a green color to the terminal. The colors are derived from the &lt;a href=&quot;https://en.wikipedia.org/wiki/ANSI_escape_code#Colors&quot;&gt;ANSI escape code&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The “\e[0m” sequence resets the terminal. It removes all attributes (formatting and colors). Always add it at the end of each colored text.&lt;/p&gt;
&lt;p&gt;You can combine attributes but ensure that the attributes are separated by a semicolon. To create a bold and underlined text, use &lt;strong&gt;\e[1;4;33m&lt;/strong&gt;.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Learn, &lt;span class=&quot;token entity&quot; title=&quot;\e&quot;&gt;\e&lt;/span&gt;[1;4;33mUnlearn&lt;span class=&quot;token entity&quot; title=&quot;\e&quot;&gt;\e&lt;/span&gt;[0m, Relearn. &lt;span class=&quot;token entity&quot; title=&quot;\e&quot;&gt;\e&lt;/span&gt;[1mJust keep moving...&lt;span class=&quot;token entity&quot; title=&quot;\e&quot;&gt;\e&lt;/span&gt;[0m&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You&apos;re done with the bits. Now, add everything together to create an awesome terminal.&lt;/p&gt;
&lt;p&gt;The customizations you&apos;ve done so far disappears when you quit the terminal. To make it persist, copy the code and paste in your &lt;strong&gt;.zshrc&lt;/strong&gt; or &lt;strong&gt;.bash_profile&lt;/strong&gt;. I&apos;ll use the zshrc file. Feel free to use bash_profile file.&lt;/p&gt;
&lt;p&gt;Run the command below on your terminal to open the file with your Visual Studio Code editor.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;code ~/.zshrc&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&apos;info&apos;&gt;
&lt;p&gt;If you cannot access files using VS Code code command, you need to install it.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Launch VS Code&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Press &lt;kbd&gt;CMD + SHIFT + P&lt;/kbd&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Type &lt;strong&gt;shell command&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Select &lt;strong&gt;Install code command in path&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;p&gt;You can also launch it with nano using,&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;nano&lt;/span&gt; ~/.zshrc&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Paste the code below or your custom message in the .zshrc or .bash_profile file.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;figlet &lt;span class=&quot;token parameter variable&quot;&gt;-k&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;{ } is poetry&apos;&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token entity&quot; title=&quot;\e&quot;&gt;\e&lt;/span&gt;[32m Learn, &lt;span class=&quot;token entity&quot; title=&quot;\e&quot;&gt;\e&lt;/span&gt;[1;4;33mUnlearn,&lt;span class=&quot;token entity&quot; title=&quot;\e&quot;&gt;\e&lt;/span&gt;[0m &lt;span class=&quot;token entity&quot; title=&quot;\e&quot;&gt;\e&lt;/span&gt;[32mRelearn. &lt;span class=&quot;token entity&quot; title=&quot;\e&quot;&gt;\e&lt;/span&gt;[1mJust keep moving...&lt;span class=&quot;token entity&quot; title=&quot;\e&quot;&gt;\e&lt;/span&gt;[0m&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Finally, save your changes by running the command:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;source&lt;/span&gt; ~/.zshrc

or

&lt;span class=&quot;token builtin class-name&quot;&gt;source&lt;/span&gt; ~/.bash_profile&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Voila! you now have an awesome terminal and have gotten a sneak peek of how my terminal currently looks.&lt;/p&gt;
&lt;p&gt;Read my article on &lt;a href=&quot;/how-to-configure-your-macos-terminal-with-zsh-like-a-pro/&quot;&gt;How to configure your terminal with ZSH&lt;/a&gt; for a deep dive into customizing your terminal.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Nullish Coalescing and Optional Chaining in JavaScript]]></title><description><![CDATA[When working with data, situations arise where you aren’t sure that the property you need exists.
To build fault-tolerant applications…]]></description><link>https://chiamakaikeanyi.dev/nullish-coalescing-and-optional-chaining-in-javascript/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/nullish-coalescing-and-optional-chaining-in-javascript/</guid><pubDate>Thu, 07 May 2020 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;When working with data, situations arise where you aren’t sure that the property you need exists.
To build fault-tolerant applications despite issues like this, default values are provided to make apps fail gracefully. Before now, the logical OR (||) operator is used to achieve this. It is a syntax for selecting the second defined value or variable (default value) if the first value or variable is falsy (false, 0, &apos; &apos;, null or undefined).&lt;/p&gt;
&lt;h3&gt;The logical OR (||) operator&lt;/h3&gt;
&lt;p&gt;The tenary condition &lt;code class=&quot;language-text&quot;&gt;a ? a : b&lt;/code&gt; is shortened to &lt;code class=&quot;language-text&quot;&gt;a || b&lt;/code&gt;. This concept is known as short-circuiting.&lt;/p&gt;
&lt;div class=&quot;info&quot;&gt;
The result of actualValue || defaultValue is:
  actualValue if actualValue is truthy,
  otherwise, it is defaultValue.
&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;null&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;default&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;       &lt;span class=&quot;token comment&quot;&gt;//&apos;default&apos;&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;undefined&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;default&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;//&apos;default&apos;&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;default&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;    &lt;span class=&quot;token comment&quot;&gt;//&apos;default&apos;&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos; &apos;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;default&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;    &lt;span class=&quot;token comment&quot;&gt;//&apos;default&apos;&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;default&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;     &lt;span class=&quot;token comment&quot;&gt;//&apos;default&apos;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Note that the default value is also used when the actual value is false, 0 or &apos; &apos;. This is due to JavaScript evaluating these values as falsy. The operand on the left hand side was coerced to a boolean for the evaluation and any falsy value (false, 0, &apos; &apos;, null or undefined) is not returned. This leads to unexpected results if these values are considered valid.&lt;/p&gt;
&lt;p&gt;To get a better grasp, let&apos;s consider the function:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getUser&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;guestUser&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;isUserValid&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;isValid &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; users &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Ethel&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;25&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;isValid&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;22&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token literal-property property&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;18&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;isValid&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

users&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;user&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getUser&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;user&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// Expected output: [&quot;Ethel&quot;, &quot;guestUser&quot;, &quot;guestUser&quot;];&lt;/span&gt;

users&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;user&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;isUserValid&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;user&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// Expected output: [true, true, true];&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If the expected value for the second object in the array above is  &apos; &apos;, the logical OR (||) operator nullifies it. A recent operator (??) has been added to JavaScript to address unexpected behaviours like this when using the || operator.&lt;/p&gt;
&lt;h3&gt;The nullish coalescing (??) operator&lt;/h3&gt;
&lt;p&gt;As opposed to the logical OR (||) operator, the nullish coalescing (??) operator provides a syntax for selecting the second operand &lt;em&gt;only&lt;/em&gt; when the first operand evaluates to either null or undefined (but no other falsy values).&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The nullish coalescing operator (??) is a logical operator that returns its right-hand side operand when its left-hand side operand is null or undefined, and otherwise returns its left-hand side operand.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The tenary condition &lt;code class=&quot;language-text&quot;&gt;(a !== null &amp;amp;&amp;amp; a !== undefined) ? a : b&lt;/code&gt; is shortened to &lt;code class=&quot;language-text&quot;&gt;a ?? b&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&quot;info&quot;&gt;
The result of actualValue ?? defaultValue is:
  actualValue if actualValue is not null or undefined,
  otherwise, it is defaultValue.
&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;null&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;??&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;default&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;      &lt;span class=&quot;token comment&quot;&gt;// &apos;default&apos;&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;undefined&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;??&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;default&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// &apos;default&apos;&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;??&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;default&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;   &lt;span class=&quot;token comment&quot;&gt;// false&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos; &apos;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;??&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;default&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;    &lt;span class=&quot;token comment&quot;&gt;// &apos; &apos;&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;??&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;default&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;     &lt;span class=&quot;token comment&quot;&gt;// 0&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Take a look at the last three operations, therein lies the difference between || and ??. Actual values are returned for the two falsy values.&lt;/p&gt;
&lt;p&gt;Rewriting the same function,&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getUser&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name &lt;span class=&quot;token operator&quot;&gt;??&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;guestUser&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;isUserValid&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;isValid &lt;span class=&quot;token operator&quot;&gt;??&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; users &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Ethel&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;25&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;isValid&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;22&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token literal-property property&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;18&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;isValid&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

users &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; users&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;
  users&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;user&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getUser&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;user&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// Expected output: [&quot;Ethel&quot;, &quot;&quot;, &quot;guestUser&quot;];&lt;/span&gt;

users &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; users&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;
  users&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;user&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;isUserValid&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;user&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// Expected output: [true, true, false];&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Optional Chaining (?.)&lt;/h3&gt;
&lt;p&gt;The optional chaining operator (?.) provides a concise way of accessing the value of a property that is deep within a chain of connected objects without having to explicitly validate the reference. It is useful when accessing a property of an object which may be nullish (null or undefined).&lt;/p&gt;
&lt;p&gt;Instead of causing an error when a reference is nullish, it short-circuits with a return value of undefined.&lt;/p&gt;
&lt;p&gt;Given the object,&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; user &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Eve&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Lagos&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;city&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Gbagada&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;234&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To access a property on this object that its availability is uncertain, we usually use the syntax below:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;user&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;state &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;state&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;city&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; stateCode &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;state&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;city&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;code&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This ensures that the program does not throw an error message such as:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;TypeError: Cannot read property &apos;code&apos; of undefined&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;With the newly introduced optional chaining operator (?.), you can check for data availability using a more concise approach.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;user&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;state&lt;span class=&quot;token operator&quot;&gt;?.&lt;/span&gt;city&lt;span class=&quot;token operator&quot;&gt;?.&lt;/span&gt;code&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Given the array,&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; users &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Nora&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;city&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Accra&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;233&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Terrence&apos;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Nick&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;

    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; cityCode &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; users&lt;span class=&quot;token operator&quot;&gt;?.&lt;/span&gt;length &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;
  users&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;user&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;state&lt;span class=&quot;token operator&quot;&gt;?.&lt;/span&gt;city&lt;span class=&quot;token operator&quot;&gt;?.&lt;/span&gt;code &lt;span class=&quot;token operator&quot;&gt;??&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// Expected output: [&quot;233&quot;, 0, 0];&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;warning&quot;&gt;
Do not combine both the AND (&amp;&amp;) and OR operators (||) directly with ??. A syntax error would be thrown in such scenario.
&lt;/div&gt;
&lt;p&gt;Note that when ?? is used together with || or &amp;#x26;&amp;#x26; operator in an expression, always enclose the expression within parentheses due to &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence#Table&quot;&gt;its low value on the precedence table&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Given the object,&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; user &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Eve&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;  &lt;span class=&quot;token keyword&quot;&gt;null&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; stateValueWithError &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;state &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;
  user&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;state&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name &lt;span class=&quot;token operator&quot;&gt;??&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Accra&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// Uncaught SyntaxError: Unexpected token &apos;??&apos;&lt;/span&gt;

console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;stateValueWithError&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// Uncaught ReferenceError: stateValueWithError is not defined&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; stateValueWithoutError &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;user&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;state &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;
  user&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;state&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;??&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Lagos&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;stateValueWithoutError&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// &quot;Lagos&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;The main difference between the logical OR (||) and the nullish coalescing operator (??) is that || returns the first &lt;em&gt;truthy&lt;/em&gt; value while ?? returns the first &lt;em&gt;defined&lt;/em&gt; value. This becomes important when other falsy values are considered as valid values.&lt;/p&gt;
&lt;p&gt;Though this feature is appealing to use, minimize its usage at this stage due to the cross-browser stability.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[How to Write Good Git Commit Messages]]></title><description><![CDATA[Writing good commit messages is an under-valued skill. Why does it seem to count; shouldn't only technical skills count? Well, possessing it…]]></description><link>https://chiamakaikeanyi.dev/how-to-write-good-git-commit-messages/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/how-to-write-good-git-commit-messages/</guid><pubDate>Thu, 02 Apr 2020 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Writing good commit messages is an under-valued skill. Why does it seem to count; shouldn&apos;t only technical skills count?&lt;/p&gt;
&lt;p&gt;Well, possessing it as a developer helps in the following ways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It adds clarity to pull requests (PRs) raised&lt;/li&gt;
&lt;li&gt;It is key to effective debugging within a team.&lt;/li&gt;
&lt;li&gt;Makes tracking an implementation easier&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;NB&lt;/strong&gt;: If you&apos;re yet to understand what Git is, read my article on &lt;a href=&quot;/working-with-git&quot;&gt;Working with Git&lt;/a&gt; before revisiting this.&lt;/p&gt;
&lt;h2&gt;What is a Git commit?&lt;/h2&gt;
&lt;p&gt;This is a way to tell Git about the staged changes you made to the repository using the commit command. It takes a snapshot of what your project looks like once you commit, and stores a unique reference (40 character length) to it using a Secure Hashing Algorithm (SHA).&lt;/p&gt;
&lt;p&gt;To add these changes, you need to specify a commit message to be attached to this change and a specific &lt;a href=&quot;https://git-scm.com/docs/git-commit&quot;&gt;flag&lt;/a&gt; to use. Write the commit message as if it&apos;s about to be applied, rather than about what you just did.&lt;/p&gt;
&lt;p&gt;Let&apos;s elaborate why you should care about writing good commit messages.&lt;/p&gt;
&lt;h3&gt;Adds clarity to PRs raised&lt;/h3&gt;
&lt;p&gt;If someone needs to read through your PR before getting a grasp of what it&apos;s meant to do, it means that you have a lot to do regarding writing good commit messages. Your commit message should be concise and state the context of the change. The message is truncated once it reaches the specified character limit.&lt;/p&gt;
&lt;p&gt;Reference the ticket number or tracking ID within the commit message to add more context.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# Bad&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; commit &lt;span class=&quot;token parameter variable&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Fix bug&quot;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# Good&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; commit &lt;span class=&quot;token parameter variable&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Add auto login for verified users - Closes BLG-20&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;State why you&apos;re making the changes within the body (if necessary) as the diff already shows what is being changed. Focus on the way it worked before the change (and what was wrong with that), the way it works now, and why you decided to solve it the way you did. Explain the side effects of the change if any.&lt;/p&gt;
&lt;p&gt;A new developer joining the team should be able to read the commit message and tell what the PR does. If it is difficult to understand, you may be adding too many changes, strive for atomic commits.&lt;/p&gt;
&lt;h3&gt;Key to Effective Debugging&lt;/h3&gt;
&lt;p&gt;For the commit message to help in debugging effectively, ensure that it is short and use an imperative mood (spoken or written as if giving a command or instruction) when constructing them.&lt;/p&gt;
&lt;p&gt;The first word in your commit message should be one of these:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Add&lt;/li&gt;
&lt;li&gt;Create&lt;/li&gt;
&lt;li&gt;Refactor&lt;/li&gt;
&lt;li&gt;Fix&lt;/li&gt;
&lt;li&gt;Release&lt;/li&gt;
&lt;li&gt;Document&lt;/li&gt;
&lt;li&gt;Modify&lt;/li&gt;
&lt;li&gt;Update&lt;/li&gt;
&lt;li&gt;Remove&lt;/li&gt;
&lt;li&gt;Delete etc...&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;info&quot;&gt;
It should complete the template: If applied, this commit will [Add your subject line here]
&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# Bad&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; commit &lt;span class=&quot;token parameter variable&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;implemented automatic login for new verified signups because
currently new users have to manually log in after signing up.&quot;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# Good&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; commit &lt;span class=&quot;token parameter variable&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Implement automatic login for new verified signups&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Take a look at the two commit messages to notice the difference. The first word of the message labelled &lt;em&gt;good&lt;/em&gt; is written in an imperative mood, succint and starts with a capital letter. It communicates using an active voice.&lt;/p&gt;
&lt;p&gt;When you substitute the message within the Git commit template, it becomes:&lt;/p&gt;
&lt;div class=&quot;note&quot;&gt;
If applied, this commit will Implement automatic login for new verified signups
&lt;/div&gt;
&lt;p&gt;To view revision history when debugging, run the command.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; log&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The output:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;commit a6e7ab9ce174821a0c934df9e61450a230a855e0
Author: Chiamaka Ikeanyi &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;hello@chiamakaikeanyi.dev&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
Date:   Thu Apr 02 04:00:00 &lt;span class=&quot;token number&quot;&gt;2020&lt;/span&gt; +0000

    Add article on commit messages - Closes BLG-27&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This shows a detailed log of a specific commit.&lt;/p&gt;
&lt;p&gt;To get a more streamlined output, provide more arguments to the log command.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; log &lt;span class=&quot;token parameter variable&quot;&gt;--oneline&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-5&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;--author&lt;/span&gt; chiamaka &lt;span class=&quot;token parameter variable&quot;&gt;--before&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Thu Apr 02 2020&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This shows the subject of commits made by the specified author before the specified date.&lt;/p&gt;
&lt;h3&gt;Makes tracking an implementation easier&lt;/h3&gt;
&lt;p&gt;Within a project, you can ascertain if a developer is a good team player or not by running &lt;code class=&quot;language-text&quot;&gt;git log&lt;/code&gt;. Logs that are well cared for are useful and helps you to understand why something happened in the past.&lt;/p&gt;
&lt;h2&gt;Model of a good Git commit message:&lt;/h2&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Capitalized, short (50 characters or less) summary&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;More detailed explanatory text, if necessary. Wrap it to about 72 characters or so. In some contexts, the first line is treated as the subject of an email and the rest of the text as the body. The blank line separating the summary from the body is critical (unless you omit the body entirely); tools like rebase can get confused if you run the two together.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Write your commit message in the imperative: &quot;Fix bug&quot; and not &quot;Fixed bug&quot;or &quot;Fixes bug.&quot; This convention matches up with commit messages generatedby commands like git merge and git revert.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Further paragraphs come after blank lines&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Bullet points are okay, too. Typically a hyphen or asterisk is used for the bullet, followed by a single space, with blank lines in between, but conventions vary here&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If you use an issue tracker, add a reference(s) to them at the bottom, e.g. Resolve #123; See also: #456, #789&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;7 rules of a great Git commit message&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Separate subject from body with a blank line&lt;/li&gt;
&lt;li&gt;Limit the subject line to 50 characters&lt;/li&gt;
&lt;li&gt;Capitalize the subject line&lt;/li&gt;
&lt;li&gt;Do not end the subject line with a period&lt;/li&gt;
&lt;li&gt;Use the imperative mood when in the subject line&lt;/li&gt;
&lt;li&gt;Wrap the body at 72 characters&lt;/li&gt;
&lt;li&gt;Use the body to explain what and why the change was made. This part should be added only when necessary&lt;/li&gt;
&lt;li&gt;Remove unnecessary punctuation marks&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Commit Types&lt;/h2&gt;
&lt;p&gt;Different teams have different means of structuring commit messages. Some use commit types to add more context to PRs raised.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;feat: A new feature&lt;/li&gt;
&lt;li&gt;fix: A bug fix&lt;/li&gt;
&lt;li&gt;style: Additions or modifications related to styling only&lt;/li&gt;
&lt;li&gt;refactor: Code refactoring&lt;/li&gt;
&lt;li&gt;test: Additions or modifications to test cases&lt;/li&gt;
&lt;li&gt;docs: README, Architectural, or anything related to documentation&lt;/li&gt;
&lt;li&gt;chore: Regular code maintenance&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A PR that has a commit type added can look like this:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; commit &lt;span class=&quot;token parameter variable&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Resolve feat/BLG-20: Implement auto login for new signups&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Debugging becomes a thorn in the flesh when commit messages do not help. Ensuring that you write good commit messages do not only show that you are empathetic, but also helps you during the debugging process.&lt;/p&gt;
&lt;p&gt;I hope this will help you and your team to write great commit messages that follows Git&apos;s built-in convention. You can still &lt;a href=&quot;/how-to-update-git-commit-messages/&quot;&gt;update previous commits&lt;/a&gt; if you&apos;ve just made a mistake.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[JavaScript Array Methods: forEach vs map]]></title><description><![CDATA[As a JavaScript developer, you may have been in a position of using forEach or map array method on the  object to iterate through the…]]></description><link>https://chiamakaikeanyi.dev/map-vs-foreach/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/map-vs-foreach/</guid><pubDate>Thu, 05 Mar 2020 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;As a JavaScript developer, you may have been in a position of using &lt;em&gt;forEach&lt;/em&gt; or &lt;em&gt;map&lt;/em&gt; array method on the &lt;code class=&quot;language-text&quot;&gt;Array.prototype&lt;/code&gt; object to iterate through the elements of an array and wondered the choice to make based on performance gain.&lt;/p&gt;
&lt;p&gt;First, let&apos;s see MDN&apos;s definition of what they do,&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;forEach()&lt;/strong&gt; method executes a provided function once for each array element.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;map()&lt;/strong&gt; method creates a new array populated with the results of calling a provided function on every element in the calling array.&lt;/p&gt;
&lt;p&gt;To elaborate,&lt;/p&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;forEach()&lt;/code&gt; iterates through the elements of an array and perform an operation on each element. It mutates the original data and returns undefined.&lt;/p&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;map()&lt;/code&gt; is a functional programming technique. It iterates through the elements of an array, transforms each member of that array, and returns a new array of the same size with the transformed members e.g. performing calculations on a list of numbers. It does not mutate the original data, it returns a new array.&lt;/p&gt;
&lt;p&gt;The basic difference between forEach and map is the:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;return value&lt;/li&gt;
&lt;li&gt;data mutation&lt;/li&gt;
&lt;li&gt;chainability&lt;/li&gt;
&lt;li&gt;performance&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Given the array;&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; array &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Return Value and Data mutation&lt;/h3&gt;
&lt;p&gt;forEach mutates the original data and has no return value.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; newArray &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; array&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;num&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; index&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; array&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;index&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; num &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Expected output: array = [8, 16, 24, 32]&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// newArray = undefined&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Map do not mutate the original data. It returns a new array.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; newArray &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; array&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; num &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// Expected output: array = [2, 4, 6, 8]&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// newArray = [8, 16, 24, 32]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Chainability&lt;/h2&gt;
&lt;p&gt;Chainability is a technique used for invoking multiple method calls. forEach is not chainable whereas map is chainable.&lt;/p&gt;
&lt;p&gt;Given the array;&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; array &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; newArray &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; array
  &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; num &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; num &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Expected output: array = [2, 4, 6, 8]&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// newArray = [12, 16]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Performance&lt;/h2&gt;
&lt;p&gt;In terms of speed, I&apos;ll use JSperf, a popular website for checking the performance of JavaScript functions and the DevTools console.&lt;/p&gt;
&lt;p&gt;To really see the impact, I&apos;ll use a large data set.&lt;/p&gt;
&lt;p&gt;Given the array,&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; array &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1000000&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  array&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Using the DevTools console,&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// forEach&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;forEach&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
array&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;num&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; index&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; array&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;index&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; num &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;timeEnd&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;forEach&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// map&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;map&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
array&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; num &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;timeEnd&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;map&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Note that the result on JSperf as shown in the image above, and using the DevTools, &lt;code class=&quot;language-text&quot;&gt;forEach&lt;/code&gt; is faster than &lt;code class=&quot;language-text&quot;&gt;map&lt;/code&gt;. However, if &lt;code class=&quot;language-text&quot;&gt;for&lt;/code&gt; is put into consideration, it is the fastest of all.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th align=&quot;left&quot;&gt;&lt;/th&gt;
&lt;th align=&quot;left&quot;&gt;forEach&lt;/th&gt;
&lt;th align=&quot;left&quot;&gt;map&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td align=&quot;left&quot;&gt;Return value&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;undefined&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;New array&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align=&quot;left&quot;&gt;Data mutation&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;Yes&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align=&quot;left&quot;&gt;Chainability&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;No&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align=&quot;left&quot;&gt;Performance&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;More performant&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;Less performant&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;map and forEach are methods on the Array.prototype object. For proper usage, consider the scenario to determine the method to use.&lt;/p&gt;
&lt;p&gt;When working with functional programming, consider using map to avoid mutating data but when you do not care about data mutation, returning a value or chaining, use forEach.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Building for the User's Color Preference]]></title><description><![CDATA[We are in an era of dark mode. Some people who prefer dark mode are of the opinion that using dark mode helps the eyes by exposing it to…]]></description><link>https://chiamakaikeanyi.dev/building-for-the-user-color-preference/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/building-for-the-user-color-preference/</guid><pubDate>Thu, 20 Feb 2020 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;We are in an era of dark mode. Some people who prefer dark mode are of the opinion that using dark mode helps the eyes by exposing it to less light, to some, dark mode is used due to it&apos;s known ability to save a lot of power on AMOLED screens while to others, it&apos;s purely for aesthetic reason. Currently, popular applications and operating systems give users the option to enable light or dark mode. This is an accessibility win.&lt;/p&gt;
&lt;p&gt;The web platform is not left out. &lt;a href=&quot;https://drafts.csswg.org/mediaqueries-5&quot;&gt;Media Queries Level 5&lt;/a&gt; introduced user preference media features. This enables websites to detect the user&apos;s preferred settings to view content on the web.&lt;/p&gt;
&lt;p&gt;In this article, I&apos;ll be discussing the &lt;em&gt;prefers-color-scheme&lt;/em&gt; media query.&lt;/p&gt;
&lt;p&gt;The prefers-color-scheme media feature is used by the browser to detect the color theme (light or dark color theme) set by the user and use the setting when rendering the page. This media feature works with &lt;code class=&quot;language-text&quot;&gt;no-preference&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;light&lt;/code&gt; or &lt;code class=&quot;language-text&quot;&gt;dark&lt;/code&gt; as its value. For example, if the &lt;code class=&quot;language-text&quot;&gt;prefers-color-scheme: dark&lt;/code&gt; media query value is set to true, it means that the user has set their operating system to dark mode and prefers UIs with a dark theme (light text on dark background).&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;color-scheme&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  This color changes based on the user&apos;s operating system&apos;s settings.
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;:root&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;--light-theme-background-color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #15202b&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;--light-theme-text-color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #fafafa&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token property&quot;&gt;--dark-theme-background-color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #fafafa&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;--dark-theme-text-color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #15202b&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;.color-scheme&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;--light-theme-background-color&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;--light-theme-text-color&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token atrule&quot;&gt;&lt;span class=&quot;token rule&quot;&gt;@media&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;prefers-color-scheme&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; dark&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token selector&quot;&gt;.color-scheme&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;--dark-theme-background-color&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;--dark-theme-text-color&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can view the &lt;a href=&quot;https://caniuse.com/#feat=prefers-color-scheme&quot;&gt;support for prefers-color-scheme on Caniuse.com&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;For websites with &lt;code class=&quot;language-text&quot;&gt;prefers-color-scheme&lt;/code&gt; implementation, you can emulate the appearance on different color modes without switching the operating system&apos;s color scheme. This is possible using Chrome DevTools. This is done in a way that only the visible tab is affected. When you switch to a different tab, you would need to choose the color scheme you need to emulate.&lt;/p&gt;
&lt;p&gt;To achieve this,&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Press &lt;kbd&gt;CTRL + SHIFT + I&lt;/kbd&gt; in Windows and Linux environments or &lt;kbd&gt;CMD + OPT + J&lt;/kbd&gt; in a Mac environment to access the DevTools&lt;/li&gt;
&lt;li&gt;Open the Command Menu using &lt;kbd&gt;CTRL + SHIFT + P&lt;/kbd&gt; or &lt;kbd&gt;CMD + SHIFT + P&lt;/kbd&gt;&lt;/li&gt;
&lt;li&gt;Type Rendering and run the Show Rendering command,&lt;/li&gt;
&lt;li&gt;Change the Emulate CSS media feature prefers-color-scheme to your preferred option.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For certain websites, images on a white background appear too obvious when a dark theme is activated. To tone down these images, you can choose to re-colorize or invert the colors.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/* re-colorize images */&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;img:not([src*=&apos;.svg&apos;])&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;grayscale&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;50%&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;/* invert images */&lt;/span&gt;
&lt;span class=&quot;token atrule&quot;&gt;&lt;span class=&quot;token rule&quot;&gt;@media&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;prefers-color-scheme&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; dark&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token selector&quot;&gt;img:not([src*=&apos;.svg&apos;])&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;invert&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;85%&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To avoid bloated stylesheets, you can create different stylesheets to handle theme-related styles. These can then be loaded conditionally.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;link&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;rel&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;stylesheet&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;style/dark.css&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;media&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;(prefers-color-scheme: dark)&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;link&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;rel&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;stylesheet&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;style/light.css&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;media&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;(prefers-color-scheme: light)&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;link&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;rel&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;stylesheet&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;style/style.css&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Supporting dark mode can make a great difference for users visiting your website as it can make or mar the user experience.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Coloured Console Log in Browser DevTools]]></title><description><![CDATA[To JavaScript developers, writing console messages is done almost on a daily basis. The console is like a good friend. It makes the…]]></description><link>https://chiamakaikeanyi.dev/coloured-console-log-in-browser-devtools/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/coloured-console-log-in-browser-devtools/</guid><pubDate>Thu, 06 Feb 2020 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;To JavaScript developers, writing console messages is done almost on a daily basis. The console is like a good friend. It makes the debugging process easier. These messages can be displayed in many ways but many end up with just the regular &lt;code class=&quot;language-text&quot;&gt;console.log&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Displaying colourful console messages may be a child&apos;s play to some, but to others, it may still be a mystery yet to be unravelled. I once saw a coloured console message when I popped open the DevTools of a particular website. This sparked my curiosity and my quest to discover how it was achieved began.&lt;/p&gt;
&lt;p&gt;In this article, I&apos;ll show you how to display colourful console messages. Note that this is mainly for decorative purpose and not to be used when trying to debug production issues.&lt;/p&gt;
&lt;p&gt;The common syntax:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;\x1b[33m%s\x1b[0m&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;stringToStyle&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;\x1b[33m&lt;/strong&gt; is an escape sequence that will be intercepted by the terminal. When it is encountered, it instructs the terminal to switch to a yellow colour derived from the &lt;a href=&quot;https://en.wikipedia.org/wiki/ANSI_escape_code#Colors&quot;&gt;ANSI escape code&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;%s&lt;/strong&gt; indicates that the next character would be a string. This is where the second argument (the string) gets injected.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;\x1b[0m&lt;/strong&gt; is the code for the non-printable control character &lt;em&gt;escape&lt;/em&gt;. It resets the terminal colour.&lt;/p&gt;
&lt;p&gt;The syntax for coloured console message formatted using CSS:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;%cstringToStyle&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;color: #f0db4f&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The CSS format specifier %c is used to indicate that the console message (the second parameter) would be styled using CSS.&lt;/p&gt;
&lt;p&gt;To format the output further, you can specify a font for the message:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
  &lt;span class=&quot;token string&quot;&gt;&quot;%cLet&apos;s build a better web&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token string&quot;&gt;&apos;color: #734E73; font: bold 50px Helvetica Neue; text-shadow: 1px 1px 0 #ddd;&apos;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
  &lt;span class=&quot;token string&quot;&gt;&apos;%cWant to learn more about Software Engineering? Visit https://chiamakaikeanyi.dev&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token string&quot;&gt;&apos;font-size: 14px&apos;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Copy the code above and paste in your DevTools console to view the formatting.&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;You can style your console messages to achieve more. All possibilities are not exhausted in this article.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Imperative vs Declarative Approach to Programming]]></title><description><![CDATA[You probably must have heard of the terms imperative vs declarative and wondered what it means and how to apply it while programming. In…]]></description><link>https://chiamakaikeanyi.dev/imperative-vs-declarative-approach-to-programming/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/imperative-vs-declarative-approach-to-programming/</guid><pubDate>Thu, 16 Jan 2020 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;You probably must have heard of the terms imperative vs declarative and wondered what it means and how to apply it while programming.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;In computer science, declarative programming is a programming paradigm that expresses the logic of a computation without describing its control flow.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Imperative approach focuses on &lt;em&gt;how&lt;/em&gt; you do something, and declarative approach focuses on &lt;em&gt;what&lt;/em&gt; you do.”&lt;/p&gt;
&lt;p&gt;For instance, if you ask about how to learn react; let&apos;s look at the imperative vs declarative response to both.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;imperative response&lt;/strong&gt;: You can either learn using tutorials or by reading the documentation. To learn using tutorials, click on Take a tutorial button and to learn using the docs, click on Get started. The links are on &lt;a href=&quot;https://reactjs.org&quot;&gt;https://reactjs.org&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;declarative response&lt;/strong&gt;: Visit &lt;a href=&quot;https://reactjs.org&quot;&gt;https://reactjs.org&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;HTML, React etc. uses the declarative approach unlike imperative approach that focus on &lt;em&gt;how&lt;/em&gt; e.g. Java.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;header&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;h1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Learn React Today&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;h1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;header&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;Input&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; className&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; label&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; name&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; placeholder&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; type &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;div className&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;styles&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;inputWrapper&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
            &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;label
                className&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;styles&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;inputLabel&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
                htmlFor&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
                &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;label &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;label&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
            &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;input
                id&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
                className&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;className&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
                name&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
                placeholder&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;placeholder &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
                type&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;type&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
        &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;div&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Given the examples above, the focus is on &lt;strong&gt;WHAT&lt;/strong&gt; is to be done rather than &lt;strong&gt;HOW&lt;/strong&gt; to get it done.&lt;/p&gt;
&lt;p&gt;Worthy of note is the fact that behind the scenes, declarative approach uses imperative approach. However, this has been abstracted and you do not need to bother about it.&lt;/p&gt;
&lt;p&gt;Given the string &quot;Hello World&quot; to reverse and a bunch of numbers to find its sum, the possible approach you may take is:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;reverseString&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;str &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;typeof&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;str&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!==&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;string&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Argument must be a string&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; splittedStr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;str&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; reversedString &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; index &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; splittedStr&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; index &lt;span class=&quot;token operator&quot;&gt;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; index&lt;span class=&quot;token operator&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    reversedString &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; splittedStr&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;index&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; reversedString&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;getSum&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token parameter&quot;&gt;arr&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; sum &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; index &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; index &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; arr&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; index&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    result &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; arr&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;index&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; result&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The solutions above are valid. However, you can take a more declarative approach to get the same result instead of repeated iterations on the array.&lt;/p&gt;
&lt;p&gt;These can be refactored to:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;reverseString&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;str&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;reverse&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;getSum&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token parameter&quot;&gt;arr&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; arr&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;reduce&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;prev&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; current&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; prev &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; current&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The above describes the &lt;strong&gt;WHAT&lt;/strong&gt; we want to achieve (declarative) instead of the &lt;strong&gt;HOW&lt;/strong&gt; we want to achieve it (imperative). Notice the use of built-in JavaScript methods - &lt;code class=&quot;language-text&quot;&gt;reverse&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;join&lt;/code&gt;, and &lt;code class=&quot;language-text&quot;&gt;reduce&lt;/code&gt; to achieve the same goal with a concise and readable code.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[2019, A Year In My Life]]></title><description><![CDATA[2018 was an awesome year for me, albeit 2019 was better - a year of fitting into big shoes. It was filled with God's unending faithfulness…]]></description><link>https://chiamakaikeanyi.dev/2019-a-year-in-my-life/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/2019-a-year-in-my-life/</guid><pubDate>Wed, 01 Jan 2020 11:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;a href=&quot;/2018-a-year-in-my-life&quot;&gt;2018&lt;/a&gt; was an awesome year for me, albeit 2019 was better - a year of fitting into big shoes. It was filled with God&apos;s unending faithfulness.&lt;/p&gt;
&lt;p&gt;There&apos;s a lot to reflect on, this past year:&lt;/p&gt;
&lt;h2&gt;Relationship ‍&lt;/h2&gt;
&lt;p&gt;Good relationships add a good spice to life. I got to meet new people while keeping in touch with the people I met in the past years. I met and had dinner with some of the women in Tech that I admire. God, my maker has also kept His Word towards me to guide, guard and protect me throughout the journey.&lt;/p&gt;
&lt;h2&gt;Career&lt;/h2&gt;
&lt;p&gt;In 2019, I filled the big shoe; I was promoted and this came with extra responsibilities that seemed like it was going to break me. I felt like running away but the Lord was by my side to guide me through it all. I set up my home workspace and consciously made effort to study. This was a great deal for me. It really helped. I also, consciously went on a quest to learn how to manage people, think critically and creatively to be a good leader and make wise decisions.&lt;/p&gt;
&lt;h2&gt;Speaking&lt;/h2&gt;
&lt;p&gt;Over the years, I&apos;ve been attending tech events but 2019 felt better as I attended 2 tech events as a speaker.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;At Forloop Lagos Summit, I spoke about &lt;a href=&quot;/avoiding-shell-hell-aliases-to-the-rescue&quot;&gt;Avoiding Shell Hell: Aliases to the Rescue&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;At Vue Vixens, I spoke about &lt;a href=&quot;https://speakerdeck.com/chiamakaikeanyi/working-on-your-soft-skills-as-a-software-developer&quot;&gt;Working on your Soft Skills as a Software Developer&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Though my aim is to be known as a builder and not a speaker, I hope to speak at more tech events and grow this list sometime.&lt;/p&gt;
&lt;h2&gt;Writing&lt;/h2&gt;
&lt;p&gt;Having in mind the goal of creating quality learning resources, I wrote 16 articles in 2019. My most popular article was &lt;a href=&quot;/sizing-in-css-px-vs-em-vs-rem&quot;&gt;Sizing in CSS: px vs em vs rem&lt;/a&gt;. I will improve and explore more writing options this year.&lt;/p&gt;
&lt;h2&gt;Poetry&lt;/h2&gt;
&lt;p&gt;Asides coding, I like art and poetry. Playing with words and leaving the brushstrokes of one&apos;s imaginations and musings in print is amazing. I wrote &lt;a href=&quot;https://medium.com/poesie/archive/2019&quot;&gt;5 poems&lt;/a&gt; and spoken words in 2019.&lt;/p&gt;
&lt;h2&gt;New Language&lt;/h2&gt;
&lt;p&gt;In July, I started learning German on Duolingo. It feels awesome learning a new language and I try to use it at every opportunity I get to communicate with my friends in Germany. Feel free to &lt;a href=&quot;https://www.duolingo.com/profile/chiamaka_i&quot;&gt;add me&lt;/a&gt;, let&apos;s hit the target.&lt;/p&gt;
&lt;h2&gt;Reading&lt;/h2&gt;
&lt;p&gt;I read a lot of articles and 7 books in 2019. I will read 12 books or more in 2020. My favourite ones were:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The Smart Money Woman: This had the Nigerian feel. Everything was relatable as it was set in Lagos, Nigeria. It taught me about financial independence - to have goals, invest, and make wise decisions financially.&lt;/li&gt;
&lt;li&gt;Atomic Habits: This taught me to focus on the systems (building better habits) rather than the goals (chasing better results) and make each day count.&lt;/li&gt;
&lt;li&gt;Bridge to Haven: This taught me that despite our unfaithfulness, God remains faithful and ready to have us back when we run to Him.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;What&apos;s Next?&lt;/h2&gt;
&lt;p&gt;New lifestyle delivers new results. In 2020, I need to make deliberate effort to build stable systems and achieve a lot more than I have ever done.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Grow in my role as a Software Engineer and explore new grounds&lt;/li&gt;
&lt;li&gt;Engage in creative drawing. I&apos;ve neglected this over the past few years&lt;/li&gt;
&lt;li&gt;Get more involved in open source projects&lt;/li&gt;
&lt;li&gt;Read 12 books and write more&lt;/li&gt;
&lt;li&gt;Keep fit and prioritize self-care&lt;/li&gt;
&lt;li&gt;Enrol in a driving school.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Generally, I had an exciting and rewarding 2019. Goodbye 2019, cheers to the new year 🥂&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Demystifying this, call, apply and bind]]></title><description><![CDATA[The this keyword is one of the concepts you must encounter in your journey as a JavaScript developer. Yet, it is misunderstood by a lot of…]]></description><link>https://chiamakaikeanyi.dev/demystifying-this-call-apply-and-bind/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/demystifying-this-call-apply-and-bind/</guid><pubDate>Thu, 12 Dec 2019 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;The &lt;em&gt;this&lt;/em&gt; keyword is one of the concepts you must encounter in your journey as a JavaScript developer. Yet, it is misunderstood by a lot of developers. &lt;code class=&quot;language-text&quot;&gt;this&lt;/code&gt; is determined by the context of the code being executed. It varies implicitly or explicitly using &lt;code class=&quot;language-text&quot;&gt;call&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;apply&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;bind&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;In this article, you&apos;ll learn what &lt;code class=&quot;language-text&quot;&gt;this&lt;/code&gt; refers to and how to determine its value implicitly and explicitly using &lt;code class=&quot;language-text&quot;&gt;call&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;apply&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;bind&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;To determine the context of this keyword, you need to look at &lt;strong&gt;where the fuction is invoked&lt;/strong&gt;.&lt;/p&gt;
&lt;h2&gt;Implicit Context of this&lt;/h2&gt;
&lt;p&gt;There are different contexts of the &lt;strong&gt;this&lt;/strong&gt; keyword when used implicitly.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Global object&lt;/li&gt;
&lt;li&gt;Method of an Object&lt;/li&gt;
&lt;li&gt;Constructor&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Global Object&lt;/h3&gt;
&lt;p&gt;When you&apos;re working with the browser,&lt;code class=&quot;language-text&quot;&gt;this&lt;/code&gt; refers to the &lt;strong&gt;Window&lt;/strong&gt; object.&lt;/p&gt;
&lt;!-- This is because the code run within the context the object that it sits on. --&gt;
&lt;p&gt;The output when logged to the console is:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Window {parent: Window, postMessage: ƒ, blur: ƒ, focus: ƒ, close: ƒ, …}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You may be surprised to know that the value of &lt;code class=&quot;language-text&quot;&gt;this&lt;/code&gt; in a top-level function is also the &lt;strong&gt;Window&lt;/strong&gt; object.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;learnToSoar&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;learnToSoar&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Window {parent: Window, postMessage: ƒ, blur: ƒ, focus: ƒ, close: ƒ, …}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;However, using the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode&quot;&gt;strict mode&lt;/a&gt;, you can combat this weird behaviour.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token string&quot;&gt;&apos;use strict&apos;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;learnToSoar&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;learnToSoar&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// undefined&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Method of an Object&lt;/h3&gt;
&lt;p&gt;A method of an object refers to the properties of the object using the &lt;code class=&quot;language-text&quot;&gt;this&lt;/code&gt; keyword.&lt;/p&gt;
&lt;p&gt;Given an object;&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt; &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; person &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Chiamaka&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;scope&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;web&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; writes articles about the &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;scope&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; platform.&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
 &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To invoke the info method of the person object,&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;person&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// &quot;Chiamaka writes articles about the web platform.&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now, to determine what the &lt;code class=&quot;language-text&quot;&gt;this&lt;/code&gt; keyword within the object references, take a look at the left hand side of the dot notation. It is apparent that the value of &lt;code class=&quot;language-text&quot;&gt;this&lt;/code&gt; in the context is the &lt;em&gt;person&lt;/em&gt; object.&lt;/p&gt;
&lt;p&gt;Let&apos;s take this further using a nested object to get a better grasp of the concept,&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt; &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; person &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Chiamaka&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;watchword&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Find your greatest life and live it.&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;scope&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;web&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;readAnalogy&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;watchword&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; and keep writing about the
    &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;scope&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; platform&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;friend&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Rita&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;watchword&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Don\&apos;t sink into the life you have now.&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;readAnalogy&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;Keep winning &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;. &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;watchword&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
 &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In the snippet above, &lt;code class=&quot;language-text&quot;&gt;this.name&lt;/code&gt; within the person object refers to &lt;code class=&quot;language-text&quot;&gt;person.name&lt;/code&gt; whereas within the friend object, it refers to &lt;code class=&quot;language-text&quot;&gt;person.friend.name&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;Constructor&lt;/h3&gt;
&lt;p&gt;You can use the &lt;code class=&quot;language-text&quot;&gt;new&lt;/code&gt; keyword to create an instance of a class. In the constructor context &lt;code class=&quot;language-text&quot;&gt;this&lt;/code&gt; is bound to the instance of the class.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Person&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;name&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; watchword&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; name&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;watchword &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; watchword&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token function&quot;&gt;readAnalogy&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;s watchword is &quot;&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;watchword&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;


&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; human &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;Uzoma&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token string&quot;&gt;&apos;Be at the right place at the right time, with the right person.&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

human&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;readAnalogy&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;//&quot;Uzoma&apos;s watchword is &apos;Be at the right place at the right time, with the right person.&apos;&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In the example above, &lt;code class=&quot;language-text&quot;&gt;this&lt;/code&gt; is bound to the instance of &lt;code class=&quot;language-text&quot;&gt;Person&lt;/code&gt; which is &lt;code class=&quot;language-text&quot;&gt;human&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;Event Handler&lt;/h3&gt;
&lt;p&gt;The context of &lt;code class=&quot;language-text&quot;&gt;this&lt;/code&gt; for event handlers called using &lt;code class=&quot;language-text&quot;&gt;addEventListener&lt;/code&gt; is the element that is being listened to &lt;code class=&quot;language-text&quot;&gt;event.currentTarget&lt;/code&gt; or &lt;code class=&quot;language-text&quot;&gt;event.target&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;cta_button&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  Click the button
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; button &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;.cta_button&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

button&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;click&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;//&quot;&amp;lt;button&gt;Click me&amp;lt;/button&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Explicit Context of this&lt;/h2&gt;
&lt;p&gt;You can use &lt;code class=&quot;language-text&quot;&gt;call&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;apply&lt;/code&gt;, or &lt;code class=&quot;language-text&quot;&gt;bind&lt;/code&gt; to determine the context of &lt;code class=&quot;language-text&quot;&gt;this&lt;/code&gt; explicitly.&lt;/p&gt;
&lt;h3&gt;Call&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;The call() method calls a function with a given &lt;strong&gt;this&lt;/strong&gt; value and arguments provided individually.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Given the object,&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt; &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; person &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Chiamaka&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;watchword&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Find your greatest life and live it&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;scope&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;web&apos;&lt;/span&gt;
 &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;and the standalone function,&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;  &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;readAnalogy&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;watchword&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; and keep writing about the
    &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;scope&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; platform&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Looking at where the readAnalogy function is invoked, the context of this is &lt;strong&gt;Window&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The output of &lt;code class=&quot;language-text&quot;&gt;readAnalogy()&lt;/code&gt; would be:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token string&quot;&gt;&quot;undefined and keep writing about the undefined platform&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To invoke readAnalogy with the this keyword referencing the person object, using &lt;code class=&quot;language-text&quot;&gt;person.readAnalogy()&lt;/code&gt; would not work. It would output:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;Uncaught TypeError&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; person&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;readAnalogy is not a &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; at &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;anonymous&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The call and apply methods are used to achieve this purpose. To invoke readAnalogy within the person context, pass the person as an argument to the call method. Simply put, the first argument passed to the call method is what the this keyword inside that function will reference.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token function&quot;&gt;readAnalogy&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;person&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;//or&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;readAnalogy&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;apply&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;person&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To pass arguments to the function being invoked with the call method, it should be passed after the first argument which is the execution context.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; person &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Chiamaka&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;jobTitle&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Software Engineer&apos;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;stack1&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; stack2&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; stack3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;My name is &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; and I am a &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;jobTitle&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;
  building solutions using &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;stack1&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;stack2&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; and &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;stack3&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; stack &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;JavaScript&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;React&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Redux&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;person&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; stack&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; stack&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; stack&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Given a lot of arguments, using the call method becomes tiring. The apply method solves the problem.&lt;/p&gt;
&lt;h3&gt;Apply&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;The apply() method calls a function with a given this value, and arguments provided as an array (or an array-like object).&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This is similar to the call method. However, using the apply method, you pass an array as the second argument which is spread out as arguments.&lt;/p&gt;
&lt;p&gt;When you try to use the syntax for call on apply&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token function&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;apply&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;person&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; stack&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; stack&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; stack&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The output is&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token constant&quot;&gt;VM505&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; Uncaught TypeError&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; CreateListFromArrayLike called on non&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;object
at &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;anonymous&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To use apply, the code above will be refactored to:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; person &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Chiamaka&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;jobTitle&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Software Engineer&apos;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;stack1&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; stack2&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; stack3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;My name is &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; and I am a &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;jobTitle&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;
  building solutions using &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;stack1&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;stack2&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; and &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;stack3&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; stack &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;JavaScript&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;React&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Redux&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;apply&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;person&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; stack&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Note the difference here&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Gavin Joyce has a useful mnemonic to help remember the difference between &lt;code class=&quot;language-text&quot;&gt;fn.call&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;fn.apply&lt;/code&gt;&lt;/p&gt;
&lt;blockquote class=&quot;twitter-tweet&quot;&gt;&lt;p lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;Have trouble remembering the difference between `&lt;a href=&quot;https://t.co/gdUSChIRgv&quot;&gt;https://t.co/gdUSChIRgv&lt;/a&gt;` and `fn.apply` in JavaScript?&lt;br&gt;&lt;br&gt;A useful mnemonic from &lt;a href=&quot;https://t.co/HekOteBawB&quot;&gt;https://t.co/HekOteBawB&lt;/a&gt;:&lt;br&gt;&lt;br&gt;&amp;quot;A for array and C for comma.&amp;quot;&lt;br&gt;&lt;br&gt;fn.apply(context, [a, b, c]);&lt;a href=&quot;https://t.co/gdUSChIRgv&quot;&gt;https://t.co/gdUSChIRgv&lt;/a&gt;(context, a, b, c);&lt;/p&gt;&amp;mdash; Gavin Joyce (@gavinjoyce) &lt;a href=&quot;https://twitter.com/gavinjoyce/status/950817905003900928?ref_src=twsrc%5Etfw&quot;&gt;January 9, 2018&lt;/a&gt;&lt;/blockquote&gt; &lt;script async src=&quot;https://platform.twitter.com/widgets.js&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;
&lt;h3&gt;Bind&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;The bind() method creates a new function that, when called, has its this keyword set to the provided value, with a given sequence of arguments preceding any provided when the new function is called.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Using bind is similar to call, but you need to create a new function that you can invoke later.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; person &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Chiamaka&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;jobTitle&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Software Engineer&apos;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;stack1&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; stack2&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; stack3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;My name is &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; and I am a &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;jobTitle&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;
  building solutions using &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;stack1&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;stack2&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;stack3&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; stack &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;JavaScript&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;React&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Redux&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; boundedFunction &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;bind&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;person&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; stack&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; stack&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; stack&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;boundedFunction&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Arrow Functions&lt;/h3&gt;
&lt;p&gt;For arrow functions, &lt;code class=&quot;language-text&quot;&gt;this&lt;/code&gt; refers to the lexical scope. It inherits the context of the parent.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; functionType &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;token literal-property property&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Regular function&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token function-variable function&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;type&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token literal-property property&quot;&gt;child&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Arrow function&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token function-variable function&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;type&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

functionType&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// &quot;Regular function&quot;&lt;/span&gt;
functionType&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;child&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// undefined&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can use arrow function when you want &lt;strong&gt;this&lt;/strong&gt; to reference the outer context. For instance, attaching an event listener to an element in an outer scope and referencing it from within a class.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Button A&lt;/strong&gt;:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;cta_buttonA&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  Click Button A
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; buttonA &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;.cta_buttonA&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ButtonA&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;buttonBackground &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;#ffdd40&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    buttonA&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;click&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;target&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;style&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;backgroundColor &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;buttonBackground&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ButtonA&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Button B&lt;/strong&gt;:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;cta_buttonB&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  Click Button B
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; buttonB &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;.cta_buttonB&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ButtonB&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;buttonBackground &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;#ffdd40&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    buttonB&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;click&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token parameter&quot;&gt;event&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;target&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;style&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;backgroundColor &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;buttonBackground&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ButtonB&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If you click &lt;strong&gt;Button A&lt;/strong&gt; which uses a regular function, &lt;code class=&quot;language-text&quot;&gt;this&lt;/code&gt; would be equal to event.currentTarget and cannot be used to access a value within the class without explicitly binding it whereas clicking on &lt;strong&gt;Button B&lt;/strong&gt; which uses arrow function would change the background color of the button.&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;In a nutshell, through this article, you&apos;ve learned about &lt;strong&gt;this&lt;/strong&gt; and its value in different use cases - implicit and explicit. Having learned this, you should be comfortable using it during development without questioning the result of &lt;code class=&quot;language-text&quot;&gt;this&lt;/code&gt;.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Concatenate, an Africa-focused Conference]]></title><description><![CDATA[On October 11th and 12th, I attended the Concatenate Conference held at Zone Tech Park, Lagos, Nigeria. It is a free conference for African…]]></description><link>https://chiamakaikeanyi.dev/concatenate-an-africa-focused-conference/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/concatenate-an-africa-focused-conference/</guid><pubDate>Thu, 17 Oct 2019 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;On October 11th and 12th, I attended the &lt;a href=&quot;https://concatenate.dev&quot;&gt;Concatenate Conference&lt;/a&gt; held at Zone Tech Park, Lagos, Nigeria. It is a free conference for African developers.&lt;/p&gt;
&lt;p&gt;This year&apos;s event happened in style as the event was scheduled to hold in two countries (Lagos, Nigeria and Nairobi, Kenya). Speakers flew in to attend the conference. Most of these speakers have not been to Africa before. They experienced Lagos traffic,  enjoyed the scenery, and the &lt;em&gt;Nigerian Jollof Rice&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;The event was packed with well-thought-out sessions and lightning talks presented by amazing people. These centred around community and support, building usable products, performance, etc.
The highlights are summarized below.&lt;/p&gt;
&lt;h3&gt;Engaging Empathy&lt;/h3&gt;
&lt;p&gt;The floor was opened by the amazing Sharon Steed with a talk on Engaging Empathy. The most important part that struck me is when she talked about embracing who you are and pushing through it, knowing that vulnerability is just trying.&lt;/p&gt;
&lt;p&gt;She identified 3 Key Empathy Behaviours;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Patience (the foundation of empathy, being present in a distracting world),&lt;/li&gt;
&lt;li&gt;Perspective (the root of understanding, thinking before you speak, eliminating bias) and&lt;/li&gt;
&lt;li&gt;Connection (the real reason we communicate, leaving every conversation in a better place than where it began).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;She concluded the talk with a heart-warming note. She stated that&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Life is hard; putting people first is important when collaborating as a team because, the more thoughtful that we are, the more connections we make by embracing empathy.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Retrospective of how CodeSandbox was built&lt;/h3&gt;
&lt;p&gt;Ives Van Hoorne gave a Retrospective of how CodeSandbox was built. He talked about how he moved from ideation to product actualization. Never would I have known that the CodeSandbox editor and the preview are two different applications until he mentioned it.&lt;/p&gt;
&lt;p&gt;He concluded with the wise words:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;If you have an idea that you deem imperfect, just work on it. It can turn into a great idea if you start working on it and keep evolving.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Seek external feedback; people being enthusiastic can motivate you to work and help refine the product. Also, release fast,
don&apos;t over-engineer; keep it simple, stupid (KISS).&lt;/p&gt;
&lt;p&gt;Key takeaways&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Abstract the core components&lt;/li&gt;
&lt;li&gt;Make your solution updatable&lt;/li&gt;
&lt;li&gt;Don&apos;t reinvent the wheel&lt;/li&gt;
&lt;li&gt;An item on the idea board may become a usable product&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;User-Centric Metrics&lt;/h3&gt;
&lt;p&gt;The loading and runtime experience on the web can be hard to measure. In the performance world, faster is better. A fast website improves the user experience leading to a boost in revenue. But, before optimizing, always measure.&lt;/p&gt;
&lt;p&gt;Yoav discussed two approaches to measurement to determine the speed and user experience on the web:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;LAB (lab-based measurement): This does not represent your real users&apos; experience. A computer is just set up to generate data and tests are run repeatedly under specific conditions e.g. &lt;a href=&quot;https://developers.google.com/web/tools/lighthouse&quot;&gt;Lighthouse&lt;/a&gt;, &lt;a href=&quot;https://www.webpagetest.org&quot;&gt;Webpagetest&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;RUM (Real user measurement): This captures your real users&apos; experience. However, this requires a lot of traffic to simulate, and tests must be run in a production environment to get the actual data. e.g. Chrome User Experience, PageSpeed Insights&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Lab-based measurement helps collect data before shipping a product while RUM helps verify that the feature doesn&apos;t regress performance. Results from RUM can be used as data to improve the Lab.&lt;/p&gt;
&lt;p&gt;The meaningful points to track the user&apos;s journey are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Visual
&lt;ul&gt;
&lt;li&gt;Speed Index&lt;/li&gt;
&lt;li&gt;Visual completeness (FP, FCP, FID, LCP, etc.)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Interactivity (TTI)&lt;/li&gt;
&lt;li&gt;User annoyance metrics&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Event timing also allows you to tag important elements in your page and get performance entries for them&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;h1&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;elementtiming&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;usefulcontent&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Useful content&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;h1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Design Systems and Art Direction&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Art Direction combines art and design to evoke a cultural and emotional reaction - Dan Mall&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Design Systems are the how, Art Direction is the why. This is where you check if the end-user feels good when using your product.&lt;/p&gt;
&lt;p&gt;It is better to modify, not remove the defaults because you feel it doesn&apos;t fit with the aesthetics of the website e.g. the :focus outline&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;:focus&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;outline&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; thin solid &lt;span class=&quot;token function&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;--primary-color&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;outline-offset&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; .25rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Translation !== Localization.
Localization does not mean changing words to different languages. It entails infusing the local market into the design; making the entire experience more appropriate for the culture of the user. It helps them feel like the product is made just for them.&lt;/p&gt;
&lt;p&gt;It is not right to make assumptions about other people&apos;s culture, include them in the design process. Consider avatar colour, writing mode, design style etc. These are things involved in localization, not changing the language to that of the audience.&lt;/p&gt;
&lt;p&gt;Accessibility is a collective effort. Don&apos;t make certain components accessible and the rest inaccessible. It is as good as no accessibility optimization done. The whole is better than the sum of its parts.&lt;/p&gt;
&lt;h3&gt;The Cost Of JavaScript in 2019&lt;/h3&gt;
&lt;p&gt;After downloading a web page, executing JavaScript becomes the dominant cost. JavaScript is the most expensive part of a website. When it blocks the main thread, nothing else can happen.
You have to optimize the code you&apos;re loading to improve user experience. Note that you need to make performance part of the conversation from the initial stage; set performance budgets to avoid degrading performance.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Small JavaScript bundles improve download speed, lower memory usage and reduce CPU costs&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Key takeaways&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Reduce the amount of JavaScript you ship&lt;/li&gt;
&lt;li&gt;Avoid  large bundles (50KB+)&lt;/li&gt;
&lt;li&gt;Avoid large inline scripts&lt;/li&gt;
&lt;li&gt;Ship less code (minify, cache)&lt;/li&gt;
&lt;li&gt;Download times are critical for low-end phones&lt;/li&gt;
&lt;li&gt;Use code-splitting&lt;/li&gt;
&lt;li&gt;Use lazy-loading&lt;/li&gt;
&lt;li&gt;Audit JavaScript regularly using webpack bundle analyzer, source-map explorer, import cost for VS Code&lt;/li&gt;
&lt;li&gt;Avoid using Moment.js, try date-fns.org instead&lt;/li&gt;
&lt;li&gt;Be careful when using lodash. Instead of importing the entire library, use specific imports e.g.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; times &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &apos;lodash&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;times&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;is better than&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; times &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &apos;lodash&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;For more savings, try &lt;a href=&quot;https://bit.ly/smaller-lodash&quot;&gt;lodash-webpack-plugin&lt;/a&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://bit.ly/lightwallet-docs&quot;&gt;Use Light Wallet&lt;/a&gt; or bundle size for setting performance budgets&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Improving performance is a journey. Take it one step at a time. Measure, optimize, monitor and repeat.&lt;/p&gt;
&lt;h3&gt;The Future of Web Animation&lt;/h3&gt;
&lt;p&gt;With 3D animations, there are lots of areas yet to be explored in the web development industry. Think outside the box; create applications that people would remember after they have seen it once (one that currently does not exist) because the web is meant for us to invent, share and communicate.&lt;/p&gt;
&lt;p&gt;However, it is imperative to note that design and page transitions can impact cognitive load. When making a change in the design or animating on the web, consider the cognitive load it may create on the users.&lt;/p&gt;
&lt;h3&gt;Systems of Systems&lt;/h3&gt;
&lt;p&gt;Every decision that we make at the atomic level has a huge impact that would help us build at scale.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Nothing can be changed until it is faced.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;There&apos;s a need to work as one; we are meant to help people who are less privileged than us.
We must learn to lift as we climb. Be Redwoods but have interwoven roots like Ivy to stand tall and strong.&lt;/p&gt;
&lt;h3&gt;Serverless Can Do That?!&lt;/h3&gt;
&lt;p&gt;With serverless, you focus on building your ideas, not on deployment as a lot of things are abstracted. Servers scale to meet your current workload. You can explore hosting services like Netlify, Azure, etc. to get started.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;npm install netlify&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;cli
npm install azure&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;functions&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;core&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;tools&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Key takeaways&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Write stateless code. You can&apos;t preserve state within function calls&lt;/li&gt;
&lt;li&gt;Serverless applications are event-driven&lt;/li&gt;
&lt;li&gt;Use tools that generate the boilerplate code for you&lt;/li&gt;
&lt;li&gt;Apply the Single Responsibility Principle&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Building Usable Products&lt;/h3&gt;
&lt;p&gt;Don&apos;t ship complicated products, let products solve users&apos; problems. Understand your users, test with them before launch and continuously collect feedback to help improve the product.&lt;/p&gt;
&lt;h3&gt;Docker for Dev and Test&lt;/h3&gt;
&lt;p&gt;Docker is not for DevOps Engineer alone. It can make it easy for teams to set up and update their development environment without having to install a variety of frameworks or tools.&lt;/p&gt;
&lt;p&gt;Docker Container !== Virtual Machine&lt;/p&gt;
&lt;p&gt;Containers are&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Isolated&lt;/li&gt;
&lt;li&gt;Consistent&lt;/li&gt;
&lt;li&gt;Portable&lt;/li&gt;
&lt;li&gt;Easy to use&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;AHA (Avoid Hasty Abstractions) Programming&lt;/h3&gt;
&lt;p&gt;Complex abstractions make it difficult to make changes to a codebase. It is important to be thoughtful about abstractions. DRY or WET? Under or over-abstraction?
You need to know when not to abstract and when to do so to help improve a codebase.&lt;/p&gt;
&lt;p&gt;Key takeaways&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;DRY is not necessarily a bad thing&lt;/li&gt;
&lt;li&gt;You cannot tell the future: optimize for change&lt;/li&gt;
&lt;li&gt;Duplication is far cheaper than the wrong abstraction, so prefer duplication over the wrong abstraction - Sandi Metz&lt;/li&gt;
&lt;li&gt;Wait for commonalities in duplicate code to scream at you for abstraction.&lt;/li&gt;
&lt;li&gt;If you have &quot;shared code&quot; with lots of branches then resist the urge to add more conditionals to it. Refactor it first.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Building a Business&lt;/h3&gt;
&lt;p&gt;Before saying that something can&apos;t be done, try to validate the idea (validate early, validate often). Focus on where your core values lies, solve a known problem. Don&apos;t re-invent the wheel, use available services to build your business and create value.&lt;/p&gt;
&lt;h3&gt;Solving Diabetics With An Open Source Artificial Pancreas&lt;/h3&gt;
&lt;p&gt;The mystery speaker, Scott Hanselman handled this topic. He discussed ways to control blood sugar level with software and hardware. He has an API that monitors his blood sugar level. This would enable his wife, doctor and Siri to monitor his blood sugar level and be sure he is in a good state.&lt;/p&gt;
&lt;p&gt;Key takeaway&lt;/p&gt;
&lt;p&gt;Instead of building a product just for yourself, involve the community and build solutions that would be beneficial to all. Everyone has a battle they are fighting, remember that once you look at colour and gender, these would remain unsolved.&lt;/p&gt;
&lt;p&gt;A lot of useful talks were presented. You can watch the &lt;a href=&quot;https://www.youtube.com/watch?v=NzGCI_uGm0o&quot;&gt;Day1&lt;/a&gt;, &lt;a href=&quot;https://www.youtube.com/watch?v=-Ez53J0vj9c&quot;&gt;Day2&lt;/a&gt; and &lt;a href=&quot;https://www.youtube.com/watch?v=sat_BG4xxMk&quot;&gt;Day 3&lt;/a&gt;  live stream to get a full grasp of all that happened during the conference.&lt;/p&gt;
&lt;hr&gt;
&lt;h2&gt;The slides I could find on the web&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://www.linkedin.com/learning/communicating-with-empathy/welcome&quot;&gt;Sharon&apos;s course on Engaging Empathy&lt;/a&gt;,
&lt;a href=&quot;https://speakerdeck.com/adoranwodo/productive-debugging-because-time-is-money&quot;&gt;Productive Debugging&lt;/a&gt;,
&lt;a href=&quot;https://bit.ly/concat-metrics&quot;&gt;User Centric Metrics&lt;/a&gt;,
&lt;a href=&quot;https://speakerdeck.com/silm/building-usable-products&quot;&gt;Building Usable Products&lt;/a&gt;,
&lt;a href=&quot;https://speakerdeck.com/addyosmani/the-cost-of-javascript-in-2019&quot;&gt;The Cost Of JavaScript in 2019&lt;/a&gt;,
&lt;a href=&quot;https://noti.st/sdras/PimT6j/the-future-of-web-animation&quot;&gt;The Future of Web Animation&lt;/a&gt;,
&lt;a href=&quot;http://slides.com/tatianamac/systems-of-systems&quot;&gt;Systems of Systems&lt;/a&gt;,
&lt;a href=&quot;http://serverlesscandothat.com:9000/gitpitch/desktop&quot;&gt;Serverless Can Do That?!&lt;/a&gt;,
&lt;a href=&quot;https://speakerdeck.com/hacksultan/moving-from-beginner-to-a-junior-developer&quot;&gt;Moving from Beginner to a Junior Developer&lt;/a&gt;,
&lt;a href=&quot;https://github.com/kentcdodds/aha-programming-slides&quot;&gt;AHA (Avoid Hasty Abstractions) Programming&lt;/a&gt;,
&lt;a href=&quot;https://speakerdeck.com/vakila/first-steps-into-functional-programming&quot;&gt;Functional Programming Basics in JavaScript&lt;/a&gt;,
&lt;a href=&quot;https://vakila.github.io/mapbox-concatenate-workshop&quot;&gt;Building Interactive Maps with Mapbox&lt;/a&gt;,
&lt;a href=&quot;http://slides.com/tatianamac/technical-debt-for-us&quot;&gt;Technical Debt for Us&lt;/a&gt;,
&lt;a href=&quot;https://concatenateconf2019.ahmadawais.com&quot;&gt;VS CODE Power User Workflows&lt;/a&gt;,
&lt;a href=&quot;https://speakerdeck.com/kenny_io/the-state-of-payments-in-africa&quot;&gt;The State of Payments in Africa&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Links to mentioned resources&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://developers.google.com/speed&quot;&gt;Speed&lt;/a&gt;,
&lt;a href=&quot;https://web.dev&quot;&gt;Web.dev&lt;/a&gt;,
&lt;a href=&quot;https://www.theurlist.com&quot;&gt;URList&lt;/a&gt;,
&lt;a href=&quot;https://jamstack.org&quot;&gt;Jamstack&lt;/a&gt;,
&lt;a href=&quot;https://staticgen.com&quot;&gt;Staticgen&lt;/a&gt;,
&lt;a href=&quot;https://headlesscms.org&quot;&gt;Headles CMS&lt;/a&gt;,
&lt;a href=&quot;https://www.carbondesignsystem.com/guidelines/accessibility/overview&quot;&gt;Carbon design system&lt;/a&gt;,
&lt;a href=&quot;http://accessibility.digital.gov&quot;&gt;Accessibility&lt;/a&gt;,
&lt;a href=&quot;https://browser.geekbench.com&quot;&gt;Geekbench browser for benchmarking&lt;/a&gt;,
&lt;a href=&quot;http://atomicdesign.bradfrost.com&quot;&gt;Atomic design&lt;/a&gt;,
&lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurefunctions&quot;&gt;VS Code Extension for Azure functions&lt;/a&gt;,
&lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker&quot;&gt;Docker&lt;/a&gt;,
&lt;a href=&quot;https://www.sandimetz.com/blog/2016/1/20/the-wrong-abstraction&quot;&gt;The Wrong Abstraction&lt;/a&gt;,
&lt;a href=&quot;https://www.gatsbyjs.org&quot;&gt;Gatsby&lt;/a&gt;,
&lt;a href=&quot;https://baremetrics.com/open&quot;&gt;Bare Metrics&lt;/a&gt;,
&lt;a href=&quot;https://indiehackers.com/products&quot;&gt;Indie Hackers&lt;/a&gt;,
&lt;a href=&quot;https://tidepool.org&quot;&gt;TidePool&lt;/a&gt;,
&lt;a href=&quot;https://www.nightscoutfoundation.org&quot;&gt;Nightscout Foundation&lt;/a&gt;,
&lt;a href=&quot;https://openaps.org/&quot;&gt;OpenAPS&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Resource Hinting Techniques]]></title><description><![CDATA[When you input a URL to fetch content using the browser, certain processes occur under the hood - DNS resolution, request/response cycle and…]]></description><link>https://chiamakaikeanyi.dev/resource-hinting-techniques/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/resource-hinting-techniques/</guid><pubDate>Thu, 18 Jul 2019 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;When you input a URL to fetch content using the browser, certain processes occur under the hood - DNS resolution, request/response cycle and rendering.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The Domain Name Server (DNS) matches the domain name to an IP address.&lt;/li&gt;
&lt;li&gt;The browser sends an HTTP request to the server and the server sends back an HTTP response.&lt;/li&gt;
&lt;li&gt;The browser begins rendering the HTML on the page while also requesting any additional resources.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Each subsequent request completes a request/response cycle and is rendered in turn by the browser.
This request/response cycle is referred to as a &lt;strong&gt;round trip&lt;/strong&gt;. This varies depending on network conditions. Establishing the connection ahead of time helps reduce the round trip and make applications faster.&lt;/p&gt;
&lt;p&gt;In this article, I&apos;m going to explore resource hinting techniques, the difference between them and performance gains that can be achieved with them.&lt;/p&gt;
&lt;h2&gt;Preload, Prefetch, and Preconnect&lt;/h2&gt;
&lt;p&gt;Preload, Prefetch and Preconnect are resource hinting techniques used to inform the browser of your intention to resolve specified domain names or establish connection to specified domains as soon as possible. Hinting browsers about needed resources helps improve the page load time as connections to important third-party origins must have been established prior to when they are needed.&lt;/p&gt;
&lt;p&gt;This can be achieved by adding the &lt;code class=&quot;language-text&quot;&gt;rel=&quot;preload&quot;&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;rel=&quot;prefetch&quot;&lt;/code&gt; or &lt;code class=&quot;language-text&quot;&gt;rel=&quot;preconnect&quot;&lt;/code&gt; attribute to the &lt;code class=&quot;language-text&quot;&gt;&amp;lt;link &gt;&lt;/code&gt; element.&lt;/p&gt;
&lt;h2&gt;Preload&lt;/h2&gt;
&lt;p&gt;Preload offers control on fetching resources for the current navigation. It is a high-priority hint. This is useful for fetching important resources - images, CSS, JavaScript, and font files needed to render a page without blocking the document&apos;s onload event and storing them in the cache. Using this, you can speed up resource loading and minimize the amount of time that fallback text is shown (for font files) when users visit your site.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;link&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;rel&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;preload&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;https://domain.com&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;as&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;script&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;For font files, you need to set &lt;code class=&quot;language-text&quot;&gt;crossorigin&lt;/code&gt; attribute as they are loaded in anonymous mode. When this is omitted, the browser performs DNS lookup only.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;link&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;rel&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;preload&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;https://fonts.domain.com/font.woff2&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;as&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;font&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;font/woff2&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;crossorigin&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Prefetch&lt;/h2&gt;
&lt;p&gt;Prefetch focuses on fetching a resource for the next navigation. It is a low-priority hint to the browser that a resource might be needed.
There are different types of prefetching - link, DNS, and prerendering.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Link prefetching notifies the browser to fetch resources that the user might request and store them in cache.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;link&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;rel&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;prefetch&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;https://domain.com&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Due to the limit placed on the number of domains the browser can pre-connect to at a specific time, DNS prefetch comes in handy. DNS prefetching notifies the browser to perform DNS lookups at the background. This minimizes latency and can be achieved by adding the &lt;code class=&quot;language-text&quot;&gt;rel=&quot;dns-prefetch&quot;&lt;/code&gt; attribute to the &lt;code class=&quot;language-text&quot;&gt;&amp;lt;link&gt;&lt;/code&gt; element. This is useful for fetching external resources - CDNs, Google Analytics, Google fonts etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;link&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;rel&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;dns-prefetch&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;https://cdn.livechatinc.com&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;link&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;rel&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;dns-prefetch&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;https://www.google-analytics.com&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;link&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;rel&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;dns-prefetch&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;https://fonts.googleapis.com&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;link&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;rel&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;dns-prefetch&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;https://js-agent.newrelic.com&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Prerendering is very similar to prefetching. It aggregates resources that the user is likely to navigate to next. In addition, it renders the entire page in the background. To test if a page is prerendered, navigate to &lt;code class=&quot;language-text&quot;&gt;chrome://net-internals/#prerender&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;link rel=&quot;prerender&quot; href=&quot;https://domain.com/about&quot;&gt;
&lt;h2&gt;Preconnect&lt;/h2&gt;
&lt;p&gt;Preconnect notifies the browser to setup connections (DNS lookups, TLS negotiations, TCP handshakes) before an HTTP request is sent to the server. This eliminates roundtrip latency and saves time for users.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;link&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;https://cdn.domain.com&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;rel&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;preconnect&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;crossorigin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Resource hinting helps to improve page load time when you need to use resources from third-party domains. However, only preconnect to critical third-party origins you will use within 10 seconds. If the connection is not used as soon as possible, the browser closes. This results to wasting time and users bandwidth needed to fetch other useful resources.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Grasping the SOLID Principles]]></title><description><![CDATA[SOLID is a core principle of object-oriented design promoted by Robert C. Martin.
It is an acronym for software design principles applied…]]></description><link>https://chiamakaikeanyi.dev/grasping-the-solid-principles/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/grasping-the-solid-principles/</guid><pubDate>Thu, 20 Jun 2019 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;SOLID is a core principle of object-oriented design promoted by Robert C. Martin.
It is an acronym for software design principles applied when crafting maintainable software solutions.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;S - Single Responsibility Principle&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;O - Open–Closed Principle&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;L - Liskov Substitution Principle&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;I - Interface Segregation Principle&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;D - Dependency Inversion Principle&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I&apos;ll be going through each of these with code samples to make these principles easy to understand.&lt;/p&gt;
&lt;h2&gt;Single responsibility&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;A class should have one, and only one, reason to change.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;A class should perform only one task. It should only do one thing. That is to say that classes should be loosely coupled. Changes to just one part of a specification should not be able to affect the class. When changes to different parts of the specification affects a class in multiple ways, it means that this element of the principle fails.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Shape&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;width&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; height&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;width &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; width&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;height &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; height&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token function&quot;&gt;calculateArea&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// calculate the area;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token function&quot;&gt;calculatePerimeter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// calculate the perimeter;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token function&quot;&gt;formatResult&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// format the result&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In the above example, the class does more than one thing i.e. having &lt;code class=&quot;language-text&quot;&gt;formatResult()&lt;/code&gt; method,
it violates the single responsibility principle and therefore increases its likeliness to change when something else changes.
What if the required result is not provided in the format specified by &lt;code class=&quot;language-text&quot;&gt;formatResult()&lt;/code&gt;?
It will need the method to be modified thereby also violating the open-close principle.&lt;/p&gt;
&lt;div class=&quot;info&quot;&gt;
However, this does not mean that the class should have only one method,
it means that all methods within a class should be focused on carrying out one responsibility.
&lt;/div&gt;
&lt;p&gt;A better approach is&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Result&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;format&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;format &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; format&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token function&quot;&gt;formatResult&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;switch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;format&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;string&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;JSON&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;stringify&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;result&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

      &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;object&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;JSON&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;parse&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;result&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

      &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;number&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;parseInt&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;result&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

      &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;binary&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;parseInt&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;result&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

      &lt;span class=&quot;token keyword&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; result&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Shape&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;width&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; height&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; format&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;width &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; width&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;height &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; height&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;format &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; format&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token function&quot;&gt;calculateArea&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;width&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; height&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; format&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// calculate and return the area;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token function&quot;&gt;calculatePerimeter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;width&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; height&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; format&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// calculate and return the perimeter;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To use the class,&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; area &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Shape&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;string&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Open–closed&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Software entities should be open for extension, but closed for modification.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This advocates that software entities should be extensible, but not modifiable. It should be open for extension by other classes but closed for modification.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Shape&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;shape&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;shape &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; shape&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token function&quot;&gt;calculateArea&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; area&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token function&quot;&gt;foreach&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;shapes &lt;span class=&quot;token keyword&quot;&gt;as&lt;/span&gt; shape&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;shape &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Square&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        area &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;pow&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;shape &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Circle&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        area &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;pi&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;pow&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;radius&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;throw&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Error&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Unknown shape&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; area&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To calculate the area of another shape with the example above, it requires another else if block which leads to the modification of the &lt;code class=&quot;language-text&quot;&gt;calculateArea&lt;/code&gt; in the given class.
A better approach is to move the logic to the particular shape&apos;s (e.g. Circle) class and implement shape interface.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;interface&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ShapeInterface&lt;/span&gt;  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;calculateArea&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Square&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;implements&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ShapeInterface&lt;/span&gt;  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;length&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

      &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; length&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;token function&quot;&gt;calculateArea&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;pow&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Circle&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;implements&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ShapeInterface&lt;/span&gt;  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;radius&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;radius &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; radius&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token function&quot;&gt;calculateArea&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;pi&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;pow&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;radius&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token function&quot;&gt;calculateDiameter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;radius &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getArea&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;shapes&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Shape&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; shapes&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;reduce&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;previous&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; current&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; previous &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; current&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;calculateArea&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Liskov Substitution&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Let q(x) be a property provable about objects of x of type T. Then q(y) should be provable for objects y of type S where S is a subtype of T.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This postulates that objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.&lt;/p&gt;
&lt;p&gt;If you have Circle class as a sub class of Shape, Shape class should be easily substituted with Circle class without causing any thing to break&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;interface&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ShapeInterface&lt;/span&gt;  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// returns a number&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;calculateArea&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;


&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Shape&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;implements&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ShapeInterface&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;calculateArea&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// returns a number&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Circle&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Shape&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;calculateArea&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// return a number&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// if the implementation of this returns the value in another format,&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// it violates this principle as it cannot be used in place of the parent class&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Interface Segregation&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;A Client should not be forced to implement an interface that it doesn’t use.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Many client-specific interfaces are better than one general-purpose interface.
Similar to the Single Responsibility Principle, the goal here is to minimize redundant code by dividing
the software components into multiple, independent parts.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;interface&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ShapeInterface&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;calculateArea&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;calculateVolume&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Given the example above, shapes will be forced to abide by the contract specified by the interface.
This violates the single responsibility and interface segregation principles.
To fix this, &lt;code class=&quot;language-text&quot;&gt;calculateVolume();&lt;/code&gt; would be moved to a different interface.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;interface&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ShapeInterface&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;calculateArea&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;interface&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ShapesWithDepthInterface&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;calculateVolume&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Usage:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Square&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;implements&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ShapeInterface&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;calculateArea&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// calculate the area&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Cone&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;implements&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ShapeInterface&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; ShapesWithDepthInterface &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;calculateArea&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// calculate the area&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token function&quot;&gt;calculateVolume&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// calculate the volume&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Dependency Inversion&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;High-level modules should not depend on low-level modules. Both should depend on abstractions.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Abstractions should not depend on details. Details should depend on abstractions.&lt;/p&gt;
&lt;p&gt;This advocates for decoupling. One should depend upon abstractions(interfaces), NOT concretions (classes).
Despite the similarity to dependency injection, this is a bit different.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Form&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Input type&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;type &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; type&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Input is the low-level module while Form is high-level. The form should not care about the input you pass to it.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;interface&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;InputInterface&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;constructInput&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Input&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;implements&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;InputInterface&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;constructInput&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;type&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token comment&quot;&gt;// construct the input&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Form&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;InputInterface input&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;input &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; input&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;It is paramount to note that most of the principles rely on the use of interfaces.
Using interfaces (&lt;strong&gt;Interface Segregation principle&lt;/strong&gt;) helps you to isolate implementation details
from business logic(&lt;strong&gt;Single Responsibility principle&lt;/strong&gt;). This will also enable you to replace an
implementation with its subtype(&lt;strong&gt;Liskov Substitution principle&lt;/strong&gt;) and enable you to write applications
that are open for extension but close for modification (&lt;strong&gt;Open/Close principle&lt;/strong&gt;).&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;SOLID Principles is a standard that all developers should adopt to write decoupled and
maintainable code. It might sound abstract at first, but with practice, you&apos;ll have a good grasp
of it and improve the quality of code you write.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Code Review That Helps]]></title><description><![CDATA[Having an efficient code review process is essential to ensure code quality, grow as a team and get a good grasp of the entire project…]]></description><link>https://chiamakaikeanyi.dev/code-review-that-helps/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/code-review-that-helps/</guid><pubDate>Thu, 06 Jun 2019 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Having an efficient code review process is essential to ensure code quality, grow as a team and get a good grasp of the entire project. However, different people view code review in different ways that it either sounds boring or exciting.&lt;/p&gt;
&lt;p&gt;In this article, I would discuss ways to conduct good code reviews and make it a means of learning/adding value rather than a political or emotional argument.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Code review (sometimes referred to as peer review) is a software quality assurance process in which team members go through a computer program mainly by viewing and reading parts of its source code to spot mistakes.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Before a code review process can begin, a pull request has to be made. A pull request (PR) is a request to introduce changes to a code repository through a &lt;a href=&quot;/working-with-git&quot;&gt;Git&lt;/a&gt; branch. This is done using tools like GitHub, Bitbucket, Gitlab etc. Once the pull request is opened, the Engineer notifies reviewers to give their feedback on code improvements (and updates the code if necessary). When the Engineer and reviewers are satisfied with the code, the changes are merged into the base branch.&lt;/p&gt;
&lt;h2&gt;Why code review matters&lt;/h2&gt;
&lt;p&gt;Code review is essential to ship quality software solutions to real-life problems rather than introducing one. Despite the experience level, it is necessary to have someone review your code. It&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;ensures that coding standards are adhered to&lt;/li&gt;
&lt;li&gt;facilitate knowledge sharing&lt;/li&gt;
&lt;li&gt;helps team members make an extra effort to ensure code quality&lt;/li&gt;
&lt;li&gt;helps everyone get familiar with the codebase and best practices&lt;/li&gt;
&lt;li&gt;provides room for someone else to suggest a better approach to solve a problem&lt;/li&gt;
&lt;li&gt;limits the risk of introducing bugs thereby improving code quality&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Questions to ask yourself during code reviews&lt;/h2&gt;
&lt;p&gt;When conducting a code review, ponder on these below. Answering each of them helps you know things to look out for during the review process.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Is the piece of code difficult to understand? It might need refactoring&lt;/li&gt;
&lt;li&gt;Are the method and class names intuitive? They may need to be renamed&lt;/li&gt;
&lt;li&gt;Does the method do much? It may need to be broken down&lt;/li&gt;
&lt;li&gt;Are there many comment blocks? The method names may need to show what the code does&lt;/li&gt;
&lt;li&gt;Is the code well organized? It may not be maintainable&lt;/li&gt;
&lt;li&gt;Does the code have test coverage?&lt;/li&gt;
&lt;li&gt;Could the code be made more efficient?&lt;/li&gt;
&lt;li&gt;Are all the requirements, stated in the ticket fully implemented?&lt;/li&gt;
&lt;li&gt;Does it meet the coding standards of the team?&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;How to do a proper code review&lt;/h2&gt;
&lt;p&gt;Reviewing someone&apos;s code should not be about the approvals. It is about helping a co-worker find mistakes in his/her code and ways to make it better. When someone sends you their PR to review, it means that the person values your time and input. Find time to help and do it properly.&lt;/p&gt;
&lt;p&gt;Look out for deviation from coding standards, readability, maintainability of every piece of code, test coverage, performance, accessibility and security bottlenecks.&lt;/p&gt;
&lt;p&gt;A good code is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Well designed&lt;/li&gt;
&lt;li&gt;Readable by others&lt;/li&gt;
&lt;li&gt;Does what the author intended&lt;/li&gt;
&lt;li&gt;Not too complex&lt;/li&gt;
&lt;li&gt;Not degrading system code health&lt;/li&gt;
&lt;li&gt;Commented with the why vs. what&lt;/li&gt;
&lt;li&gt;Appropriately tested&lt;/li&gt;
&lt;li&gt;Sufficiently documented&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Review your code&lt;/h3&gt;
&lt;p&gt;It is important to review your code to spot mistakes before requesting for a code review. Ensure
that your code compiles successfully and passes the test cases. This helps you spot little mistakes before your reviewers do.&lt;/p&gt;
&lt;h3&gt;Foster a positive culture&lt;/h3&gt;
&lt;p&gt;When a comment is made regarding a part of the code you didn&apos;t write, don&apos;t take offence; rather be happy to fix it and help in paying technical debts. Avoid words such as &quot;That isn&apos;t my code. My linting tool only formatted it&quot;. Have a positive culture around code reviews, it should not matter who introduced the bug. All that should matter is preventing the bug from being deployed to production. Or, eliminating the bug if it wasn&apos;t caught earlier.&lt;/p&gt;
&lt;h3&gt;Automate&lt;/h3&gt;
&lt;p&gt;Automate what can be automated. Make use of stylelint, eslint and other tools to help improve the quality of your code. This helps code reviewers focus on the code and not spend time spotting issues that can be found automatically.&lt;/p&gt;
&lt;h3&gt;Declutter&lt;/h3&gt;
&lt;p&gt;Let one PR do one thing. When the purpose of the code change is clear, reviewing becomes much easier and increases feedback.&lt;/p&gt;
&lt;h3&gt;Have a context of the problem&lt;/h3&gt;
&lt;p&gt;Your job is not just to spot syntax errors, having a context of the problem is important to create a bigger picture and be sure the solution fits into it. To help team members get an insight into the problem, it is paramount for the submitter to link the issue / ticket number to the pull request. If it needs further clarifications, provide it in the description field.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;TicketNumber: Issue description&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;or&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Fixes #issueNumber: Issue description&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Note that when constructing the commit message, start with a verb e.g. SPA-001: Bootstrap the app&lt;/p&gt;
&lt;h3&gt;Attend to comments&lt;/h3&gt;
&lt;p&gt;You certainly should not leave a comment unattended, you either respond to it or fix the issue. If you do not understand what the reviewer meant, ask for clarifications; don&apos;t be emotionally attached to your code. Afterwards, notify the team member that dropped the comment that it has been attended to.
Going ahead to resolve a comment dropped by another or merging a PR with unattended comments is a way of telling the team member who dropped the comment that you do not value his/her input.&lt;/p&gt;
&lt;h3&gt;Be objective&lt;/h3&gt;
&lt;p&gt;Rephrase your objection as a question. It helps to get the desired result without much argument.&lt;/p&gt;
&lt;p&gt;Bad: “This change will break feature XXX.”&lt;/p&gt;
&lt;p&gt;Good: “Will there be a possible negative impact on XXX with your change?”&lt;/p&gt;
&lt;h3&gt;Be open to new ideas&lt;/h3&gt;
&lt;p&gt;You may have an entirely different approach to solving a specific problem. Being open helps you learn new and possibly better approaches instead of imposing your approach on your team members.&lt;/p&gt;
&lt;p&gt;Bad: “This approach sucks, use XXX.”&lt;/p&gt;
&lt;p&gt;Good: “I have a similar feature implemented using approach XXX because YYY does ZZZ. You can learn more about this on LINK XXX.&lt;/p&gt;
&lt;h3&gt;Acknowledge people&apos;s level of experience&lt;/h3&gt;
&lt;p&gt;Everybody is not on the same level of experience with you, so state the obvious without being sarcastic about it or treat people like they don&apos;t deserve to be Software Engineers. Pointing out useful examples or suggesting a way to implement it will help get everyone on the same page.&lt;/p&gt;
&lt;p&gt;Bad: “Can’t you see that this is wrong, letting a break in XXX break the app?”&lt;/p&gt;
&lt;p&gt;Good: “You can make this fail-safe and return early by doing XXX.&lt;/p&gt;
&lt;h3&gt;Be respectful&lt;/h3&gt;
&lt;p&gt;It doesn’t cost anything extra to be respectful when letting people know that the submission doesn’t meet the code standard for quality.&lt;/p&gt;
&lt;p&gt;Bad: “This code doesn&apos;t meet the minimum standard. Didn&apos;t you read CONTRIBUTING.md before making this PR?&lt;/p&gt;
&lt;p&gt;Good: “Thanks for your contribution. However, it cannot be accepted in its current form; there are multiple problems (as outlined below). Consider reading CONTRIBUTING.md, that could help us find a path forward.”&lt;/p&gt;
&lt;h3&gt;Be a team player&lt;/h3&gt;
&lt;p&gt;When reviewing many lines of code at once, you are less likely to find bugs. So, if a PR contains many files that will take much time to review at once, be polite when letting the submitter know about it. The codebase belongs to the team. Also, as a submitter, keep your pull requests small to speed up review time.&lt;/p&gt;
&lt;p&gt;Bad: “This contains quite a lot. I do not have time to review it.”&lt;/p&gt;
&lt;p&gt;Good: “Could you please break this down into smaller changes? I do not have a lot of time and this contains quite a lot to review at once.”&lt;/p&gt;
&lt;h3&gt;Be polite&lt;/h3&gt;
&lt;p&gt;When a PR wouldn&apos;t be allowed to slide through due to details that may seem minor like formatting, saying “please” shows that you respect the submitter’s time and can go a long way in getting the submitter to make the change without feeling bad.&lt;/p&gt;
&lt;p&gt;Bad: &quot;This code is not properly formatted&quot;&lt;/p&gt;
&lt;p&gt;Good: &quot;Could you please align these variable definitions so they’re easier to read?&quot;&lt;/p&gt;
&lt;h3&gt;Show appreciation&lt;/h3&gt;
&lt;p&gt;Always show appreciation when a team member does a good job. As a code submitter, also show that you value feedback from the reviewers. Showing that you appreciate as a motivation.&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Peradventure code review is not yet a part of the code shipping process in your organization, you can introduce it and watch the effect it will have on your team. However, if the code review process is not well planned, it could have more cost than value. Enjoy the process, do not see it as a waste of time.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Understanding Aria]]></title><description><![CDATA[When working on complex UIs or dynamic JavaScript-updated content, there are times when you cannot achieve your goal using semantic HTML…]]></description><link>https://chiamakaikeanyi.dev/understanding-aria/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/understanding-aria/</guid><pubDate>Thu, 23 May 2019 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;When working on complex UIs or dynamic JavaScript-updated content, there are times when you cannot achieve your goal using semantic HTML. This is where ARIA plays an important role. It supplements HTML and passes interactions in applications to assistive technologies. For instance, when working with modals and custom elements, there is no semantic element you can use to announce its function to assistive technologies. WAI-ARIA bridges these accessibility issues that cannot be handled with native HTML.&lt;/p&gt;
&lt;p&gt;In this article, I will explore the areas you need to use ARIA to augment the standard DOM accessibility tree.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href=&quot;https://www.w3.org/TR/wai-aria/&quot;&gt;Web Accessibility Initiative Accessible Rich Internet Applications (WAI-ARIA)&lt;/a&gt; is a specification written by the W3C. It defines a set of attributes that provide ways to make web content and web applications more accessible.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This does not mean that you should add roles and aria-* everywhere, it is preferable to &lt;a href=&quot;/writing-standards-compliant-html&quot;&gt;write semantic HTML&lt;/a&gt; where possible, instead of using aria attributes. Semantic HTML can function effectively because they have the implicit meaning of these ARIA roles you declare explicitly; they have built-in keyboard accessibility, roles and states.&lt;/p&gt;
&lt;div class=&quot;info&quot;&gt;
&lt;b&gt;Note&lt;/b&gt;: Test your site using screen readers and keyboard navigation. This will give you insights on things to improve.
&lt;/div&gt;
&lt;p&gt;Instead of creating a custom checkbox and adding ARIA role and attributes to specify its function,&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;checkbox&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;aria-checked&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;false&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;aria-label&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Not checked&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;aria-labelledby&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;label&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;checkbox&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;tabindex&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;0&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;label&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Custom checkbox&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;use the actual HTML element&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;checkbox&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-labelledby&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;label&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;checkbox&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;label&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Default checkbox&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Avoid using a &lt;code class=&quot;language-text&quot;&gt;&amp;lt;button&gt;&lt;/code&gt; where &lt;code class=&quot;language-text&quot;&gt;&amp;lt;a&gt;&lt;/code&gt; can suffice vice-versa. Instead of using&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;button&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Place Order&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;use&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  Place Order
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;While &lt;code class=&quot;language-text&quot;&gt;&amp;lt;a&gt;&lt;/code&gt; can be styled to look like a button, assistive technologies will have no clue and announce it as a link. &lt;code class=&quot;language-text&quot;&gt;&amp;lt;a&gt;&lt;/code&gt; implies that when clicked on, it will navigate the user to another page. However, &lt;code class=&quot;language-text&quot;&gt;&amp;lt;button&gt;&lt;/code&gt; is expected to trigger an action within the same page. Using the wrong elements makes visually impaired users miss out on the purpose of the element.&lt;/p&gt;
&lt;h2&gt;Features of WAI-ARIA&lt;/h2&gt;
&lt;p&gt;WAI-ARIA has three main features namely &lt;strong&gt;roles&lt;/strong&gt;, &lt;strong&gt;properties&lt;/strong&gt;, and &lt;strong&gt;states&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Roles define what an element is&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;nav&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;navigation&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;...&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;nav&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;properties define attributes of elements which provide extra meaning to the element&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-label&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;This is for screen readers&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;...&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;and states define the current conditions of elements.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Email&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-disabled&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;true&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Applications of WAI-ARIA&lt;/h2&gt;
&lt;p&gt;WAI-ARIA is applied in several use cases:&lt;/p&gt;
&lt;h3&gt;Landmarks&lt;/h3&gt;
&lt;p&gt;It is imperative to note that you do not have to redefine default semantics. ARIA &lt;code class=&quot;language-text&quot;&gt;role&lt;/code&gt; replicate the default semantics of HTML5 elements. Adding role to a semantic element is a duplication as they have implicit ARIA semantics. However, if you are working on complex UI, or developing for old browsers e.g. IE8, adding the role attribute is essential.&lt;/p&gt;
&lt;p&gt;The search form is an important landmark that people will want to find, but it is not treated as one; it is read to screen readers as edit text. To treat it as a notable landmark, add the role attribute.&lt;/p&gt;
&lt;p&gt;Try navigating to these two search fields using a keyboard and listen to what is read out by the screen reader to notice the difference.&lt;/p&gt;
&lt;input type=&quot;search&quot; placeholder=&quot;Search...&quot; aria-label=&quot;Search for products, brands and categories...&quot; /&gt;
&lt;input type=&quot;search&quot; role=&quot;search&quot; placeholder=&quot;Search...&quot; aria-label=&quot;Search for products, brands and categories...&quot; /&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- anti-pattern but useful for old browsers e.g. IE8 --&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;main&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;main&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;...&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- standard --&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;...&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;search&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;search&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;placeholder&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Search...&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;aria-label&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Search for products, brands and categories...&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Announcing Updates&lt;/h3&gt;
&lt;p&gt;Dynamic contents are not reported to screen readers by default. Use &lt;code class=&quot;language-text&quot;&gt;aria-live&lt;/code&gt; to report these updates. While &lt;code class=&quot;language-text&quot;&gt;aria-live=&quot;polite&quot;&lt;/code&gt; informs the user about a particular change when they are idle, &lt;code class=&quot;language-text&quot;&gt;aria-live=&quot;assertive&quot;&lt;/code&gt; intercepts whatever they are doing and announces the update.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;search&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;search&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;placeholder&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Search...&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;aria-label&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Search for products, brands and categories...&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ul&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-live&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;polite&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;search_results&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;item 1&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;item 2&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;However, only the updated part is read out. You can use &lt;code class=&quot;language-text&quot;&gt;aria-atomic=&quot;true&quot;&lt;/code&gt; to control the area of the live region to be read out. When it is set to false, only the updated area will be read out. &lt;code class=&quot;language-text&quot;&gt;aria-busy=&quot;true&quot;&lt;/code&gt; forces screen readers to wait till all updates are complete before reading the update.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-live&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;polite&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-atomic&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;true&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-busy&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;true&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Total: $400&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Bridging Accessibility Gap&lt;/h3&gt;
&lt;p&gt;When creating complex UIs that cannot be achieved with native HTML elements, use ARIA attributes to bridge the gap. WAI-ARIA extends the tabindex attribute to make non-focusable elements focusable.&lt;/p&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;tabindex=&quot;0&quot;&lt;/code&gt; provides tabbable functionality to elements that are not tabbable.&lt;/p&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;tabindex=&quot;-1&quot;&lt;/code&gt; allows non-tabbable elements to receive focus programmatically using JavaScript or as the target for links.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;nav&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;#about&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
       About
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;nav&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;section&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;about&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;tabindex&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;-1&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  About Us
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;section&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Error Alerting&lt;/h3&gt;
&lt;p&gt;You can use ARIA roles and attributes like &lt;code class=&quot;language-text&quot;&gt;alert&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;aria-relevant&lt;/code&gt; for alerting users about errors. The &lt;code class=&quot;language-text&quot;&gt;aria-relevant&lt;/code&gt; attribute is used to control what gets read out when a live region is updated i.e. content additions or removals.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;errors&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;alert&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-relevant&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;all&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;...&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Form Handling&lt;/h3&gt;
&lt;p&gt;There are different aria attributes used for form handling. You can use aria-disabled attribute to define the current state of elements on web applications. &lt;code class=&quot;language-text&quot;&gt;aria-disabled=&quot;true&quot;&lt;/code&gt; tells a screen reader that the form input in focus is disabled.&lt;/p&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;aria-required=&quot;true&quot;&lt;/code&gt; should be used on required form input to specify that the input needs to be filled in and &lt;code class=&quot;language-text&quot;&gt;aria-invalid=&quot;true&quot;&lt;/code&gt; is used to specify invalid form entries.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Email&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-required&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;true&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Form Labelling&lt;/h3&gt;
&lt;p&gt;Labels are texts used to describe the purpose of the form control. You should associate form controls with a label implicitly or explicitly. This is exposed to assistive technologies and also makes the clickable area larger when users interact with the form field.&lt;/p&gt;
&lt;h4&gt;Aria-label&lt;/h4&gt;
&lt;p&gt;This adds additional information about a particular field that can only be accessed by assistive technologies. This overrides any other native labeling mechanism, such as a label element.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;date-of-birth&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-label&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;This is for screen readers&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Date of birth&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;select&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;date-of-birth&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;date-of-birth&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-label&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Date of birth&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;option&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;1990&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;1990&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;option&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;option&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;1991&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;1991&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;option&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;option&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;1992&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;1992&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;option&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;option&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;1993&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;1993&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;option&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;option&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;1994&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;1994&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;option&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;select&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Aria-labelledby&lt;/h4&gt;
&lt;p&gt;Aria-labelledby allows you to define an ID on an element which you can reference as the label for another element  or elements.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;emaillabel&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Email Address&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-labelledby&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;emaillabel&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Aria-describedby&lt;/h4&gt;
&lt;p&gt;This references an element ID that has further description for the control.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;toppingslabel&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Which of these toppings do you prefer?&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt;
    &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;radio&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;strawberry&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;strawberry&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;toppings&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token attr-name&quot;&gt;aria-labelledby&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;toppingslabel&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token attr-name&quot;&gt;aria-describedby&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;moreinfo&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;strawberry&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Strawberry&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt;
    &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;radio&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;vanilla&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;vanilla&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;toppings&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token attr-name&quot;&gt;aria-labelledby&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;toppingslabel&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token attr-name&quot;&gt;aria-describedby&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;moreinfo&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;vanilla&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Vanilla&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;moreinfo&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
Provide additional information relevant to the section referencing it
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Aria-owns&lt;/h4&gt;
&lt;p&gt;This attribute is used to tell assistive technology that an element that is separate in the DOM should be treated as a child of the current element.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;menu&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;menuitem&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-haspopup&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;true&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-owns&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;submenu&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    View More
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;menu&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;submenu&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;menuitem&lt;span class=&quot;token punctuation&quot;&gt;&apos;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    Active users
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Having learnt all these, it is time to get to work. &lt;a href=&quot;/building-accessible-web-apps&quot;&gt;Test your site or web apps&lt;/a&gt; and ensure that they are usable. If not, apply the concepts you have learnt to make the web a better place for all. Feel free to &lt;a href=&quot;https://accessibilityresources.org/m-aria/aria-property&quot;&gt;learn more about aria attributes.&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Building Accessible Web Apps]]></title><description><![CDATA[The web plays a central role in our daily lives—it is home to information, services, and opportunities. However, when accessibility is…]]></description><link>https://chiamakaikeanyi.dev/building-accessible-web-apps/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/building-accessible-web-apps/</guid><pubDate>Thu, 09 May 2019 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;The web plays a central role in our daily lives—it is home to information, services, and opportunities. However, when accessibility is overlooked, many of these resources become unusable to a significant portion of users. Accessibility should be an integral part of the design and development process, not an afterthought. An accessible application is, quite simply, a better user experience (UX).&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;“The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”&lt;/em&gt;
— Tim Berners-Lee&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;In this article, we’ll explore the fundamentals of web accessibility, common pitfalls, and practical tips to help you build inclusive and usable web applications.&lt;/p&gt;
&lt;h2&gt;What Is Accessibility?&lt;/h2&gt;
&lt;p&gt;Web accessibility means ensuring that the content and functionality of a website or application can be used by people with a wide range of abilities and impairments. At its core, accessibility is about inclusion—designing and building experiences that work for everyone.&lt;/p&gt;
&lt;p&gt;The term &lt;strong&gt;a11y&lt;/strong&gt; is a common shorthand for &lt;em&gt;accessibility&lt;/em&gt;. It’s a &lt;strong&gt;numeronym&lt;/strong&gt;, meaning there are 11 letters between the “a” and the “y” in the word.&lt;/p&gt;
&lt;p&gt;An accessible web application is one that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Can be navigated using a keyboard or screen reader&lt;/li&gt;
&lt;li&gt;Uses the correct HTML elements for their intended purpose&lt;/li&gt;
&lt;li&gt;Works well across desktop and mobile devices&lt;/li&gt;
&lt;li&gt;Remains usable on slow or unreliable network connections&lt;/li&gt;
&lt;li&gt;Is accessible regardless of geographic location&lt;/li&gt;
&lt;li&gt;Maintains sufficient color contrast for readability&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Why Accessibility Matters&lt;/h2&gt;
&lt;p&gt;Inaccessibility affects people far beyond the web. Consider a building that only has stairs and no ramp or elevator. Individuals using wheelchairs, parents with strollers, or someone temporarily injured are effectively excluded. Buildings designed with accessibility in mind remove these barriers.&lt;/p&gt;
&lt;p&gt;The same principle applies to web applications. Small clickable areas, poor contrast, missing labels, or keyboard traps can make an app frustrating—or impossible—to use for many people.&lt;/p&gt;
&lt;p&gt;Statistics consistently show that a large portion of the population experiences disability at some point in their lives—whether permanently, temporarily, or situationally. Users of your application may experience one or more of the following types of impairments:&lt;/p&gt;
&lt;h2&gt;Types of Impairments&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Motor impairments&lt;/strong&gt;
These involve limited or lost movement or muscle control. Examples include permanent conditions (e.g., limb loss), temporary injuries (e.g., a broken wrist), or situational limitations (e.g., using a device while holding a baby).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Visual impairments&lt;/strong&gt;
This includes blindness, low vision, and color blindness. Users may rely on screen readers, braille displays, magnification tools, or high-contrast modes. Even bright sunlight can create a situational visual impairment.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Hearing impairments&lt;/strong&gt;
Deaf or hard-of-hearing users may miss information conveyed solely through sound. Similarly, users in noisy environments or wearing headphones may not hear audio-only cues.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Cognitive impairments&lt;/strong&gt;
These include conditions such as dyslexia, ADHD, and autism, which can affect memory, concentration, comprehension, and decision-making.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To address these needs, the &lt;strong&gt;Web Content Accessibility Guidelines (WCAG)&lt;/strong&gt; were created.&lt;/p&gt;
&lt;h2&gt;WCAG and the POUR Principles&lt;/h2&gt;
&lt;p&gt;The Web Content Accessibility Guidelines (WCAG) are built around four foundational principles, often summarized as &lt;strong&gt;POUR&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Perceivable&lt;/strong&gt;
Information must be presented in ways users can perceive. Provide text alternatives for non-decorative images, captions for videos, and avoid using color alone to convey meaning.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Operable&lt;/strong&gt;
Users must be able to navigate and interact with the interface using various input methods, including keyboards. Navigation should be predictable and free of traps.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Understandable&lt;/strong&gt;
Content and interactions should be clear and intuitive. Maintain consistent layouts, labels, and behavior throughout the application.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Robust&lt;/strong&gt;
Content should be well-structured and compatible with a wide range of user agents and assistive technologies, both current and future.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Common Accessibility Antipatterns&lt;/h2&gt;
&lt;p&gt;Avoid these frequent mistakes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Using non-semantic elements where semantic HTML is appropriate&lt;/li&gt;
&lt;li&gt;Removing focus styles with &lt;code class=&quot;language-text&quot;&gt;outline: none&lt;/code&gt; without providing a visible alternative&lt;/li&gt;
&lt;li&gt;Assigning &lt;code class=&quot;language-text&quot;&gt;tabindex&lt;/code&gt; values greater than &lt;code class=&quot;language-text&quot;&gt;0&lt;/code&gt;, which disrupt natural tab order&lt;/li&gt;
&lt;li&gt;Using &lt;code class=&quot;language-text&quot;&gt;tabindex&lt;/code&gt; on non-interactive elements unnecessarily&lt;/li&gt;
&lt;li&gt;Low color contrast between text and background&lt;/li&gt;
&lt;li&gt;Icons or images without accessible text alternatives (unless decorative)&lt;/li&gt;
&lt;li&gt;Form inputs without associated &lt;code class=&quot;language-text&quot;&gt;&amp;lt;label&gt;&lt;/code&gt; elements&lt;/li&gt;
&lt;li&gt;Using symbols (e.g. &lt;code class=&quot;language-text&quot;&gt;*&lt;/code&gt;) in forms without explaining their meaning&lt;/li&gt;
&lt;li&gt;Vague link text like “click here” or “read more”.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- anti-pattern --&gt;&lt;/span&gt;
To know more about accessibility, &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;/documentation&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; click here&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- standard --&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;/documentation&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Read the documentation&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; for more information about
accessibility.&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Preventing users from zooming or scaling the page.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- anti-pattern --&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;meta&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;initial-scale=1, width=device-width, height=device-height, maximum-scale=1, minimum-scale=1, user-scalable=no&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- standard --&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;meta&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;initial-scale=1, width=device-width&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Building Accessible Web Applications: Practical Tips&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Follow a logical DOM order and ensure tab order matches it&lt;/li&gt;
&lt;li&gt;Manage focus intentionally when updating content dynamically (e.g., using &lt;code class=&quot;language-text&quot;&gt;tabindex=&quot;-1&quot;&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Provide clear visual affordances for interactive elements—don’t rely on hover alone&lt;/li&gt;
&lt;li&gt;Use proper heading hierarchy (&lt;code class=&quot;language-text&quot;&gt;h1&lt;/code&gt;–&lt;code class=&quot;language-text&quot;&gt;h6&lt;/code&gt;) and &lt;a href=&quot;/writing-standards-compliant-html&quot;&gt;semantic HTML&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Write meaningful &lt;code class=&quot;language-text&quot;&gt;alt&lt;/code&gt; text for images; this also benefits SEO&lt;/li&gt;
&lt;li&gt;Allow users to zoom and scale content freely&lt;/li&gt;
&lt;li&gt;Include a “skip to main content” link for keyboard and screen reader users. This gives them access to the main content without spending much time going through the navigation.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;body&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;#main-content&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;skipToMain&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Skip to main content &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;header&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Header&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;header&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;main&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;main-content&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;footer&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Footer&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;footer&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;body&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.skipToMain&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #bf1722&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #fff&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 14px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;left&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 5px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; absolute&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; -50px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;z-index&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 999&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;-webkit-transition&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; top 1s ease-out&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;transition&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; top 1s ease-out&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;.skipToMain:focus&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Write descriptive, purpose-driven link text&lt;/li&gt;
&lt;li&gt;Avoid relying on the &lt;code class=&quot;language-text&quot;&gt;title&lt;/code&gt; attribute for critical information&lt;/li&gt;
&lt;li&gt;Ensure sufficient color contrast throughout the interface&lt;/li&gt;
&lt;li&gt;Use visually hidden text (&lt;code class=&quot;language-text&quot;&gt;sr-only&lt;/code&gt;) to provide context for assistive technologies&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;sr-only&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Share article on Twitter &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.sr-only&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;border&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;clip&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;rect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;0 0 0 0&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;overflow&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; hidden&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; absolute&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Test regularly with screen readers and keyboard-only navigation&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Auditing a Web Application&lt;/h2&gt;
&lt;p&gt;Accessibility testing should be part of your regular workflow. Screen readers are especially valuable, as they expose how assistive technologies interpret your UI by announcing element roles, names, states, and values.&lt;/p&gt;
&lt;p&gt;Helpful tools include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Screen readers: &lt;a href=&quot;https://www.apple.com/accessibility/mac/vision/&quot;&gt;VoiceOver&lt;/a&gt; (macOS), &lt;a href=&quot;http://www.nvaccess.org/&quot;&gt;NVDA&lt;/a&gt; (Windows), &lt;a href=&quot;https://help.gnome.org/users/orca/stable/&quot;&gt;Orca&lt;/a&gt; (Linux)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://accessibilityinsights.io/&quot;&gt;Accessibility Insights&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://chrome.google.com/webstore/detail/axe/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US&quot;&gt;Axe browser extension&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://chrome.google.com/webstore/detail/chromevox/kgejglhpjiefppelpmljglcjbhoiplfn?hl=en-US&quot;&gt;ChromeVox&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://contrastchecker.com/&quot;&gt;Color contrast checker&lt;/a&gt; and &lt;a href=&quot;https://dequeuniversity.com/rules/axe/3.1/color-contrast?application=lighthouse&quot;&gt;analyzer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://pa11y.org/&quot;&gt;Pa11y&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;NoCoffee (vision simulation)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.tenon.io/&quot;&gt;Tenon&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://wave.webaim.org&quot;&gt;WAVE&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Using Screen readers to Evaluate Web Accessibility&lt;/h3&gt;
&lt;h4&gt;Non Visual Desktop Access (NVDA)&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Quick Keys&lt;/strong&gt;:
H: Headings,
K: Links,
B: Buttons,
L: Lists,
D: Landmarks&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Launch using Insert key (the default key also called NVDA key) or set it to use the Capslock key&lt;/li&gt;
&lt;li&gt;NVDA + N key to activate the NVDA menu&lt;/li&gt;
&lt;li&gt;NVDA + Down arrow key to read everything from your current reading position&lt;/li&gt;
&lt;li&gt;Down arrow key to read the next line&lt;/li&gt;
&lt;li&gt;Up arrow key to read the previous line&lt;/li&gt;
&lt;li&gt;Use the CTRL key to terminate the application&lt;/li&gt;
&lt;li&gt;NVDA + F7 to view all the element list (links, headings and landmarks on a page)&lt;/li&gt;
&lt;li&gt;Arrow keys: To navigate in browse mode&lt;/li&gt;
&lt;li&gt;Tab: Move focus to the next control&lt;/li&gt;
&lt;li&gt;Shift + Tab: Move focus to the previous control&lt;/li&gt;
&lt;li&gt;Spacebar: To focus for control&lt;/li&gt;
&lt;li&gt;ESC: Exit focus mode&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Voice Over&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Command + F5 to activate VoiceOver&lt;/li&gt;
&lt;li&gt;Normal keyboard operation (TAB, Shift+TAB, ESC, arrow keys etc.) work as normal with VoiceOver running&lt;/li&gt;
&lt;li&gt;Command + L to jump to address bar&lt;/li&gt;
&lt;li&gt;Control + Option + Spacebar to activate link, button or other element&lt;/li&gt;
&lt;li&gt;Control + Option + A to start reading the entire web page from the current position. You can pause the reading by pressing the Control key.&lt;/li&gt;
&lt;li&gt;Control + Option + ← ↑ ↓ → to explore content&lt;/li&gt;
&lt;li&gt;Control + Option + Command + H to move forward by heading&lt;/li&gt;
&lt;li&gt;Control + Option + Command + Shift + H to move backward by heading&lt;/li&gt;
&lt;li&gt;Control + Option + W to have a word spelt out&lt;/li&gt;
&lt;li&gt;Control + Option + U to open Web Rotor which helps you quickly jump to different types of content such as headings, links, tables, form controls, and landmarks. Type search term with Web Rotor open to search within Web Rotor. Enter to move VoiceOver focus to an item from Web Rotor&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Building accessible web applications goes far beyond what can be covered in a single article. However, every improvement—no matter how small—helps create a more inclusive web. Accessibility expands your audience, improves usability, and reflects empathy in design.&lt;/p&gt;
&lt;p&gt;To continue learning, explore these resources:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://www.w3.org/&quot;&gt;Web Content Accessibility Guidelines (WCAG)&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://webaim.org/standards/wcag/checklist&quot;&gt;WebAIM WCAG Checklist&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://www.w3.org/WAI/&quot;&gt;W3C Web Accessibility Initiative (WAI)&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://www.w3.org/TR/wai-aria/&quot;&gt;WAI-ARIA Specification&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;WebAIM guides on using &lt;a href=&quot;https://webaim.org/articles/voiceover/&quot;&gt;VoiceOver&lt;/a&gt; and &lt;a href=&quot;https://webaim.org/articles/nvda/&quot;&gt;NVDA&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;An accessible web is an inclusive web. Design with empathy—and leave no one behind.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Sizing in CSS: px vs em vs rem]]></title><description><![CDATA[We have been conversant with using pixels for sizing in CSS, but why use em or rem? When building accessible websites, you need to consider…]]></description><link>https://chiamakaikeanyi.dev/sizing-in-css-px-vs-em-vs-rem/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/sizing-in-css-px-vs-em-vs-rem/</guid><pubDate>Thu, 25 Apr 2019 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;We have been conversant with using pixels for sizing in CSS, but why use &lt;strong&gt;em&lt;/strong&gt; or &lt;strong&gt;rem&lt;/strong&gt;? When building accessible websites, you need to consider inclusion. When you use &lt;strong&gt;px&lt;/strong&gt;, you don&apos;t put user preferences at the forefront.
When the user zooms in or change the browser font setting, websites need to adjust to fit the user&apos;s setting. &lt;code class=&quot;language-text&quot;&gt;px&lt;/code&gt; do not scale but &lt;code class=&quot;language-text&quot;&gt;em&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;rem&lt;/code&gt; scales.&lt;/p&gt;
&lt;p&gt;Sequel to this, setting the font size of the html element in percentage is recommended. Assuming the browser font size is set to 16px (i.e. the default), setting the font size of the html (root) element to 62.5% will default 1rem to 10px.&lt;/p&gt;
&lt;p&gt;You may have used &lt;code class=&quot;language-text&quot;&gt;em&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;rem&lt;/code&gt; CSS units for a while but the difference between the two still appears vague. In this article, I will discuss the difference and when to use a particular unit to avoid building websites with unproportionate sizing.&lt;/p&gt;
&lt;h2&gt;The Difference&lt;/h2&gt;
&lt;p&gt;Pixel (&lt;code class=&quot;language-text&quot;&gt;px&lt;/code&gt;) is a commonly used CSS unit on websites. &lt;code class=&quot;language-text&quot;&gt;px&lt;/code&gt; is not scalable, it is an absolute unit. Change in the value of another element does not affect the value of absolute units. The value assigned is fixed irrespective of the user setting.&lt;/p&gt;
&lt;p&gt;Element (&lt;code class=&quot;language-text&quot;&gt;em&lt;/code&gt;) and Root element (&lt;code class=&quot;language-text&quot;&gt;rem&lt;/code&gt;) are responsive units interpreted into equivalent &lt;code class=&quot;language-text&quot;&gt;px&lt;/code&gt; unit by the browser. They are relative units. Change in the value of the parent or root element affects the value of relative units. They scale with the device. So, what makes the two different? The difference lies in how the values are derived by the browser. To view the computed values, open the Chrome Developer Tools and navigate to the &lt;strong&gt;Computed&lt;/strong&gt; tab.&lt;/p&gt;
&lt;p&gt;The computed pixel value of &lt;code class=&quot;language-text&quot;&gt;em&lt;/code&gt; unit is &lt;strong&gt;relative to the font size of the element being styled&lt;/strong&gt;. This is also affected by inherited values from the parent elements unless it is explicitly overridden by a &lt;code class=&quot;language-text&quot;&gt;px&lt;/code&gt; unit which is not subject to inheritance.&lt;/p&gt;
&lt;p&gt;The computed pixel value of &lt;code class=&quot;language-text&quot;&gt;rem&lt;/code&gt; unit is relative to the &lt;strong&gt;font size of the root (html) element&lt;/strong&gt;. This is however affected by the font size setting on the browser as a result of inheritance unless it is overridden by a &lt;code class=&quot;language-text&quot;&gt;px&lt;/code&gt; unit which is not subject to inheritance.&lt;/p&gt;
&lt;h3&gt;Using em&lt;/h3&gt;
&lt;p&gt;With &lt;code class=&quot;language-text&quot;&gt;em&lt;/code&gt; unit, the computed pixel value is derived from the font size of the styled element while putting the inherited (parent and grandparent) values into consideration. Using &lt;code class=&quot;language-text&quot;&gt;em&lt;/code&gt; unit can turn out to be complex. &lt;code class=&quot;language-text&quot;&gt;em&lt;/code&gt; units should be used to allow for scalability within the context of a specific design element e.g. setting the padding, margin and line-height of menu items to use &lt;code class=&quot;language-text&quot;&gt;em&lt;/code&gt; values works well to properly scale navigation menu items.&lt;/p&gt;
&lt;div class=&quot;note&quot;&gt;
&lt;b&gt;em&lt;/b&gt;:
&lt;p&gt;Unit = Font size of the element being styled x Specified value of the element being styled&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Given a &lt;code class=&quot;language-text&quot;&gt;section&lt;/code&gt; element with a font size of &lt;code class=&quot;language-text&quot;&gt;14px&lt;/code&gt;, when you create a rule, with the padding property set to &lt;code class=&quot;language-text&quot;&gt;3em&lt;/code&gt;, it would evaluate to &lt;code class=&quot;language-text&quot;&gt;42px&lt;/code&gt; (14 x 3 = 42). This is irrespective of the font size assigned to the html element. Simply put, the font size of the element on which em unit is declared determines the pixel unit value.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/* style */&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;html&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 18px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;section&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 14px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 3em&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/* computed style */&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;html&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 18px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;section&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 14px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;padding-bottom&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 42px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;padding-left&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 42px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;padding-right&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 42px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;padding-top&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 42px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Using rem&lt;/h3&gt;
&lt;p&gt;When you use &lt;code class=&quot;language-text&quot;&gt;rem&lt;/code&gt;, the &lt;code class=&quot;language-text&quot;&gt;px&lt;/code&gt; equivalence depends on the font size of the html element.&lt;/p&gt;
&lt;div class=&quot;note&quot;&gt;
&lt;b&gt;rem&lt;/b&gt;:
&lt;p&gt;Unit = Font size of the root html element x Specified value of the element being styled&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Given a web page with its root element assigned a font size of &lt;code class=&quot;language-text&quot;&gt;18px&lt;/code&gt;, and the margin property assigned a value of &lt;code class=&quot;language-text&quot;&gt;2rem&lt;/code&gt;. The computed value for the margin would evaluate to &lt;code class=&quot;language-text&quot;&gt;36px&lt;/code&gt; (18 x 2 = 36).&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/* style */&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;html&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 18px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;margin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 2rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/* computed style */&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;html&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 18px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;margin-bottom&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 36px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;margin-left&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 36px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;margin-right&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 36px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;margin-top&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 36px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;The Effect of Inheritance on em Unit&lt;/h2&gt;
&lt;p&gt;When inheritance is applied to &lt;code class=&quot;language-text&quot;&gt;em&lt;/code&gt; CSS units, the method of calculating the equivalent pixel varies.
With &lt;code class=&quot;language-text&quot;&gt;em&lt;/code&gt;, the child element inherits the value of its parent and up to the grandparent. This alters the supposed pixel value as the inherited value is put into consideration.&lt;/p&gt;
&lt;div class=&quot;note&quot;&gt;
&lt;b&gt;em&lt;/b&gt;:
&lt;p&gt;Unit = Font size of the element being styled x Font size of the parent and grandparent elements (if any) x Specified value of the element being styled&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;section&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;page-wrapper&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  Grandparent
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;container&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    Parent
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;container&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      Child
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;section&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/* style */&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;html&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 16px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;.page-wrapper&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1.5em&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;.container&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 2em&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To calculate the &lt;code class=&quot;language-text&quot;&gt;padding&lt;/code&gt; value of the &lt;code class=&quot;language-text&quot;&gt;.container&lt;/code&gt; class above, inheritance is put into consideration.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/* computed style */&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;html&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 16px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;.page-wrapper&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 24px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;.container&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;padding-bottom&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 48px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;padding-left&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 48px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;padding-right&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 48px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;padding-top&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 48px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The section having &lt;code class=&quot;language-text&quot;&gt;page-wrapper&lt;/code&gt; class inherits the font size of the parent (html) element (16px). It multiplies that value by the font size (1.5em) which computes to 24px (16 x 1.5 = 24px).&lt;/p&gt;
&lt;p&gt;Apparently, the value of the padding specified on the &lt;code class=&quot;language-text&quot;&gt;container&lt;/code&gt; class will inherit from the parent element. Its padding value will now be computed to 48px (24 x 2 = 48).&lt;/p&gt;
&lt;p&gt;If the &lt;code class=&quot;language-text&quot;&gt;container&lt;/code&gt; class specifies a font size in &lt;code class=&quot;language-text&quot;&gt;em&lt;/code&gt; unit, the calculation will be extended further to use that value. e.g If a font size of &lt;code class=&quot;language-text&quot;&gt;1.5em&lt;/code&gt; is specified on the &lt;code class=&quot;language-text&quot;&gt;container&lt;/code&gt; class,&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/* style */&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;html&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 16px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;.page-wrapper&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1.5em&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;.container&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1.5em&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 2em&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;the padding value will be computed as:&lt;/p&gt;
&lt;div class=&quot;note&quot;&gt;
Font size of the grandparent element (html) x Font size of the section (page-wrapper) x Font size of the div (container) x the padding value
&lt;/div&gt;
&lt;p&gt;This will equate to 57.6px (16 x 1.5 x 1.5 x 2 = 72).&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/* style */&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;html&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 16px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;.page-wrapper&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 24px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;.container&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 36px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;padding-bottom&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 72px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;padding-left&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 72px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;padding-right&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 72px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;padding-top&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 72px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To override this inherited value, you need to explicitly set the unit of the element being styled to
&lt;code class=&quot;language-text&quot;&gt;px&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;For instance,&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;section&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;page-wrapper&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  Grandparent
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;container&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    Parent
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;container&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      Child
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;section&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;With style:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;html&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 16px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;.page-wrapper&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 24px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;.container&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1.5em&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Note that the font size value of the &lt;code class=&quot;language-text&quot;&gt;div&lt;/code&gt; with container class above is computed based on its parent element, not the root. The interesting thing here is that the Parent and Child in the HTML above do not have the same font size irrespective of the fact that they share the same class name. The font size of Child is computed based on its parent i.e Parent and the font size of Parent is computed based on its parent i.e Grandparent.&lt;/p&gt;
&lt;p&gt;It is computed as:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;section&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;page-wrapper&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  Grandparent (24px)
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;container&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    Parent (24 x 1.5 = 36px)
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;container&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      Child (36 x 1.5 = 54px)
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;section&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;While using &lt;code class=&quot;language-text&quot;&gt;em&lt;/code&gt;, it is advisable to define the font size on the &lt;code class=&quot;language-text&quot;&gt;html&lt;/code&gt; element instead of declaring it explicitly on other elements.&lt;/p&gt;
&lt;h2&gt;The Effect of Browser Settings&lt;/h2&gt;
&lt;p&gt;The font size set on the browser by the user can affect the value when CSS &lt;code class=&quot;language-text&quot;&gt;rem&lt;/code&gt; unit is used within a web application. This affects &lt;code class=&quot;language-text&quot;&gt;em&lt;/code&gt; units also as a result of inheritance.&lt;/p&gt;
&lt;h3&gt;When no font value is set on html element&lt;/h3&gt;
&lt;p&gt;Given the example below,&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/* style */&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;html&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;box-sizing&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; border-box&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;.page-wrapper&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 2rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;the font size of the element with the class name of &lt;code class=&quot;language-text&quot;&gt;page-wrapper&lt;/code&gt; will depend on the browser settings since no font size is set on the root element. By default, the browser font size is set to &lt;code class=&quot;language-text&quot;&gt;16px&lt;/code&gt; and inherited by the root element. If a user alters the font size of the browser through the settings, the page would be rendered to conform to the settings. Assuming the user sets the default font size to 14px, the computed font size value for &lt;code class=&quot;language-text&quot;&gt;page-wrapper&lt;/code&gt; will equate to 28px (14 x 2 = 28).&lt;/p&gt;
&lt;h3&gt;When em or rem font value is set on html element&lt;/h3&gt;
&lt;p&gt;When an &lt;code class=&quot;language-text&quot;&gt;em&lt;/code&gt; or &lt;code class=&quot;language-text&quot;&gt;rem&lt;/code&gt; font value is set on the html element with a custom browser setting, the computed pixel value will be a multiple of the browser font size setting with the specified font size.&lt;/p&gt;
&lt;p&gt;For instance, if a website&apos;s html element has a font-size property set to 1.5em, and the browser font size set to 14px, the computed pixel value of the root element would be 1.5 x 14 = 21px.&lt;/p&gt;
&lt;h2&gt;The Recommended Setting&lt;/h2&gt;
&lt;p&gt;Setting the font size of the html element in percentage is recommended. This solves the problem.&lt;/p&gt;
&lt;p&gt;Assuming the browser font size is set to 16px (i.e. the default), setting the font size of the root html element to 100% will default 1rem to 16px. This is still not the optimal solution. A better approach will be to use 62.5%. This will equate 1rem to 10px. Starting with this as the base simplifies the calculations.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;box-sizing&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; border-box&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;html&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 62.5%&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;body&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;margin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1.6rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;/* 16px */&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;.page-header&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 3.2rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;/* 32px */&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;For browsers that do not support the usage of rem, you can use SCSS mixin or provide a fallback.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;box-sizing&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; border-box&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;html&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 62.5%&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;body&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;margin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 16px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1.6rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;.page-header&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 32px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 3.2rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Final notes&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Use preprocessors to abstract the calculations using a px to rem converter function&lt;/li&gt;
&lt;li&gt;Use &lt;code class=&quot;language-text&quot;&gt;em&lt;/code&gt; only for sizing that needs to scale based on the font size of an element other than the html (root) element.&lt;/li&gt;
&lt;li&gt;Use &lt;code class=&quot;language-text&quot;&gt;rem&lt;/code&gt; unit for elements that scale depending on a user&apos;s browser font size settings. Use &lt;code class=&quot;language-text&quot;&gt;rem&lt;/code&gt; as the unit for most of your property value.&lt;/li&gt;
&lt;li&gt;For complex layout arrangement, use percentage (%).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You may want to learn more about &lt;a href=&quot;/writing-better-css-in-a-codebase/&quot;&gt;writing better CSS in a codebase&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Finding Unused CSS]]></title><description><![CDATA[Research shows that a higher percentage of users will abandon a site if it takes longer than 3 seconds to load. To retain these users who…]]></description><link>https://chiamakaikeanyi.dev/finding-unused-css/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/finding-unused-css/</guid><pubDate>Thu, 11 Apr 2019 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Research shows that a higher percentage of users will abandon a site if it takes longer than 3 seconds to load. To retain these users who visit your website, it is important to curtail what you ship to them and increase the page load time.&lt;/p&gt;
&lt;p&gt;In this article, I&apos;ll be looking at a way to find unused CSS and get rid of them to improve the website&apos;s performance.&lt;/p&gt;
&lt;h2&gt;Unused CSS. What are You?&lt;/h2&gt;
&lt;p&gt;These are CSS declarations on a website that have no impact when rendering the web page.&lt;/p&gt;
&lt;p&gt;CSS declarations for features no longer being used still existing within the codebase are unused. Frameworks and libraries have more impact as you don&apos;t tend to use all declarations within the framework or library This bloats the page size and impacts performance.&lt;/p&gt;
&lt;p&gt;By default, the browser downloads and parses CSS before the content of a web page can be rendered, The more it has to download and parse, the longer it takes to render the page. The longer it also takes for users to view contents on their screen leaving the users staring at a blank screen. The more they wait, the higher the chance of losing them to a competitor. Therefore, removing unused resources is critical.&lt;/p&gt;
&lt;h2&gt;How to Remove Unused CSS&lt;/h2&gt;
&lt;p&gt;There are lots of tools for removing unused codes such as unusedCSS, unCSS, purifyCSS, purgeCSS etc. But I will focus on using the coverage tab on Chrome DevTools.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Using the Coverage Tab&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The coverage tab on Chrome gives us the ability to find unused CSS and JavaScript codes. When you load a page, it gives you a summary of unused code in relation to the total size of the code. All you need to do is to remove the unused codes and ship only what you need.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;To access the Coverage tab&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Open Chrome DevTools using &lt;kbd&gt;CMD + OPT + J&lt;/kbd&gt; or &lt;kbd&gt;CTRL + SHIFT + I&lt;/kbd&gt;&lt;/li&gt;
&lt;li&gt;Open the Command Menu using &lt;kbd&gt;CMD + SHIFT + P&lt;/kbd&gt; or &lt;kbd&gt;CTRL + SHIFT + P&lt;/kbd&gt;&lt;/li&gt;
&lt;li&gt;Type Coverage and select Show Coverage option.&lt;/li&gt;
&lt;li&gt;Click on record button to capture the coverage&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;To view unused codes&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Navigate to the Sources panel&lt;/li&gt;
&lt;li&gt;Click on a URL in the Coverage panel to view that file in the Sources panel with a breakdown of lines of code executed or not.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The lines of code are colour-coded. Green indicates executed lines of code while red shows the lines of code not executed on a web page.&lt;/p&gt;
&lt;p&gt;Codes not executed on a specific page do not mean that it was not used on the website. You need to check different pages on the website to ascertain that the lines of code weren&apos;t used.&lt;/p&gt;
&lt;p&gt;In conclusion, to reduce the time it takes to render a web page, you need to remove resources not needed and improve performance.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Browser Extensions You Should Have as a Techie]]></title><description><![CDATA[We are in a busy world where different things fight for our attention at the same time.
Opening a new tab may mean that you will never go…]]></description><link>https://chiamakaikeanyi.dev/browser-extensions-you-should-have-as-a-techie/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/browser-extensions-you-should-have-as-a-techie/</guid><pubDate>Thu, 28 Mar 2019 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;We are in a busy world where different things fight for our attention at the same time.
Opening a new tab may mean that you will never go back to the previously opened tab. So, why not utilize each new tab to learn a thing or two.&lt;/p&gt;
&lt;p&gt;In this article, I will highlight the browser extensions I find useful that you as a techie should consider exploring too.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;A browser extension is a small software module for customizing a web browser.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Browser extensions perform various functions such as user interface modifications, ad blocking, grammar check, educating the user, etc. You can leverage on certain browser extensions to learn more and widen your knowledge base.&lt;/p&gt;
&lt;p&gt;Now, let&apos;s discover some browser extensions you need to have as a techie.&lt;/p&gt;
&lt;h3&gt;30 Seconds of Knowledge&lt;/h3&gt;
&lt;p&gt;It has the tagline &quot;Become a better Developer, one New Tab at a time&quot;. This loads a random code snippet each time you open a new tab.
&lt;a href=&quot;https://30secondsofknowledge.com/&quot;&gt;30 Seconds of Knowledge&lt;/a&gt; features 6 Programming Languages and Interview Questions (at the time of writing) that you can read and understand in 30 seconds or less. You can also save snippets which you can access anytime.&lt;/p&gt;
&lt;h3&gt;Accessibility Insights for Web&lt;/h3&gt;
&lt;p&gt;This is basically &lt;a href=&quot;https://accessibilityinsights.io/&quot;&gt;an extension&lt;/a&gt; that helps developers identify common, high-impact accessibility issues in web apps and sites.&lt;/p&gt;
&lt;h3&gt;AdBlock Plus&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://adblockplus.org/&quot;&gt;Adblock Plus&lt;/a&gt; is a free and open source browser extension that blocks ads thereby helping you experience a better and faster web.&lt;/p&gt;
&lt;h3&gt;Altair&lt;/h3&gt;
&lt;p&gt;GraphQL query simplified. &lt;a href=&quot;https://chrome.google.com/webstore/detail/altair-graphql-client/flnheeellpciglgpaodhkhmapeljopja?hl=en&quot;&gt;Altair&lt;/a&gt; ships with a number of useful features including pretty-printing your query, linting your query, showing schema docs, providing autocomplete functionality, the ability to set headers for your request and more. If you work with GraphQL, consider installing this extension.&lt;/p&gt;
&lt;h3&gt;Clear Session&lt;/h3&gt;
&lt;p&gt;Helps you to clear cookies, local storage and session storage from the website you&apos;re currently on with a single click.&lt;/p&gt;
&lt;h3&gt;ColorZilla&lt;/h3&gt;
&lt;p&gt;An extension that assists web developers and graphic designers with color related tasks. It includes Color Picker, Webpage Color Analyzer, Gradient Generator and many more.&lt;/p&gt;
&lt;h3&gt;DailyNow&lt;/h3&gt;
&lt;p&gt;Every day, new and updated software development technologies are being released across the web. &lt;a href=&quot;https://www.dailynow.co/&quot;&gt;DailyNow&lt;/a&gt; curate dev news to help busy developers stay updated. It gives you access to articles on every new tab you open.&lt;/p&gt;
&lt;h3&gt;Full Page Screen Capture&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://chrome.google.com/webstore/detail/full-page-screen-capture/fdpohaocaechififmbbbbbknoalclacl?hl=en&quot;&gt;Full Page Screen Capture&lt;/a&gt; as the name implies captures the full view of a page without hassle.&lt;/p&gt;
&lt;h3&gt;Grammarly&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://www.grammarly.com/&quot;&gt;Grammarly&lt;/a&gt; goes through your messages, documents, and social media posts to ensure that they are mistake-free and impactful. It validates your writings nearly everywhere you write on the web.&lt;/p&gt;
&lt;h3&gt;The Great Suspender&lt;/h3&gt;
&lt;p&gt;This ensures your computer run smoothly by suspending the tabs that have not been viewed after a configurable length of time. It frees up the memory and CPU being consumed by that tab. It also ships with the flexibility to whitelist specific URLs or domains&lt;/p&gt;
&lt;h3&gt;JSON Viewer&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://chrome.google.com/webstore/detail/json-viewer/gbmdgpbipfallnflgajpaliibnhdgobh&quot;&gt;JSON Viewer&lt;/a&gt; is a Chrome extension for rendering JSON and JSONP data in a readable and prettified manner.&lt;/p&gt;
&lt;h3&gt;Muzli&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://muz.li/&quot;&gt;Muzli&lt;/a&gt; delivers design inspiration each time a new tab is opened in your browser. It curates innovative illustrations, design features, unique websites, photography projects, and visual art from design experts across the web to keep you in-the-know and constantly inspired.&lt;/p&gt;
&lt;h3&gt;nBox&lt;/h3&gt;
&lt;p&gt;Sceptical about signing up on certain websites with your email address? nBox generates an email address for each site, for free. This keeps you anonymous and safe on the web.&lt;/p&gt;
&lt;h3&gt;Pocket&lt;/h3&gt;
&lt;p&gt;A better way to save articles, videos and more. When you find something in Chrome that you want to view later, put it in Pocket and easily access it later even without an internet connection.&lt;/p&gt;
&lt;h3&gt;React developer tools&lt;/h3&gt;
&lt;p&gt;An open-source React JavaScript library that allows you to inspect the React component hierarchies and more in the Chrome Developer Tools.&lt;/p&gt;
&lt;h3&gt;Redux DevTools&lt;/h3&gt;
&lt;p&gt;Used for debugging application&apos;s state changes. The &lt;a href=&quot;https://chrome.google.com/webstore/detail/redux-devtools/lmhkpmbekcpmknklioeibfkpmmfibljd?hl=en&quot;&gt;extension&lt;/a&gt; provides power-ups for your Redux development workflow.&lt;/p&gt;
&lt;h3&gt;SimilarWeb&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://chrome.google.com/webstore/detail/similarweb-traffic-rank-w/hoklmmgfnpapgjgcpechhaamimifchmp?hl=en&quot;&gt;SimilarWeb&lt;/a&gt;’s browser add-on gives you in-depth traffic and key metrics for any website.&lt;/p&gt;
&lt;h3&gt;Toby&lt;/h3&gt;
&lt;p&gt;Aims to change the way you save and access tabs. &lt;a href=&quot;http://www.gettoby.com/&quot;&gt;Toby&lt;/a&gt; helps you organize your browser tabs for easy access to them. It helps declutter your web browser.&lt;/p&gt;
&lt;h3&gt;Vue.js devtools&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://chrome.google.com/webstore/detail/vuejs-devtools/nhdogjmejiglipccpnnnanhbledajbpd?hl=en&quot;&gt;Vue.js devtools&lt;/a&gt; is a Chrome and Firefox DevTools extension for debugging Vue.js applications.&lt;/p&gt;
&lt;h3&gt;VisBug&lt;/h3&gt;
&lt;p&gt;Described as a FireBug for designers, &lt;a href=&quot;https://chrome.google.com/webstore/detail/visbug/cdockenadnadldjbbgcallicgledbeoc?hl=en&quot;&gt;Visbug&lt;/a&gt; acts as a debug tool for designers. It enables you to edit or style any page, in any state, like it&apos;s an artboard. It aids the decision-making process on the front end of your site.&lt;/p&gt;
&lt;h3&gt;Wappalyzer&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://www.wappalyzer.com/download&quot;&gt;Wappalyzer&lt;/a&gt; helps you discover what technology a website is built with. It detects content management systems, e-commerce platforms, web frameworks, server software, analytics tools and many more.&lt;/p&gt;
&lt;h3&gt;Wikiwand&lt;/h3&gt;
&lt;p&gt;This gives a new look to Wikipedia. &lt;a href=&quot;http://www.wikiwand.com/&quot;&gt;Wikiwand&lt;/a&gt; optimizes the content for a quicker and significantly improved reading experience.&lt;/p&gt;
&lt;h3&gt;Momentum&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://momentumdash.com/&quot;&gt;Momentum&lt;/a&gt; is not specific to techies. Everyone would find it useful. It aims to eliminate distraction and provide inspiration, focus, and productivity. Momentum displays random photographs and motivational quotes daily on your new tab page. It also helps you set goals for the day and remain focused.&lt;/p&gt;
&lt;p&gt;You don&apos;t have to use all these extensions. Just use the ones that meet your needs and help your friends discover this.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Avoiding Shell Hell: Aliases to the Rescue]]></title><description><![CDATA[I recently gave a talk on "Avoiding Shell Hell: Aliases to the Rescue" at the forloop Lagos Summit. An event organized by forloop Africa in…]]></description><link>https://chiamakaikeanyi.dev/avoiding-shell-hell-aliases-to-the-rescue/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/avoiding-shell-hell-aliases-to-the-rescue/</guid><pubDate>Thu, 14 Mar 2019 07:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I recently gave a talk on &quot;Avoiding Shell Hell: Aliases to the Rescue&quot; at the forloop Lagos Summit. An event organized by forloop Africa in Lagos, Nigeria. It was actually my first conference talk. What a good way to mark International Women&apos;s Day!&lt;/p&gt;
&lt;blockquote class=&quot;twitter-tweet&quot;&gt;&lt;p lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;So, I gave my first conference talk today at &lt;a href=&quot;https://twitter.com/hashtag/forlooplagossummit?src=hash&amp;amp;ref_src=twsrc%5Etfw&quot;&gt;#forlooplagossummit&lt;/a&gt; &lt;a href=&quot;https://twitter.com/hashtag/IWD2019?src=hash&amp;amp;ref_src=twsrc%5Etfw&quot;&gt;#IWD2019&lt;/a&gt;&lt;/p&gt;&amp;mdash; Chiamaka Ikeanyi ♦️ (@chiamakaikeanyi) &lt;a href=&quot;https://twitter.com/chiamakaikeanyi/status/1104016243173003267?ref_src=twsrc%5Etfw&quot;&gt;March 8, 2019&lt;/a&gt;&lt;/blockquote&gt;
&lt;p&gt;I really appreciate Sarah Drasner’s tweet about my talk at the conference.&lt;/p&gt;
&lt;blockquote class=&quot;twitter-tweet&quot;&gt;&lt;p lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;If you don&amp;#39;t already use shell aliases, you should definitely check out this talk by &lt;a href=&quot;https://twitter.com/chiamakaikeanyi?ref_src=twsrc%5Etfw&quot;&gt;@chiamakaikeanyi&lt;/a&gt;- they save time, help keep in you flow state, and well, make you feel just a litttttle bit more like a badass.&lt;a href=&quot;https://t.co/numRY2iTDl&quot;&gt;https://t.co/numRY2iTDl&lt;/a&gt;&lt;/p&gt;&amp;mdash; Sarah Drasner (@sarah_edo) &lt;a href=&quot;https://twitter.com/sarah_edo/status/1105563331224526848?ref_src=twsrc%5Etfw&quot;&gt;March 12, 2019&lt;/a&gt;&lt;/blockquote&gt;
&lt;p&gt;In this article, I will discuss what I talked about for the benefit of those who could not attend the conference:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The issues with bash&lt;/li&gt;
&lt;li&gt;What aliases are&lt;/li&gt;
&lt;li&gt;Why we need to use aliases&lt;/li&gt;
&lt;li&gt;How aliases can be used to improve our terminal productivity.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Shell aliases are a hack to developer productivity. Developers spend a couple of time typing long commands from Git to Docker, Kubernetes etc. when these could be aliased saving the time to achieve more in less time.&lt;/p&gt;
&lt;p&gt;Can you remember the time when you need to open different terminal processes to get the job done? You run a command and discover that there is a typographical error within it. Then, you retype the command or bring the previous command to focus and edit it hoping you don&apos;t make another mistake. I don&apos;t mean to bash on Bash but the experience is terrible. Time is too precious to be spent typing long commands.&lt;/p&gt;
&lt;p&gt;Now, you can use iTerm2, &lt;a href=&quot;/how-to-configure-your-macos-terminal-with-zsh-like-a-pro&quot;&gt;configure it&lt;/a&gt; to use ZSH, and set up aliases in addition to the default aliases that ships with ZSH.&lt;/p&gt;
&lt;h2&gt;Why this setup?&lt;/h2&gt;
&lt;p&gt;iTerm2 provides features like split panes, search using &lt;kbd&gt;CTRL + R&lt;/kbd&gt;, autocomplete, etc. Press &lt;kbd&gt;CTRL + R&lt;/kbd&gt; to search through commands based on what you type. Continue to hit &lt;kbd&gt;CTRL + R&lt;/kbd&gt; to navigate through multiple results.&lt;/p&gt;
&lt;p&gt;ZSH and Oh My Zsh for managing the ZSH configuration is a must have.
It features plugins, history completion - start typing a command and use the up and down arrow keys to navigate through matching history entries etc. This saves you time to get more done.&lt;/p&gt;
&lt;h2&gt;Say Hello to Aliases&lt;/h2&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;gc&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Do you know what it means? Well, it can mean anything - google cloud, gmail compose ... but in this scenario, it is an alias to &lt;code class=&quot;language-text&quot;&gt;git commit&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Wondering what that means? An alias is an alternate name for a command. It is basically a shortcut. Aliases instruct the shell to replace one string with another when executing commands.&lt;/p&gt;
&lt;p&gt;With aliases, you&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;spend less time typing&lt;/li&gt;
&lt;li&gt;reduce the chances of typos in a long command&lt;/li&gt;
&lt;li&gt;speed up your terminal workflow&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Looking at&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;ps&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$image_name&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Is it cool? Of course not! You can actually achieve the same output with&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;dgp &lt;span class=&quot;token variable&quot;&gt;$image_name&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Does it look confusing? It is an alias.&lt;/p&gt;
&lt;h2&gt;Why Aliases&lt;/h2&gt;
&lt;p&gt;Consider a scenario whereby a client requests for a web page and it&apos;s being served at the moment. After a short while, another client requests for the same data and is served a HTTP error 500 page. In order to debug this, you needed to run some commands which are time-consuming. While still debugging, you lose the clients accessing your website thereby losing money that you would have made from them. Using aliases, this could be avoided; the less the commands typed, the faster you get close to the solution of the problem&lt;/p&gt;
&lt;p&gt;Aliases are popularly used in&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Git&lt;/li&gt;
&lt;li&gt;Docker&lt;/li&gt;
&lt;li&gt;Kubernetes etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Having seen the importance of aliases, you may be asking if you should alias every command. Well, not really. You do not need to alias every command. You only need to create aliases for long commands that you use frequently. Lazy software engineers find this helpful but come to think of it, lazy people get more done; they automate tasks. They wouldn&apos;t want to keep typing the same command every time.&lt;/p&gt;
&lt;p&gt;Instead of typing:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;add&lt;/span&gt; &lt;span class=&quot;token builtin class-name&quot;&gt;.&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; commit &lt;span class=&quot;token parameter variable&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Issue-tracking-code: Issue&quot;&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; push origin branch_name&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;they would rather type:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;gac &lt;span class=&quot;token string&quot;&gt;&quot;Issue-tracking-code: Issue&quot;&lt;/span&gt;
gpo branch_name&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;or something less and use the remaining time they have to relax. Now, consider the time you save every time you use &lt;code class=&quot;language-text&quot;&gt;dgp&lt;/code&gt; instead of &lt;code class=&quot;language-text&quot;&gt;docker ps | grep&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Syntax&lt;/h2&gt;
&lt;p&gt;To create an alias, use the format&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;alias&lt;/span&gt; name &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token builtin class-name&quot;&gt;command&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If there is a space(s) in the command, use&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;alias&lt;/span&gt; name &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;command with space&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If you have variable in the command, use the syntax&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;alias&lt;/span&gt; &lt;span class=&quot;token assign-left variable&quot;&gt;nis&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;f() { npm install --save &quot;$@&quot; };f&apos;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;where f can be anything.&lt;/p&gt;
&lt;p&gt;For commands containing variables, using double quotes, the variable is resolved at definition time, but with single quotes, it is resolved at invocation time.&lt;/p&gt;
&lt;p&gt;You can create aliases for a particular session within the terminal. But once the session is ended, it becomes unavailable. To create permanent aliases, store them within a dotfile in the home directory.&lt;/p&gt;
&lt;p&gt;The default files are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Bourne-again shell (BASH): ~/.bashrc and ~/.bash_profile&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Z Shell (ZSH): ~/.zshrc&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These are not the only shells in existence. There are other types e.g. Powershell, Friendly Interactive Shell (FISH) etc. But I&apos;ll be focusing on BASH and ZSH.&lt;/p&gt;
&lt;p&gt;To ascertain the file within your home directory, switch to that directory and list all the files it contains including the hidden files.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token environment constant&quot;&gt;$SHELL&lt;/span&gt;   &lt;span class=&quot;token comment&quot;&gt;# ascertain the location of the shell&lt;/span&gt;
CD ~          &lt;span class=&quot;token comment&quot;&gt;# switch to the home directory&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-la&lt;/span&gt;        &lt;span class=&quot;token comment&quot;&gt;# show all files within the directory including the hidden files&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;touch&lt;/span&gt; ~/.bash_profile   &lt;span class=&quot;token comment&quot;&gt;# create a .bash_profile file if it doesn&apos;t exist&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can use any name for the dotfile.&lt;/p&gt;
&lt;p&gt;To configure your project directory to use Git, instead of typing the long command used for setting Git up, you can create aliases for different workspaces. Then, whenever you need to configure a directory to use Git, run the command using the alias.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;alias&lt;/span&gt; &lt;span class=&quot;token assign-left variable&quot;&gt;workspace&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;git config user.name &apos;your_name&apos;
&amp;amp;&amp;amp; git config user.email &apos;your_email&apos;&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;For instance, if you have set the global Git configuration on your computer to use your personal details, and you quickly need to resolve an issue from home, all you need to do is to clone the repository, navigate to the directory, and run the alias e.g. &lt;strong&gt;workspace&lt;/strong&gt;. This configures the directory.&lt;/p&gt;
&lt;p&gt;To launch my blog on my default browser, I type &lt;strong&gt;blog&lt;/strong&gt; within the terminal, an alias I had to set up within the ~/.zshrc file.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;alias&lt;/span&gt; &lt;span class=&quot;token assign-left variable&quot;&gt;blog&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;open https://chiamakaikeanyi.dev&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can set up as many aliases as you need.
Press &lt;kbd&gt;CTRL + X&lt;/kbd&gt; to save. When it asks you to confirm, enter Y and press &lt;kbd&gt;ENTER&lt;/kbd&gt;. Afterwards, reload the file for the changes to take effect.&lt;/p&gt;
&lt;p&gt;To reload, run&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;source&lt;/span&gt; ~/.zshrc

or

&lt;span class=&quot;token builtin class-name&quot;&gt;.&lt;/span&gt; ~/.zshrc&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;span class=&quot;note&quot;&gt;
Substitute ~/.zshrc with ~/.bashrc or ~/.bash_profile depending on the file you are making use of.
&lt;/span&gt;
&lt;h2&gt;Accessing your Aliases&lt;/h2&gt;
&lt;p&gt;Aliases can be accessed using different methods.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;nano&lt;/span&gt; ~/.zshrc
&lt;span class=&quot;token function&quot;&gt;vim&lt;/span&gt; ~/.zshrc
&lt;span class=&quot;token function&quot;&gt;cat&lt;/span&gt; ~/.zshrc
&lt;span class=&quot;token function&quot;&gt;open&lt;/span&gt; ~/.zshrc
code ~/.zshrc
&lt;span class=&quot;token builtin class-name&quot;&gt;alias&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Use any method that works for you.&lt;/p&gt;
&lt;p&gt;Note that if you cannot access files using VS Code &lt;code class=&quot;language-text&quot;&gt;code&lt;/code&gt; command, you need to install it. Launch VS Code, press &lt;kbd&gt;CMD + SHIFT + P&lt;/kbd&gt;, type &lt;strong&gt;shell command&lt;/strong&gt; and select &lt;strong&gt;Install code command in path&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;To be more productive, you can set up a script to create an alias for the last command used before it was invoked.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token shebang important&quot;&gt;#!/bin/sh&lt;/span&gt;

&lt;span class=&quot;token function-name function&quot;&gt;addAlias&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token assign-left variable&quot;&gt;last_command&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; `history &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;tail&lt;/span&gt; -n1` &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;s/[0-9]* //&apos;&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token builtin class-name&quot;&gt;alias&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$1&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&apos;&quot;&lt;/span&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$last_command&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&apos;&quot; &lt;span class=&quot;token operator&quot;&gt;&gt;&gt;&lt;/span&gt; ~/.bash_profile
  &lt;span class=&quot;token builtin class-name&quot;&gt;.&lt;/span&gt; ~/.bash_profile
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This evaluates the piped (`) command i.e. fetching the last command from the history, reads the result using the stream editor, and assign it to last_command variable.&lt;/p&gt;
&lt;p&gt;Then, create an alias using the argument passed to it as the alias and the result of the evaluation as the command assigned to it. Then, save the alias within the specified file (in this case &lt;code class=&quot;language-text&quot;&gt;~/.bash_profile&lt;/code&gt;).
Afterwards, it reloads the file.&lt;/p&gt;
&lt;p&gt;For any command you do not understand its function, run &lt;code class=&quot;language-text&quot;&gt;man keyword&lt;/code&gt; within the terminal to view the manual e.g. &lt;code class=&quot;language-text&quot;&gt;man sed&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Setting up Aliases on Windows&lt;/h2&gt;
&lt;p&gt;Setting up aliases on Windows is a bit different. You need to follow the steps below.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create a &lt;code class=&quot;language-text&quot;&gt;.bat&lt;/code&gt; or &lt;code class=&quot;language-text&quot;&gt;.cmd&lt;/code&gt; file within the root directory e.g. C:\Users\UserName&lt;/li&gt;
&lt;li&gt;Run regedit to edit the registry&lt;/li&gt;
&lt;li&gt;Navigate to HKEY_CURRENT_USER\Software\Microsoft\Command Processor&lt;/li&gt;
&lt;li&gt;Add a string value entry with the name &lt;code class=&quot;language-text&quot;&gt;AutoRun&lt;/code&gt; and the absolute path to the &lt;code class=&quot;language-text&quot;&gt;.bat&lt;/code&gt; file as the value (e.g. C:\Users\UserName\alias.bat). This loads the file each time cmd is run.&lt;/li&gt;
&lt;li&gt;Open the batch file and add aliases.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span class=&quot;note&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;@echo off&lt;/code&gt; should be added as the first line within the .bat or .cmd file to prevent it from executing the command once cmd is run.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;To create an alias, use the format&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;DOSKEY &lt;span class=&quot;token assign-left variable&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;command&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Sample alias file on windows&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;@echo off

DOSKEY &lt;span class=&quot;token assign-left variable&quot;&gt;dfs&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;docker &lt;span class=&quot;token function&quot;&gt;ps&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; findstr &lt;span class=&quot;token variable&quot;&gt;$image_name&lt;/span&gt;
DOSKEY &lt;span class=&quot;token assign-left variable&quot;&gt;ga&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;git &lt;span class=&quot;token function&quot;&gt;add&lt;/span&gt; &lt;span class=&quot;token builtin class-name&quot;&gt;.&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In the end, what matters is becoming more productive.&lt;/p&gt;
&lt;p&gt;You can have a look at &lt;a href=&quot;https://speakerdeck.com/chiamakaikeanyi/avoiding-shell-hell-aliases-to-the-rescue&quot;&gt;my slides&lt;/a&gt; and &lt;a href=&quot;https://github.com/chiamakaikeanyi/dotfiles&quot;&gt;my dotfile&lt;/a&gt; to guide you in creating yours or possibly just reuse it.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[CSS Specificity]]></title><description><![CDATA[Most times, CSS seems difficult to work with. You find out that styles you applied to a particular element don't take effect and you keep…]]></description><link>https://chiamakaikeanyi.dev/css-specificity/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/css-specificity/</guid><pubDate>Thu, 28 Feb 2019 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Most times, CSS seems difficult to work with. You find out that styles you applied to a particular element don&apos;t take effect and you keep wondering why. This is as a result of CSS specificity.&lt;/p&gt;
&lt;p&gt;Specificity is the means the web browser uses to determine the set of rules applied to a specific selector having two or more conflicting rules. The more weight a selector has, the higher the chance it stands to be applied.&lt;/p&gt;
&lt;p&gt;In this article, I will explain what CSS specificity entails to help you make better decisions when styling web pages and avoid spaghetti code.&lt;/p&gt;
&lt;h3&gt;Hierarchy&lt;/h3&gt;
&lt;p&gt;Selectors have &lt;a href=&quot;https://www.w3.org/TR/CSS21/selector.html&quot;&gt;an order&lt;/a&gt; in which they have been placed in the specificity hierarchy which affects which one is considered a priority.&lt;/p&gt;
&lt;p&gt;For single selectors from highest to lowest:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Inline styles (&lt;code class=&quot;language-text&quot;&gt;&amp;lt;nav style=&quot;color: #fff;&quot;&gt;&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;IDs (&lt;code class=&quot;language-text&quot;&gt;#myId&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Classes (&lt;code class=&quot;language-text&quot;&gt;.myclass&lt;/code&gt;), attributes (&lt;code class=&quot;language-text&quot;&gt;[type=&quot;checkbox&quot;]&lt;/code&gt;) and pseudo-classes (&lt;code class=&quot;language-text&quot;&gt;:hover&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Elements (&lt;code class=&quot;language-text&quot;&gt;ul&lt;/code&gt;) and pseudo-elements (&lt;code class=&quot;language-text&quot;&gt;::before&lt;/code&gt;)&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Rules of thumb&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;By default, inline CSS is considered first before internal or external stylesheets.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;!important&lt;/code&gt; takes precedence over all declared styles.&lt;/li&gt;
&lt;li&gt;Only use &lt;code class=&quot;language-text&quot;&gt;!important&lt;/code&gt; on page-specific CSS that overrides CSS from external libraries, e.g. Bootstrap, normalize.css etc.&lt;/li&gt;
&lt;li&gt;To override &lt;code class=&quot;language-text&quot;&gt;!important&lt;/code&gt; that you have control over, rewrite the original rule to avoid the use of &lt;code class=&quot;language-text&quot;&gt;!important&lt;/code&gt;. For scenarios where the previous declaration has a high specificity, give the selector a high specificity in your later declaration or the same specificity making the later take priority over the former.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;[id=&quot;someElement&quot;] p&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; blue&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;p.error&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; red&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The styles above have the same specificity&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A more specific selector takes precedence over a less specific one&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;    &lt;span class=&quot;token selector&quot;&gt;nav&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 10px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;token selector&quot;&gt;// The rule below has higher specificity
    nav#main&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 15px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Due to a cascading effect, rules that appear later in the code override earlier rules if both have the same specificity.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;    &lt;span class=&quot;token selector&quot;&gt;nav&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 10px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;token selector&quot;&gt;nav&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 15px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Universal selector (*), combinators (+, &gt;, ~,), inherited values and negation pseudo-class (:not()) have no effect on specificity.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Styles targeted directly to an element will always take precedence over inherited styles, regardless of the specificity of the inherited rule.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;html&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;body&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;parent&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;h1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Title&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;h1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;body&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;html&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;having the style below:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;  &lt;span class=&quot;token selector&quot;&gt;#parent&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; blue&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token selector&quot;&gt;h1&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; purple&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;will have purple applied to it.&lt;/p&gt;
&lt;h3&gt;Calculating Specificity&lt;/h3&gt;
&lt;p&gt;A formula guides how CSS specificity is calculated. The selector with the most specific value is applied.&lt;/p&gt;
&lt;span class=&quot;note&quot;&gt;
For each given selector, add 1 to the column it appears within the specificity table and sum up the value afterwards to derive the specificity of the selector.
&lt;/span&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th align=&quot;center&quot;&gt;S&lt;/th&gt;
&lt;th align=&quot;center&quot;&gt;I&lt;/th&gt;
&lt;th align=&quot;center&quot;&gt;C&lt;/th&gt;
&lt;th align=&quot;center&quot;&gt;E&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td align=&quot;center&quot;&gt;0&lt;/td&gt;
&lt;td align=&quot;center&quot;&gt;0&lt;/td&gt;
&lt;td align=&quot;center&quot;&gt;0&lt;/td&gt;
&lt;td align=&quot;center&quot;&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;strong&gt;Legend:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;[&lt;strong&gt;S&lt;/strong&gt;]: Inline styles&lt;/p&gt;
&lt;p&gt;[&lt;strong&gt;I&lt;/strong&gt;]: ID selectors&lt;/p&gt;
&lt;p&gt;[&lt;strong&gt;C&lt;/strong&gt;]: Classes, attributes and pseudo-classes&lt;/p&gt;
&lt;p&gt;[&lt;strong&gt;E&lt;/strong&gt;]: Elements and pseudo-elements&lt;/p&gt;
&lt;p&gt;Start at 0,&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;1000 for style attribute,&lt;/li&gt;
&lt;li&gt;0100 for each ID,&lt;/li&gt;
&lt;li&gt;0010 for each attribute, class or pseudo-class,&lt;/li&gt;
&lt;li&gt;0001 for each element name or pseudo-element.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Use Cases&lt;/h3&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;section #content .data a:hover&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;...&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Using the formula,&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th align=&quot;center&quot;&gt;S&lt;/th&gt;
&lt;th align=&quot;center&quot;&gt;I&lt;/th&gt;
&lt;th align=&quot;center&quot;&gt;C&lt;/th&gt;
&lt;th align=&quot;center&quot;&gt;E&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td align=&quot;center&quot;&gt;0&lt;/td&gt;
&lt;td align=&quot;center&quot;&gt;1&lt;/td&gt;
&lt;td align=&quot;center&quot;&gt;2&lt;/td&gt;
&lt;td align=&quot;center&quot;&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th align=&quot;center&quot;&gt;specificity  = 0 1 2 2&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;/table&gt;
&lt;p&gt;Given an unordered list of two items having conflicting rules,&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ul&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;list&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;item&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;1&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;item&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;2&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;  &lt;span class=&quot;token selector&quot;&gt;.item&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #e90b8d&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token selector&quot;&gt;ul &gt; li&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #fff&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To determine the more specific selector, calculate the specificity of each selector.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Selector 1 has one class&lt;/strong&gt;:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;  &lt;span class=&quot;token selector&quot;&gt;.item&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #e90b8d&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th align=&quot;center&quot;&gt;S&lt;/th&gt;
&lt;th align=&quot;center&quot;&gt;I&lt;/th&gt;
&lt;th align=&quot;center&quot;&gt;C&lt;/th&gt;
&lt;th align=&quot;center&quot;&gt;E&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td align=&quot;center&quot;&gt;0&lt;/td&gt;
&lt;td align=&quot;center&quot;&gt;0&lt;/td&gt;
&lt;td align=&quot;center&quot;&gt;1&lt;/td&gt;
&lt;td align=&quot;center&quot;&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th align=&quot;center&quot;&gt;specificity = 0 0 1 0&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;/table&gt;
&lt;p&gt;&lt;strong&gt;Selector 2 has two elements&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;  &lt;span class=&quot;token selector&quot;&gt;ul &gt; li&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #fff&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th align=&quot;center&quot;&gt;S&lt;/th&gt;
&lt;th align=&quot;center&quot;&gt;I&lt;/th&gt;
&lt;th align=&quot;center&quot;&gt;C&lt;/th&gt;
&lt;th align=&quot;center&quot;&gt;E&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td align=&quot;center&quot;&gt;0&lt;/td&gt;
&lt;td align=&quot;center&quot;&gt;0&lt;/td&gt;
&lt;td align=&quot;center&quot;&gt;0&lt;/td&gt;
&lt;td align=&quot;center&quot;&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th align=&quot;center&quot;&gt;specificity = 0 0 0 2&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;/table&gt;
&lt;p&gt;&lt;strong&gt;Result&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;From the above calculation, you can see that selector 1 has a higher specificity (10) than selector 2 with a value of 2. Therefore, the list items will be pink in color (#e90b8d).&lt;/p&gt;
&lt;p&gt;Check out &lt;a href=&quot;http://cssspecificity.com/&quot;&gt;the visual representation of CSS specificity&lt;/a&gt; for more information.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[VS Code Setup to Improve Productivity]]></title><description><![CDATA[Code editors have evolved over the years. A few years ago, there was no Visual Studio Code (VS Code). You were probably using Sublime Text…]]></description><link>https://chiamakaikeanyi.dev/vscode-setup-to-improve-productivity/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/vscode-setup-to-improve-productivity/</guid><pubDate>Thu, 14 Feb 2019 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Code editors have evolved over the years. A few years ago, there was no Visual Studio Code (VS Code). You were probably using Sublime Text, Atom, Bracket, etc. But with the release of VS Code, it has become the favourite code editor of most software developers.&lt;/p&gt;
&lt;h2&gt;Why VS Code?&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Customizable&lt;/li&gt;
&lt;li&gt;Easy Debugging&lt;/li&gt;
&lt;li&gt;Emmet&lt;/li&gt;
&lt;li&gt;Extensions&lt;/li&gt;
&lt;li&gt;Git Integration&lt;/li&gt;
&lt;li&gt;Integrated terminal&lt;/li&gt;
&lt;li&gt;Intellisense&lt;/li&gt;
&lt;li&gt;Theming and more...&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Having seen the advantages of using VS Code, this article will cover VS Code setup and extensions needed when using VS Code from the lens of productivity.&lt;/p&gt;
&lt;h2&gt;Emmet&lt;/h2&gt;
&lt;p&gt;Used in many popular text editors, this greatly improves HTML &amp;#x26; CSS workflow.
To access this, press &lt;kbd&gt;CMD + SHIFT + P&lt;/kbd&gt;. Then, search for &lt;strong&gt;emmet&lt;/strong&gt;. This shows a list of actions that can be performed using emmet.&lt;/p&gt;
&lt;p&gt;For instance, to display five &lt;code class=&quot;language-text&quot;&gt;divs&lt;/code&gt; with the class name &lt;code class=&quot;language-text&quot;&gt;item&lt;/code&gt;, all you need is&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;.item{$}*5&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then, press the &lt;kbd&gt;Enter&lt;/kbd&gt; key. The result is&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;item&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;1&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;item&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;2&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;item&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;3&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;item&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;4&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;item&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;5&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;CSS use case:&lt;/p&gt;
&lt;p&gt;Within any CSS selector, type&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;p20&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then, press the &lt;kbd&gt;Tab&lt;/kbd&gt; key. The result is&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 20px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Emmet requires a little configuration to work with frameworks such as React etc. Navigate to VSCode settings.json file and add:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;json&quot;&gt;&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token property&quot;&gt;&quot;emmet.includeLanguages&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;javascript&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;javascriptreact&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;vue-html&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;html&quot;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then, you can type &lt;code class=&quot;language-text&quot;&gt;div.page-wrapper&lt;/code&gt; and press the &lt;kbd&gt;Enter&lt;/kbd&gt; key. This will result to&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;page-wrapper&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Font&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/tonsky/FiraCode&quot;&gt;Fira Code&lt;/a&gt; looks cool as a result of the support for ligatures. It makes your code readable at a glance. Download and install Fira Code, then add it to your settings.json file.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;json&quot;&gt;&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token property&quot;&gt;&quot;editor.fontFamily&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Fira Code&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token property&quot;&gt;&quot;editor.fontLigatures&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Launching from the command line&lt;/h2&gt;
&lt;p&gt;Launching VS Code from the terminal looks cool. To do this, press &lt;kbd&gt;CMD + SHIFT + P&lt;/kbd&gt;, type &lt;strong&gt;shell command&lt;/strong&gt; and select &lt;strong&gt;Install code command in path&lt;/strong&gt;.
Afterwards, navigate to any project from the terminal and type &lt;strong&gt;&lt;code class=&quot;language-text&quot;&gt;code .&lt;/code&gt;&lt;/strong&gt; from the directory to launch the project using VS Code.&lt;/p&gt;
&lt;h2&gt;Multiple Cursors&lt;/h2&gt;
&lt;p&gt;You can modify multiple lines of code at the same time. To achieve this, you need to set your preferred access &lt;kbd&gt;KEY&lt;/kbd&gt; within your settings.json file.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;json&quot;&gt;&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token property&quot;&gt;&quot;editor.multiCursorModifier&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;ctrlCmd&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;

or

&lt;span class=&quot;token property&quot;&gt;&quot;editor.multiCursorModifier&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;alt&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;After setting this, press down the key set within your settings.json file, and you will be able to select multiple lines of code at the same time. This speeds up the code refactoring process.&lt;/p&gt;
&lt;h2&gt;Terminal&lt;/h2&gt;
&lt;p&gt;Bored of the default terminal shipped with your macOS? You can &lt;a href=&quot;/how-to-configure-your-macos-terminal-with-zsh-like-a-pro&quot;&gt;set up your terminal to use iTerm2 and ZSh&lt;/a&gt; and have your VS Code terminal setup to use that.&lt;/p&gt;
&lt;p&gt;After configuring Zsh, launch the VS Code integrated terminal &lt;code class=&quot;language-text&quot;&gt;Terminal &gt; New Terminal&lt;/code&gt; and run the command&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;source&lt;/span&gt; ~/.zshrc&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;or&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;.&lt;/span&gt; ~/.zshrc&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;to execute the content of the .zshrc configuration file in the shell.&lt;/p&gt;
&lt;h2&gt;Hacks&lt;/h2&gt;
&lt;h3&gt;Automatic sub-folder creation&lt;/h3&gt;
&lt;p&gt;You can easily create a sub-folder from an already existing file.
To do this, select a file and click on rename. Then, add a backslash (/) at the point you need it to be demarcated from.&lt;/p&gt;
&lt;p&gt;E.g. To create a bio sub-folder from &lt;code class=&quot;language-text&quot;&gt;authorbio.js&lt;/code&gt;, type &lt;code class=&quot;language-text&quot;&gt;author/bio.js&lt;/code&gt;&lt;/p&gt;
&lt;h3&gt;Logging to the console&lt;/h3&gt;
&lt;p&gt;To easily log to the console, type clg and press the &lt;kbd&gt;tab&lt;/kbd&gt; key or type log and press the &lt;kbd&gt;enter&lt;/kbd&gt; key&lt;/p&gt;
&lt;h2&gt;Extensions&lt;/h2&gt;
&lt;p&gt;Extensions improve developer experience when working on a codebase. You can explore available options in the marketplace.&lt;/p&gt;
&lt;p&gt;To access these extensions,&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Go to View &gt; Extensions&lt;/li&gt;
&lt;li&gt;Search for extensions in the marketplace&lt;/li&gt;
&lt;li&gt;Click on Install&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Below are extensions that I find useful and what they do.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Add jsdoc comments&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This adds comments block to the code. To use it, highlight the first line of the function, press &lt;kbd&gt;CMD + SHIFT + P&lt;/kbd&gt; and select &lt;em&gt;Add Doc Comments&lt;/em&gt;&lt;/p&gt;
&lt;ol start=&quot;2&quot;&gt;
&lt;li&gt;&lt;strong&gt;Auto Rename tag&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Automatically renames paired elements.&lt;/p&gt;
&lt;ol start=&quot;3&quot;&gt;
&lt;li&gt;&lt;strong&gt;Babel JavaScript&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;JavaScript syntax highlighting for ES201x, React JSX, Flow and GraphQL.&lt;/p&gt;
&lt;ol start=&quot;4&quot;&gt;
&lt;li&gt;&lt;strong&gt;CSS Peek&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;As the name implies, this helps you peek on rules applied by a defined style within a codebase and it&apos;s &lt;a href=&quot;/css-specificity&quot;&gt;specificity&lt;/a&gt;. It comes in handy when working on legacy codebases.&lt;/p&gt;
&lt;ol start=&quot;5&quot;&gt;
&lt;li&gt;&lt;strong&gt;Debugger for Chrome&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This lets you debug your JavaScript code running on your Google Chrome browser
right from VS Code.&lt;/p&gt;
&lt;ol start=&quot;6&quot;&gt;
&lt;li&gt;&lt;strong&gt;Docker&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You can create Dockerfiles on the fly with this extension. It also provides syntax highlighting, intellisense and much more.&lt;/p&gt;
&lt;p&gt;Press &lt;kbd&gt;CMD + SHIFT + P&lt;/kbd&gt; and search for &lt;em&gt;Add Docker files to workspace&lt;/em&gt;&lt;/p&gt;
&lt;ol start=&quot;7&quot;&gt;
&lt;li&gt;&lt;strong&gt;DotENV&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Adds syntax highlighting to .env files.&lt;/p&gt;
&lt;ol start=&quot;8&quot;&gt;
&lt;li&gt;&lt;strong&gt;ES7 React/Redux/GraphQL/React-Native snippets&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This provides JavaScript and React/Redux snippets in ES7 with Babel plugin features. &lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=dsznajder.es7-react-js-snippets&quot;&gt;Read the comprehensive usage guide&lt;/a&gt;.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th align=&quot;left&quot;&gt;Prefix&lt;/th&gt;
&lt;th align=&quot;left&quot;&gt;Method&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td align=&quot;left&quot;&gt;imd→&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;import { destructuredModule } from &apos;module&apos;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align=&quot;left&quot;&gt;fof→&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;for(let itemName of objectName { }&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align=&quot;left&quot;&gt;imrc→&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;import React, { Component } from &apos;react&apos;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align=&quot;left&quot;&gt;rafcp→&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;Creates a react arrow functional component with PropTypes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Legend:&lt;/p&gt;
&lt;p&gt;→ : &lt;kbd&gt;Tab&lt;/kbd&gt; key&lt;/p&gt;
&lt;ol start=&quot;9&quot;&gt;
&lt;li&gt;&lt;strong&gt;ESDoc MDN&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In certain scenarios, we tend to forget how a particular thing works. This is where this extension becomes useful. You don&apos;t need to launch your web browser to find out the syntax. All you need is to type&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;//mdn object.method;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Copy the snippet below and paste on your VS Code to get a grasp of how it works.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;//mdn array.filter;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ol start=&quot;10&quot;&gt;
&lt;li&gt;&lt;strong&gt;ESLint&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This integrates ESLint into VS Code to lint your codes. You need to have ESLint installed either locally or globally to take advantage of the features this extension offers.&lt;/p&gt;
&lt;p&gt;To install ESLint locally, run &lt;code class=&quot;language-text&quot;&gt;npm install eslint&lt;/code&gt; or globally using
&lt;code class=&quot;language-text&quot;&gt;npm install -g eslint&lt;/code&gt;.
You would also need to create &lt;code class=&quot;language-text&quot;&gt;.eslintrc&lt;/code&gt; configuration file.&lt;/p&gt;
&lt;p&gt;If you installed ESLint locally, run
&lt;code class=&quot;language-text&quot;&gt;./node_modules/.bin/eslint --init&lt;/code&gt;
or &lt;code class=&quot;language-text&quot;&gt;eslint --init&lt;/code&gt;
for global installation.&lt;/p&gt;
&lt;ol start=&quot;11&quot;&gt;
&lt;li&gt;&lt;strong&gt;GitLens&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;GitLens boosts what you can achieve with Git. It helps you to do a lot more such as seamlessly exploring Git repositories, peeking into code revisions, authorship and much more.&lt;/p&gt;
&lt;ol start=&quot;12&quot;&gt;
&lt;li&gt;&lt;strong&gt;Google Fonts&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Adding Google fonts just got easier with this extension. You no longer need to search for fonts on the browser. To access a list of fonts, press &lt;kbd&gt;CMD + SHIFT + P&lt;/kbd&gt; and search for &lt;strong&gt;Google fonts&lt;/strong&gt; to proceed.&lt;/p&gt;
&lt;ol start=&quot;13&quot;&gt;
&lt;li&gt;&lt;strong&gt;Highlight Matching Tag&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=vincaslt.highlight-matching-tag&quot;&gt;This extension&lt;/a&gt; highlights matching opening and closing tags while also providing extensive styling options to customize how tags are highlighted.&lt;/p&gt;
&lt;ol start=&quot;14&quot;&gt;
&lt;li&gt;&lt;strong&gt;HTMLHint&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This extension validates your HTML helping you to write &lt;a href=&quot;/writing-standards-compliant-html&quot;&gt;standards-compliant code&lt;/a&gt;&lt;/p&gt;
&lt;ol start=&quot;15&quot;&gt;
&lt;li&gt;&lt;strong&gt;Image Preview&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=kisstkondoros.vscode-gutter-preview&quot;&gt;Image Preview&lt;/a&gt; shows the image preview in the gutter and on hover. This is essential as it helps you ensure that you are importing the right image at a glance.&lt;/p&gt;
&lt;ol start=&quot;16&quot;&gt;
&lt;li&gt;&lt;strong&gt;Import Cost&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Import Cost shows the impact of imported packages within the codebase. It helps measure performance bottlenecks.&lt;/p&gt;
&lt;ol start=&quot;17&quot;&gt;
&lt;li&gt;&lt;strong&gt;Kubernetes&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The extension helps developers building applications to run in Kubernetes clusters and for DevOps staff troubleshooting Kubernetes applications. It enables you view your clusters in an explorer tree view, and drill into workloads, services, pods and nodes. Works with any Kubernetes anywhere (Azure, Minikube, AWS, GCP and more)&lt;/p&gt;
&lt;ol start=&quot;18&quot;&gt;
&lt;li&gt;&lt;strong&gt;Live Server&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This launches a local development server with live reload feature.&lt;/p&gt;
&lt;ol start=&quot;19&quot;&gt;
&lt;li&gt;&lt;strong&gt;Peacock&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This extension gives you the ability to change the workspace color of your workspace. It is ideal when you have multiple VS Code instances and you want to quickly identify a particular instance.&lt;/p&gt;
&lt;p&gt;After installing Peacock, click on the settings icon &gt; settings,
select workspace settings tab, click on {} and paste the code below.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;json&quot;&gt;&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;workbench.colorCustomizations&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;activityBar.background&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;#734E73&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;activityBar.foreground&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;#fff&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;activityBar.inactiveForeground&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;#b5b5b5&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;peacock.affectedElements&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;activityBar&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can also add &lt;code class=&quot;language-text&quot;&gt;titleBar&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;statusBar&lt;/code&gt; to the affectedElements and add color customizations for them within the colorCustomizations section.&lt;/p&gt;
&lt;p&gt;To use one of the default colors, press &lt;kbd&gt;CMD + SHIFT + P&lt;/kbd&gt;, type &lt;strong&gt;peacock&lt;/strong&gt; and select your preferred theme. This overrides the color settings within the settings.json file defined for that workspace.&lt;/p&gt;
&lt;ol start=&quot;20&quot;&gt;
&lt;li&gt;&lt;strong&gt;Prettier&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Do you always press spacebar or tab key when coding, here comes Prettier to the rescue. It formats lines of code and makes it readable. After installing Prettier, enable format on save within your editor and experience the magic of Prettier.&lt;/p&gt;
&lt;ol start=&quot;21&quot;&gt;
&lt;li&gt;&lt;strong&gt;Polacode&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;As a technical writer, this comes in handy. It gives you appealing screenshots of your code snippets. It works like &lt;a href=&quot;https://carbon.now.sh&quot;&gt;Carbon&lt;/a&gt; within your VS Code.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Step 1: Press CMD + SHIFT + P
Step 2: Select Polacode 📸
Step 3: Copy some code
Step 4: Paste into Polacode view
Step 5: Click the lens-like button below the code view to save&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ol start=&quot;22&quot;&gt;
&lt;li&gt;&lt;strong&gt;Quokka.js&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Enjoy rapid JavaScript prototyping in your editor. &lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=WallabyJs.quokka-vscode&quot;&gt;Quokka.js&lt;/a&gt; automatically computes and print the result of code snippets. There&apos;s no need to log to the console. It supports package installation, live comments and value display features e.g. &lt;code class=&quot;language-text&quot;&gt;/*? $.toLowerCase() */&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;//?&lt;/code&gt; in the Pro edition.&lt;/p&gt;
&lt;p&gt;Get started with the steps below after installing the extension:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Step 1: Press CMD + SHIFT + P or CTRL + SHIFT + P
Step 2: Type Quokka.js
Step 3: Select an option e.g. Quokka.js: New JavaScript file
Step 4: Write your code&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ol start=&quot;23&quot;&gt;
&lt;li&gt;&lt;strong&gt;Shell-format&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Helps in quickly formatting shell scripts, dockerfiles, ignore files, DOTENV files and more.
To access this, press &lt;code class=&quot;language-text&quot;&gt;CMD + SHIFT + P&lt;/code&gt; and type Format Document.&lt;/p&gt;
&lt;ol start=&quot;24&quot;&gt;
&lt;li&gt;&lt;strong&gt;TODO Highlight&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;With a lot to work on which needs to be prioritized, sometimes, you may tend to forget tasks yet to be completed. TODO highlight makes these easily seen by highlighting them.&lt;/p&gt;
&lt;ol start=&quot;25&quot;&gt;
&lt;li&gt;&lt;strong&gt;YAML&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Provides comprehensive YAML Language support via the yaml-language-server, with built-in Kubernetes syntax support. &lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml&quot;&gt;Read the comprehensive usage guide&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Configuration&lt;/h2&gt;
&lt;p&gt;VS Code configurations not specific to a workspace are housed within the settings.json. You can configure VS Code to suit your preferences.&lt;/p&gt;
&lt;p&gt;To launch the settings.json, press&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;CMD + ,&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Copy and paste the code below within the settings.json file&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;json&quot;&gt;&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;editor.multiCursorModifier&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;ctrlCmd&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;editor.formatOnPaste&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;editor.wordWrap&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;bounded&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;editor.trimAutoWhitespace&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;editor.fontFamily&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Fira Code&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;editor.fontLigatures&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;editor.fontSize&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;editor.formatOnSave&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;files.autoSave&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;onFocusChange&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;emmet.syntaxProfiles&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;javascript&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;jsx&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;emmet.includeLanguages&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;javascript&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;javascriptreact&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;vue-html&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;html&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;eslint.autoFixOnSave&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;eslint.validate&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;javascript&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;javascriptreact&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;javascript.validate.enable&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;git.enableSmartCommit&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;files.trimTrailingWhitespace&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;editor.tabSize&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;gitlens.historyExplorer.enabled&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;diffEditor.ignoreTrimWhitespace&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;workbench.sideBar.location&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;right&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;explorer.confirmDelete&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;javascript.updateImportsOnFileMove.enabled&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;always&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;yaml.completion&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;yaml.format.enable&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;yaml.format.singleQuote&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;yaml.validate&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;yaml.schemas&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;http://json.schemastore.org/composer&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;/*&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;kubernetes&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;k8s/*/*.yaml&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content:encoded></item><item><title><![CDATA[Writing Better CSS in a Codebase]]></title><description><![CDATA[Cascading Style Sheet (CSS) is well known in web development as the flesh of HTML documents. While HTML gives a website its structure, CSS…]]></description><link>https://chiamakaikeanyi.dev/writing-better-css-in-a-codebase/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/writing-better-css-in-a-codebase/</guid><pubDate>Thu, 31 Jan 2019 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Cascading Style Sheet (CSS) is well known in web development as the flesh of HTML documents. While HTML gives a website its structure, CSS deals with the presentation. It makes websites visually appealing while handling responsiveness using media queries.&lt;/p&gt;
&lt;p&gt;A lot of developers hate writing CSS. Some prefer to just write the back-end logic and move on to something else. &quot;I&apos;ll write anything but definitely not CSS&quot; some will say.&lt;/p&gt;
&lt;p&gt;What if you can really write good CSS? What if you believe you suck at it as a result of not giving yourself enough time to appreciate the language and learn how to write it in a better way? What if this hatred is as a result of an improperly structured codebase?&lt;/p&gt;
&lt;p&gt;All there is to CSS is mastering the selectors, properties, values and specificity. Writing CSS is not complicated but it can be when working on big projects if not properly structured. It requires patience and love for artistry to excel if we intend to design usable web applications. The key here is to be consistent.&lt;/p&gt;
&lt;p&gt;In my previous post, &lt;a href=&quot;/writing-standards-compliant-html&quot;&gt;Writing Standards-Compliant-HTML&lt;/a&gt;, I listed a couple of guidelines we need to follow to build accessible websites or web applications. In this article, we will be looking at ways to write clean and maintainable CSS.&lt;/p&gt;
&lt;h3&gt;What we need to consider&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Readability&lt;/li&gt;
&lt;li&gt;Reusability&lt;/li&gt;
&lt;li&gt;Maintainability&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;What do we need to know?&lt;/h3&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;selector&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;property&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; value&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;As straightforward as this syntax is, there are things we don&apos;t get right when using it. We will be looking into some of them in detail.&lt;/p&gt;
&lt;h3&gt;Style Import&lt;/h3&gt;
&lt;p&gt;When linking the stylesheet to our HTML document, having to write the file type is unnecessary. This is implied already.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/* bad code */&lt;/span&gt;
&amp;lt;link rel=&lt;span class=&quot;token string&quot;&gt;&quot;stylesheet&quot;&lt;/span&gt; href=&lt;span class=&quot;token string&quot;&gt;&quot;path_to_file.css&quot;&lt;/span&gt; type=&lt;span class=&quot;token string&quot;&gt;&quot;text/css&quot;&lt;/span&gt;&gt;

&lt;span class=&quot;token comment&quot;&gt;/* good code */&lt;/span&gt;
&amp;lt;link rel=&lt;span class=&quot;token string&quot;&gt;&quot;stylesheet&quot;&lt;/span&gt; href=&lt;span class=&quot;token string&quot;&gt;&quot;path_to_file.css&quot;&lt;/span&gt;&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Code format&lt;/h3&gt;
&lt;p&gt;CSS selectors, properties, and values should be written in lowercase. Having it all in uppercase makes the stylesheet look clumsy.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/* bad code */&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;.site-body&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;DISPLAY&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; FLEX&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;/* good code */&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;.site-body&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; flex&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Quotation marks&lt;/h3&gt;
&lt;p&gt;Property values should be enclosed in single quotation marks (&apos; &apos;) rather than double quotation marks (&quot; &quot;).&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;html,
body&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Helvetica Neue&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; georgia&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; serif&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Box Model&lt;/h3&gt;
&lt;p&gt;We need a proper understanding of the box model to determine where padding, border and margin applies and use them appropriately. They all consist of a width and a height.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Content&lt;/strong&gt;: Each content on a web page takes up a rectangular space with a width and a height. The content is what is displayed on the web page. It is the inner-most part of the box.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Padding&lt;/strong&gt;: This is the transparent area surrounding the content.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Border&lt;/strong&gt;: This area (if present) surrounds the padding and the content&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Margin&lt;/strong&gt;: This separates the element from other elements in the DOM. It is the transparent outer-most layer that surrounds the border.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Naming Convention&lt;/h3&gt;
&lt;p&gt;Looking at id and class names, we should be able to decipher the content being styled. Names chosen should not be unnecessarily long. We need to make it short and meaningful.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/* bad code */&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;.green-notification&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #15c39a&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;/* good code */&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;.success-alert&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #15c39a&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In the code above, what happens when UI/UX engineers propose a change of color? This will affect not only the content of the styled element, but the name and HTML file(s) involved. Names should define the content or function (what it does) NOT the presentation (how it looks) of the element.&lt;/p&gt;
&lt;p&gt;You can opt for the BEM - Block, Element, Modifier (.block__element--modifier) naming convention. It is a widely-used convention in most big projects though outside the scope of this article. E.g.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;  &lt;span class=&quot;token selector&quot;&gt;.orderedList__item--active&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;border-bottom&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1px dashed #a974bf&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #ad58ad&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Specificity&lt;/h3&gt;
&lt;p&gt;Sometimes, when we style elements and expect them to reflect, they act otherwise leaving us wondering what went wrong. This is as a result of CSS specificity.&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;note&quot;&gt;It determines the rule applied by web browsers depending on the element&apos;s position on the hierarchy.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;By default, inline CSS is considered first before internal or external CSS. The order of precedence from highest to lowest is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;!important&lt;/code&gt; takes precedence over all declared styles.&lt;/li&gt;
&lt;li&gt;inline CSS (html style attribute) overrides CSS rules in style tag and external stylesheets&lt;/li&gt;
&lt;li&gt;a more specific selector takes precedence over a less specific one&lt;/li&gt;
&lt;li&gt;rules that appear later in the code override earlier rules if both have the same specificity.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For single selectors from highest to lowest:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Inline styles (&lt;code class=&quot;language-text&quot;&gt;&amp;lt;nav style=&quot;color: #fff;&quot;&gt;&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;IDs (&lt;code class=&quot;language-text&quot;&gt;#myId&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Classes (&lt;code class=&quot;language-text&quot;&gt;.myclass&lt;/code&gt;), attributes (&lt;code class=&quot;language-text&quot;&gt;[type=&quot;checkbox&quot;]&lt;/code&gt;) and pseudo-classes (&lt;code class=&quot;language-text&quot;&gt;:hover&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Elements (&lt;code class=&quot;language-text&quot;&gt;ul&lt;/code&gt;) and pseudo-elements (&lt;code class=&quot;language-text&quot;&gt;::before&lt;/code&gt;).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;We need to understand CSS specificity to help us make better decisions when styling our documents and avoid spaghetti code.&lt;/p&gt;
&lt;h3&gt;Enforced Styles&lt;/h3&gt;
&lt;p&gt;Do you see &lt;code class=&quot;language-text&quot;&gt;!important&lt;/code&gt; everywhere when checking out styles used on a website? That is a sign of an unstructured CSS codebase. &lt;code class=&quot;language-text&quot;&gt;!important&lt;/code&gt; overrides previously declared styles. This should be avoided as much as possible. The more it appears in a codebase, the more the codebase becomes messed up and difficult to maintain.&lt;/p&gt;
&lt;h3&gt;Shorthand Properties&lt;/h3&gt;
&lt;p&gt;The more concise, the better. We should opt for shorthand properties in cases where it can be used.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/* bad code */&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;selector&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;margin-top&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 10px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;margin-right&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 20px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;margin-bottom&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 10px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;margin-right&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 20px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;/* good code */&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;selector&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
 &lt;span class=&quot;token property&quot;&gt;margin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 10px 20px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Hex Code&lt;/h3&gt;
&lt;p&gt;We should always use three (3) character hexadecimal code where possible since they yield the same result as the six (6) character equivalent. According to &lt;a href=&quot;http://www.websiteoptimization.com/speed/tweak/hex/&quot;&gt;websiteoptimization.com&lt;/a&gt;, shorthand hexadecimal colors can help optimize style sheets, especially when combined with shorthand properties and grouping. The only exception should be when the named equivalent is shorter e.g. gray.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;selector&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #fc0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Unit&lt;/h3&gt;
&lt;p&gt;Properties having zero (0) as its value should not be assigned a unit as it makes no difference.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/* bad code */&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;selector&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;margin-top&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;margin-bottom&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0%&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;/* good code */&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;selector&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;margin-top&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;margin-bottom&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Group Selectors and Declarations&lt;/h3&gt;
&lt;p&gt;To create compact yet powerful CSS rules, always group selectors and declarations.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/* bad code */&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;body&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;th&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;/* good code */&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;body,
th&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Sort properties&lt;/h3&gt;
&lt;p&gt;To make rules readable, arrange the properties in alphabetical order.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;selector&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #ad58ad&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;margin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Setting width on inline elements&lt;/h3&gt;
&lt;p&gt;Sometimes, we find ourselves setting width on an inline element without adding &lt;code class=&quot;language-text&quot;&gt;display&lt;/code&gt; property to change it to a block element.&lt;/p&gt;
&lt;p&gt;&lt;label class=&quot;inline-element&quot;&gt;Inline element&lt;/label&gt;&lt;/p&gt;
&lt;p&gt;&lt;label class=&quot;inline-element inline-element--two&quot;&gt;Inline element&lt;/label&gt;&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.inline-element&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;background&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #ffb40f&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 50px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 200px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;.inline-element--two&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; block&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Notice the difference between the two elements above. By adding &lt;code class=&quot;language-text&quot;&gt;display: block;&lt;/code&gt; to the second element, the &lt;code class=&quot;language-text&quot;&gt;width&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;height&lt;/code&gt; properties took effect. Adding &lt;code class=&quot;language-text&quot;&gt;display: block;&lt;/code&gt; to block elements means introducing redundant code to our codebase and should be avoided.&lt;/p&gt;
&lt;h3&gt;Hover state on disabled elements&lt;/h3&gt;
&lt;p&gt;When elements are disabled, we need to convey it clearly to the users. Hovering over the buttons below, the buttons behave differently. Instead of giving room for deadclicks like in the first button, we need to use the approach applied in the second one.&lt;/p&gt;
&lt;input class=&quot;hover-state&quot; type=&quot;submit&quot; value=&quot;Hover over me&quot; disabled /&gt;
&lt;input class=&quot;hover-state--two&quot; type=&quot;submit&quot; value=&quot;Hover over me&quot; disabled /&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.hover-state&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;cursor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; pointer&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;.hover-state--two:disabled&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;cursor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; not-allowed&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Not providing fall backs&lt;/h3&gt;
&lt;p&gt;Using &lt;a href=&quot;https://caniuse.com&quot;&gt;caniuse&lt;/a&gt;, we can detect properties that are not supported across all browsers. Rather than going ahead to use the properties, we can show empathy by providing fallbacks.&lt;/p&gt;
&lt;h3&gt;Collapsing divs&lt;/h3&gt;
&lt;p&gt;We need to apply certain rules on &lt;code class=&quot;language-text&quot;&gt;div&lt;/code&gt;s housing floated elements to avoid what we see in case 1 below.&lt;/p&gt;
&lt;div&gt;
  &lt;div class=&quot;floated-left&quot;&gt;Floated left&lt;/div&gt;
  &lt;div class=&quot;floated-right&quot;&gt;Floated right&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;generic-div&quot;&gt;Below floated elements&lt;/div&gt;
&lt;div class=&quot;floats-container&quot;&gt;
  &lt;div class=&quot;floated-left&quot;&gt;Floated left&lt;/div&gt;
  &lt;div class=&quot;floated-right&quot;&gt;Floated right&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;generic-div&quot;&gt;Below floated elements&lt;/div&gt;
&lt;p&gt;Notice the difference between the two cases presented. If we don&apos;t understand what is happening when faced with this scenario, we may end up trying to enforce unneccessary styles to achieve what we want when we could have just applied the styles shown below to the &lt;code class=&quot;language-text&quot;&gt;floats-container&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.floats-container::before,
.floats-container::after&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot; &quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; table&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;.floats-container::after&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;clear&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; both&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Keep it DRY&lt;/h3&gt;
&lt;p&gt;Don&apos;t repeat yourself (DRY) in a codebase. We need to group things and use variables whenever we can. We don&apos;t need to set the theme color for every element that needs it. Providing the ability to update all instances once the declaration is changed makes the code easy to refactor.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;:root&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;--primary-color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #ad58ad&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;.nav&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;--primary-color&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Code for mobile users first&lt;/h3&gt;
&lt;p&gt;Code for mobile users first and then progressively enhance for tablets and desktops.
Compare this to coding for desktop first, where heavy components are loaded by default and then hidden for small screens (known as &quot;graceful degradation&quot;).&lt;/p&gt;
&lt;p&gt;Given:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;image&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here&apos;s an example of coding for desktop first:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;&amp;lt;style&gt;
.image&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;token property&quot;&gt;background-image&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token url&quot;&gt;&lt;span class=&quot;token function&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;image1.jpg&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token atrule&quot;&gt;&lt;span class=&quot;token rule&quot;&gt;@media&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;max-width&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;390px&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;token selector&quot;&gt;.image&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      display&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; none&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&amp;lt;/style&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In the above code, the default is to display the image, which is then overruled for mobile devices with the media query.&lt;/p&gt;
&lt;p&gt;Here&apos;s an example of coding for mobile first:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&amp;lt;style&gt;
&lt;span class=&quot;token atrule&quot;&gt;&lt;span class=&quot;token rule&quot;&gt;@media&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;min-width&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;391px&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;token selector&quot;&gt;.image&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      background-image&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token url&quot;&gt;&lt;span class=&quot;token function&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;image1.jpg&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&amp;lt;/style&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;By default, the image isn&apos;t displayed, while wider screens are progressively enhanced using a media query.&lt;/p&gt;
&lt;h3&gt;Code Validation&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://jigsaw.w3.org/css-validator/&quot;&gt;W3C Validator&lt;/a&gt; can help us pinpoint areas that we might miss when writing our stylesheets.&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;Knowing the right property to use at the right time will curb the stress we go through while styling web pages. So, let&apos;s not hate CSS. Let&apos;s practice more and we will come to love what we can achieve with it.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Writing Standards-Compliant HTML]]></title><description><![CDATA[The importance of quality Hypertext Markup Language (HTML) in any codebase cannot be over-emphasized. HTML is the backbone of any website…]]></description><link>https://chiamakaikeanyi.dev/writing-standards-compliant-html/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/writing-standards-compliant-html/</guid><pubDate>Thu, 17 Jan 2019 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;The importance of quality Hypertext Markup Language (HTML) in any codebase cannot be over-emphasized. HTML is the backbone of any website, the skeleton fleshed out with CSS and brought to life with JavaScript.&lt;/p&gt;
&lt;p&gt;Though markups render when standards are not adhered to, we need to strive towards writing standards-compliant code. Accessibility cannot be achieved without quality and semantically valid HTML.&lt;/p&gt;
&lt;p&gt;Let&apos;s go through the basic elements that makes up a HTML page, coding practices which are usually neglected and ways we can write standards-compliant HTML.&lt;/p&gt;
&lt;h3&gt;Doctype&lt;/h3&gt;
&lt;p&gt;This is often neglected. &lt;code class=&quot;language-text&quot;&gt;Doctype&lt;/code&gt; explains the document type being rendered on websites. You should always include it when writing your markup.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token doctype&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;!&lt;/span&gt;&lt;span class=&quot;token doctype-tag&quot;&gt;DOCTYPE&lt;/span&gt; &lt;span class=&quot;token name&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Lang attribute&lt;/h3&gt;
&lt;p&gt;The &lt;code class=&quot;language-text&quot;&gt;lang&lt;/code&gt; attribute is essential in any website. &lt;code class=&quot;language-text&quot;&gt;lang&lt;/code&gt; attribute within &lt;code class=&quot;language-text&quot;&gt;html&lt;/code&gt; element plays an important role especially when considering internationalization (i18n).&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;html&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;lang&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;en&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;html&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In a french version of your site, it should be written as&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;html&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;lang&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;fr&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;html&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Character encoding&lt;/h3&gt;
&lt;p&gt;The first content of the &lt;code class=&quot;language-text&quot;&gt;head&lt;/code&gt; section should be the character encoding declaration. The browser needs to know the encoding to use when rendering the content of a site. Therefore, this should be written before any other element within the &lt;code class=&quot;language-text&quot;&gt;head&lt;/code&gt; section.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;head&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;meta&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;charset&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;utf-8&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;head&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Entity reference&lt;/h3&gt;
&lt;p&gt;Entity reference should be used for characters with special meaning in HTML&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th align=&quot;left&quot;&gt;Character&lt;/th&gt;
&lt;th align=&quot;left&quot;&gt;Reference&lt;/th&gt;
&lt;th align=&quot;left&quot;&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td align=&quot;left&quot;&gt;&amp;#x26;&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;amp;amp;&lt;/code&gt;&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;Ampersand&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align=&quot;left&quot;&gt;&quot;&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;amp;quot;&lt;/code&gt;&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;Quotation mark&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align=&quot;left&quot;&gt;&apos;&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;amp;apos;&lt;/code&gt;&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;Apostrophe&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align=&quot;left&quot;&gt;&amp;#x3C;&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;lt;&lt;/code&gt;&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;Less than&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align=&quot;left&quot;&gt;&gt;&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;Greater than&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3&gt;Content of Title element&lt;/h3&gt;
&lt;p&gt;The &lt;code class=&quot;language-text&quot;&gt;title&lt;/code&gt; element should not be left without a content. The title of the page should be written first, followed by a separator before the title of the site.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;title&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Writing Standards-Compliant HTML | Chiamaka Ikeanyi&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;title&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Indentation&lt;/h3&gt;
&lt;p&gt;Of what use is a code if it is not readable? We need to ensure that the lines of code we write are properly indented showing hierarchy.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token doctype&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;!&lt;/span&gt;&lt;span class=&quot;token doctype-tag&quot;&gt;DOCTYPE&lt;/span&gt; &lt;span class=&quot;token name&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;html&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;lang&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;en&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;head&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;meta&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;charset&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;utf-8&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;meta&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;viewport&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;width=device-width, initial-scale=1.0&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;meta&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;http-equiv&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;X-UA-Compatible&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;ie=edge&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;title&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Coding Style&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;title&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;head&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;body&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;section&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;content&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;section&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;body&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;html&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The above code is messed up. To avoid this, for every new element, always indent using the tab key or by leaving 2 spaces. Closing elements should correspond to the opening elements.&lt;/p&gt;
&lt;p&gt;If you find this really tasking, &lt;a href=&quot;https://prettier.io/&quot;&gt;Prettier&lt;/a&gt; extension can help with that. Go through the &quot;Get Started&quot; guide to set it up.&lt;/p&gt;
&lt;h3&gt;Separation of concerns&lt;/h3&gt;
&lt;p&gt;Despite being in this era of CSS in JS, i&apos;m still of the opinion that HTML, CSS and JS files are meant to be kept in different files. Structure, presentation and behaviour should not be muddled up in one file. Not only do this improve readability of the code, it makes it reusable also.&lt;/p&gt;
&lt;p&gt;You can always import your CSS and JS files using&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&amp;lt;link rel=&lt;span class=&quot;token string&quot;&gt;&quot;stylesheet&quot;&lt;/span&gt; href=&lt;span class=&quot;token string&quot;&gt;&quot;path_to_file.css&quot;&lt;/span&gt; /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;and&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;script src&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;path_to_file.js&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;script&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;respectively&lt;/p&gt;
&lt;h3&gt;Use elements appropriately&lt;/h3&gt;
&lt;p&gt;Elements are often misused. We need to use the right elements for the right reasons. It is not appropriate to use an &lt;code class=&quot;language-text&quot;&gt;a&lt;/code&gt; element where &lt;code class=&quot;language-text&quot;&gt;button&lt;/code&gt; should be used (vice versa) or a &lt;code class=&quot;language-text&quot;&gt;div&lt;/code&gt; instead of a &lt;code class=&quot;language-text&quot;&gt;button&lt;/code&gt; and assign a button value to its role attribute. Avoid divitis (the act of writing many &lt;code class=&quot;language-text&quot;&gt;div&lt;/code&gt; elements in place of meaningful semantic HTML elements), there is no need to use a &lt;code class=&quot;language-text&quot;&gt;div&lt;/code&gt; element where we are meant to use a &lt;code class=&quot;language-text&quot;&gt;p&lt;/code&gt; or semantic element.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- bad code --&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;wrapper&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;text&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;placeholder&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Search...&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;

  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;header&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Main Title&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;description&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Short description&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;br&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;br&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
    Lorem ipsum dolor sit amet, consectetur adipiscing elit.
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;link&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token special-attr&quot;&gt;&lt;span class=&quot;token attr-name&quot;&gt;onclick&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token value javascript language-javascript&quot;&gt;&lt;span class=&quot;token function&quot;&gt;navigateSomewhere&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Learn more&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- good code --&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;wrapper&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;search&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;placeholder&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Search...&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;

  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;article&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;header&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;h1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Main Title&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;h1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;header&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Short description&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;https://domainname.topleveldomain&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;_blank&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Learn more about the main title &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;article&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;i&gt;&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;&amp;lt;em&gt;&lt;/code&gt; may yield the same result but has a different meaning for screen readers. Likewise &lt;code class=&quot;language-text&quot;&gt;&amp;lt;bold&gt;&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;&amp;lt;strong&gt;&lt;/code&gt;. Having an understanding of the appropriate usage of these elements will help you write better HTML code.&lt;/p&gt;
&lt;p&gt;Semantic elements - &lt;code class=&quot;language-text&quot;&gt;main&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;nav&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;section&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;article&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;aside&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;footer&lt;/code&gt; should always be used to describe contents of a website instead of using a &lt;code class=&quot;language-text&quot;&gt;div&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Use &lt;code class=&quot;language-text&quot;&gt;&amp;lt;time&gt;&lt;/code&gt; to represent a specific period instead of wrapping it within &lt;code class=&quot;language-text&quot;&gt;&amp;lt;span&gt;&lt;/code&gt; or &lt;code class=&quot;language-text&quot;&gt;&amp;lt;small&gt;&lt;/code&gt; tag.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- bad code --&gt;&lt;/span&gt;
Published on &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;January 17, 2019&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; at &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;07:00&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- good code --&gt;&lt;/span&gt;
Published on
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;time&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;datetime&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;January 17, 2019&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  January 17, 2019
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;time&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
at &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;time&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;datetime&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;07:00&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;07:00 am&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;time&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Quotation marks&lt;/h3&gt;
&lt;p&gt;Attributes values should be enclosed in double quotation marks (&quot; &quot;) rather than single quotation marks (&apos; &apos;).&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- bad code --&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;/explore&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Explore&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- good code --&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;/explore&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Explore&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Use alternate text on images&lt;/h3&gt;
&lt;p&gt;Provide a descriptive alternate text for images. &lt;code class=&quot;language-text&quot;&gt;alt&lt;/code&gt; attribute helps assistive technologies like screen readers to get a better understanding of the content of the element. For images used for decorative purposes (e.g. a button containing a search icon close to a Search text), it should be left empty &lt;code class=&quot;language-text&quot;&gt;alt&lt;/code&gt;=&quot;&quot; because adding alternate text would introduce redundancy.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- bad code --&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;path_to_file.png&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- good code --&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;path_to_file.png&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Descriptive text&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;path_to_file.png&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Form Labelling&lt;/h3&gt;
&lt;p&gt;Forms elements should be associated with labels either implicitly or explicitly.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- implicit label --&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- explicit label --&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Email Address&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Avoid Shouting&lt;/h3&gt;
&lt;p&gt;Writing a content in all capital letters signifies shouting. Lowercase letters should be used for your content likewise elements, attributes and values. Handle all typography and styling using CSS.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- bad code --&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;h1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;CODING STYLE&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;h1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;nav&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;CONTENT&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- good code --&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;h1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Coding Style&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;h1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;nav&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Content&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If you need the content to be in all capital letters, you can then use&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.nav&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;text-transform&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; uppercase&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Naming Convention&lt;/h3&gt;
&lt;p&gt;Naming things can be daunting but pays off in the long run when we get it right. Id and class names should be descriptive. It needs to relate to the content, not the presentation.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- bad code --&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;green-notification&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Order successful&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- good code --&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;order-notification&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Order successful&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Peradventure we decide to change the color of notification in the future, it would only affect the CSS file leaving the markup untouched. However, if the first approach was used, we would need to update the class name within the markup to reflect the change.&lt;/p&gt;
&lt;h3&gt;Logical Sequence&lt;/h3&gt;
&lt;p&gt;Markups should be written in a logical sequence. This can be very useful to screen readers. Using CSS to position sections within a page which can be achieved using HTML is an overkill.&lt;/p&gt;
&lt;h3&gt;Link to external documents&lt;/h3&gt;
&lt;p&gt;The &lt;code class=&quot;language-text&quot;&gt;rel&lt;/code&gt; attribute with value of &lt;code class=&quot;language-text&quot;&gt;noopener noreferrer&lt;/code&gt; should always be added to &lt;code class=&quot;language-text&quot;&gt;a&lt;/code&gt; elements when linking to external documents.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;path_to_file&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;rel&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;noopener noreferrer&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;_blank&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Link text&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;noopener&lt;/strong&gt;: To prevent the browsing context from having an opener browsing context if a user clicks on the hyperlink.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;noreferrer&lt;/strong&gt;: To prevent the browser from sending an HTTP referrer header if a user clicks on the hyperlink.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Code Validation&lt;/h3&gt;
&lt;p&gt;Validators such as &lt;a href=&quot;https://validator.w3.org&quot;&gt;W3C validator&lt;/a&gt; can help pin point areas that we might have missed.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- good code --&gt;&lt;/span&gt;

&lt;span class=&quot;token doctype&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;!&lt;/span&gt;&lt;span class=&quot;token doctype-tag&quot;&gt;DOCTYPE&lt;/span&gt; &lt;span class=&quot;token name&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;html&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;lang&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;en&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;head&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;meta&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;charset&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;utf-8&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;meta&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;viewport&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;width=device-width, initial-scale=1.0&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;meta&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;http-equiv&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;X-UA-Compatible&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;ie=edge&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;title&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Writing Standards-Compliant HTML | Chiamaka Ikeanyi&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;title&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;link&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;rel&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;shortcut icon&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;path_to_image.png&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;image/png&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;link&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;rel&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;stylesheet&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;path_to_file.css&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;head&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;body&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;site-body&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;header&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;/&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Site Title&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;sr-only&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Navigation&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;nav&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
          &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
            &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;/about&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;About&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
          &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
          &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
            &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;/projects&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Projects&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
          &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;nav&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;header&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;section&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;site-content&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;article&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
          &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;h1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Writing Standards-Compliant HTML&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;h1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
          &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;path_to_file.png&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Descriptive alternate text&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
          &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;The article&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;article&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;section&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;footer&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token entity named-entity&quot; title=&quot;&amp;copy;&quot;&gt;&amp;amp;copy;&lt;/span&gt; {dynamic date} Site Title
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;footer&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;script&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;path_to_file.js&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token script&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;script&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;body&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;html&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You must have learnt a few things here. Consider educating someone also. Let&apos;s write semantic, accessible and search engine optimized HTML and leave codebases better than we meet them.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Starting Out as a Newbie in the Tech Industry]]></title><description><![CDATA[Perhaps, you are considering joining the tech industry and asking about where to start as a newbie. Questions concerning this is usually…]]></description><link>https://chiamakaikeanyi.dev/starting-out-as-a-newbie-in-the-tech-industry/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/starting-out-as-a-newbie-in-the-tech-industry/</guid><pubDate>Thu, 03 Jan 2019 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Perhaps, you are considering joining the tech industry and asking about where to start as a newbie. Questions concerning this is usually raised during meetups and personal discussions with people. The tech industry is a good place to be. Being in tech gives you the opportunity to take an idea from ideation to a working application. You get the opportunity to build amazing solutions and help make life easier for people utilizing technology.&lt;/p&gt;
&lt;p&gt;My experience has been an awesome one so far - not easy, but rewarding. Sometimes, you get overwhelmed and at other times, you become joyous seeing a product you were part of its development being used by many.&lt;/p&gt;
&lt;p&gt;In this article, I will dissect the life of a software developer, how you can start your journey in tech and opportunities in the tech industry.&lt;/p&gt;
&lt;h2&gt;A day in the life of a developer&lt;/h2&gt;
&lt;p&gt;Seen developers before? They are a bunch of nerds with no social life. Staring at the screen all day with headphones on putting them within the zone. Are you sure they are not internet fraudsters?&lt;/p&gt;
&lt;p&gt;This is the common belief of people around developers ignorant of what software development entails. Is that true? you may ask. Personally, I&apos;ve seen jovial software engineers. We are not all introverts, there are ambiverts too.&lt;/p&gt;
&lt;p&gt;When working on a task and you encounter a bug, the first thing to do after a couple of &lt;a href=&quot;https://en.wikipedia.org/wiki/Debugging&quot;&gt;debugging&lt;/a&gt; is to check the documentation before visiting &lt;a href=&quot;https://stackoverflow.com&quot;&gt;Stack Overflow&lt;/a&gt; - a platform that features questions and answers on a wide range of topics in computer programming. If the answer is not forthcoming, google to see what other platforms have to offer. Sometimes, you may need to &lt;a href=&quot;https://en.wikipedia.org/wiki/Rubber_duck_debugging&quot;&gt;rubber duck&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The life of a developer is a disciplined one. As a developer, your spare time is hardly spent watching movies. When you want to relax and watch a movie, you remember all the notifications from coding channels that are piled up calling for your attention. Which would you go for? Definitely not that Netflix movie. You&apos;ll rather spend it learning one or two from coding platforms like &lt;a href=&quot;https://www.youtube.com/channel/UC8butISFwT-Wl7EV0hUK0BQ&quot;&gt;freeCodeCamp&lt;/a&gt;, &lt;a href=&quot;https://www.youtube.com/channel/UCnUYZLuoy1rq1aVMwx4aTzw&quot;&gt;Chrome Dev channel&lt;/a&gt;, &lt;a href=&quot;https://www.youtube.com/channel/UCyIe-61Y8C4_o-zZCtO4ETQ&quot;&gt;DevTips&lt;/a&gt;, &lt;a href=&quot;https://www.youtube.com/channel/UCyU5wkjgQYGRB0hIHMwm2Sg&quot;&gt;LevelUpTuts&lt;/a&gt; etc.&lt;/p&gt;
&lt;p&gt;Software development teaches you to think vastly and solve problems. So, you should consider coding. Check out Carl Newport&apos;s view on &lt;a href=&quot;http://calnewport.com/books/so-good/&quot;&gt;why skills trump passion in the quest for the work you love&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&quot;We&apos;ve heard our whole lives that if you follow your passion, that&apos;s all that matters. What I&apos;m arguing, instead, is that passion is something that follows you; on your path, you become really good at things that are valuable. If you focus on what&apos;s important and really focus on doing those things better, then [you] use these skills as leverage to keep shaping [your] job. It&apos;s not a sexy process, but it&apos;s one that very consistently helps people build these types of working lives that really resonate with them. They&apos;re a real source of passion.&quot;  -  Cal Newport&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;Journeying into tech, you should keep the following tips at heart:&lt;/h2&gt;
&lt;h3&gt;Be dedicated to the craft&lt;/h3&gt;
&lt;p&gt;You must not have a Computer Science degree to be in tech. Choose a track and improve. A lot of people have made themselves relevant in this field irrespective of their discipline or gender by putting in hours of work. Nothing great comes easy. You&apos;re going to hit a lot of walls, constantly acquire new skills as tools change rapidly and sometimes debugging is going to become immensely frustrating. The problem you&apos;re facing might make you feel dumb, and will make you rethink your career path. In these cases, do not give up. Even the best programmers are not geniuses. They just have a &lt;a href=&quot;https://theartofcharm.com/podcast-episodes/dr-carol-dweck-the-motivated-mindset-episode-445/&quot;&gt;growth mindset&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The tech industry is a good place to venture into especially with the innovative disruption happening at the moment. New to Tech? Do not fret as this is a lovely community to be in, creating a sense of belonging to individuals in it.&lt;/p&gt;
&lt;h3&gt;Find a means that work for you&lt;/h3&gt;
&lt;p&gt;What is your primary source of learning? Stack Overflow, YouTube, Books, MOOC, Online tutorials, Personal tutor, Discussion group or School system? This differs depending on the individual involved. Use whatever works for you. Identifying this early helps fast-track the learning process as there are lots of articles and tutorials flooded online. You don&apos;t need them all. Focus on the good ones and avoid getting overwhelmed.&lt;/p&gt;
&lt;p&gt;Here is a curated list of a few useful resources:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://edx.org&quot;&gt;Edx&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://freecodecamp.org&quot;&gt;freeCodeCamp&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://udacity.com&quot;&gt;Udacity&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developers.google.com/&quot;&gt;Google&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.codecademy.com&quot;&gt;Codecademy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.pluralsight.com&quot;&gt;Pluralsight&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.w3schools.com&quot;&gt;W3schools&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.khanacademy.org&quot;&gt;khanacademy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.udemy.com&quot;&gt;Udemy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://css-tricks.com&quot;&gt;Css Tricks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://wesbos.com/courses&quot;&gt;Wes Bos Courses&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/getify/You-Dont-Know-JS&quot;&gt;You Don’t Know JS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://eloquentjavascript.net/&quot;&gt;The Eloquent JavaScript&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org&quot;&gt;Mozilla Developers Network&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://javascript.info&quot;&gt;Javascript Info&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.edx.org/course/cs50s-introduction-computer-science-harvardx-cs50x&quot;&gt;CS50&apos;s Introduction to Computer Science&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://tympanus.net/codrops&quot;&gt;Codrops&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/channel/UCWv7vMbMWH4-V0ZXdmDpPBA&quot;&gt;Programming with Mosh&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/channel/UC29ju8bIPH5as8OGnQzwJyA&quot;&gt;Traversy Media - Brad Traversy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/channel/UCJbPGzawDH1njbqV-D5HqKw&quot;&gt;TheNewBoston - Bucky Roberts&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg&quot;&gt;The Net Ninja&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/c/Academind&quot;&gt;Academind&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developers.google.com/web/tools/chrome-devtools&quot;&gt;DevTools&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.amazon.com/Dont-Make-Me-Think-Usability/dp/0321344758&quot;&gt;Don’t Make Me Think&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/channel/UCVyRiMvfUNMA1UPlDPzG5Ow&quot;&gt;DesignCourse - Gary Simons&lt;/a&gt;
and more…&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Learn at your pace&lt;/h3&gt;
&lt;p&gt;Value every second, don&apos;t try to learn everything, focus on one thing at a time and forget all the hype. At the initial stage, everything may seem confusing starting with the stack to focus on, to the frameworks to consider, the text editor to use, configurations and hacks to make you more productive.&lt;/p&gt;
&lt;p&gt;You don’t need to learn everything at once. Learn the language when you need to use it to solve a problem. You must not use all the frameworks. Just learn what you need to accomplish the project at hand. It’s not about the code you write but about the problems you solve using those languages. Use the right tools to get the job done.&lt;/p&gt;
&lt;p&gt;While &lt;a href=&quot;https://www.ted.com/talks/barry_schwartz_on_the_paradox_of_choice?language=en&quot;&gt;trying to choose&lt;/a&gt; a niche can be quite confusing, the earlier you dive deep and explore, the better. Go for things you enjoy doing and develop your skills in it. If you are good at designs, you can venture into User Interface (UI), User Experience (UX) or Front-end development. Love logic and algorithms? Back-end development will be a good fit. Stay calm and learn. You may be plagued with &lt;a href=&quot;http://en.wikipedia.org/wiki/Impostor_syndrome&quot;&gt;imposter syndrome&lt;/a&gt;, remember that everyone else feels the same way. Don&apos;t let the syndrome consume you. Good resources that can help you transition smoothly into tech abound. Do not also let yourself suffer from &lt;a href=&quot;https://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect&quot;&gt;Dunning–Kruger effect&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Practice&lt;/h3&gt;
&lt;p&gt;A lot of practice is needed to be a master in this craft. Don&apos;t expect to be a pro in a month. Before starting any project, it is imperative to plan extensively before executing. In the course of planning, potential loopholes are spotted and solutions to them gotten.&lt;/p&gt;
&lt;p&gt;To excel, explore, build and ship it. The more you go through other people&apos;s codes, the better you become. Hang around more experienced software engineers and learn from them (they will push you to become better). Make Google your friend, source for information online as there is a high probability of someone having asked questions concerning the challenge you are currently faced with. Read articles and write about things you find interesting. Data subscription should be something you shouldn&apos;t trade for anything else as it plays a vital role here.&lt;/p&gt;
&lt;h3&gt;Get good tools&lt;/h3&gt;
&lt;p&gt;You need a computer with good specifications to function effectively. Concentrate by listening to &lt;a href=&quot;https://www.youtube.com/channel/UC8butISFwT-Wl7EV0hUK0BQ&quot;&gt;freeCodeCamp Radio&lt;/a&gt;, &lt;a href=&quot;https://www.noisli.com/&quot;&gt;Noisli&lt;/a&gt; or other cool instrumentals. Don&apos;t feel intimidated when you see most people move about with a Mac. You can still do well with your Linux or Windows laptop provided it has good specs (Ubuntu operating system preferably, minimum of 8GB RAM, Core i5, great processing speed etc.).&lt;/p&gt;
&lt;p&gt;You need a &lt;strong&gt;Terminal&lt;/strong&gt; (iTerm2, bash, cmd) for writing commands to run programs, a &lt;strong&gt;Text editor&lt;/strong&gt; (Visual Studio Code, Sublime Text, Atom) or an &lt;strong&gt;Integrated Development Environment&lt;/strong&gt; (Web Storm, PHP Storm, Visual Studio, Android Studio, Pycharm) for writing codes, a &lt;strong&gt;Web browser&lt;/strong&gt; (Chrome, Firefox) for viewing the output if your chosen track is web development, &lt;strong&gt;Git&lt;/strong&gt; for version control (GitHub, GitLab, Bitbucket), &lt;strong&gt;Web Server&lt;/strong&gt; (Netlify, Heroku, Linode, Digital Ocean, GCP, AWS) for hosting your site.&lt;/p&gt;
&lt;h3&gt;Share your Work&lt;/h3&gt;
&lt;p&gt;Don’t be afraid to share your first work. It can definitely not be compared to the ones you’ll build as you gain more experience. That is just your first iteration. Share it and seek for feedback. This will help you improve.&lt;/p&gt;
&lt;h3&gt;Avoid burnout&lt;/h3&gt;
&lt;p&gt;A lot of developers experience burn out. Don&apos;t accept more tasks than you can handle to help you keep your sanity. Work / life balance matters.&lt;/p&gt;
&lt;h3&gt;Network&lt;/h3&gt;
&lt;p&gt;Follow people making waves in the industry on social media (twitter is the best place to be), read their articles, and attend events they propagate. Meetups, seminars, workshops and conferences can be a great way to network and learn from peers and professionals in the industry, you may secure your next job through your connection.&lt;/p&gt;
&lt;p&gt;There are lots of meetups and conferences around that you can attend. Here in Lagos, Nigeria, we have:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Meetups&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Google Developers Group&lt;/li&gt;
&lt;li&gt;Facebook Developer&apos;s Circle&lt;/li&gt;
&lt;li&gt;Andela Learning Community&lt;/li&gt;
&lt;li&gt;Women in Tech&lt;/li&gt;
&lt;li&gt;Usable&lt;/li&gt;
&lt;li&gt;Figma&lt;/li&gt;
&lt;li&gt;Android Nigeria
and more ...&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Conferences&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;forLoop Summit&lt;/li&gt;
&lt;li&gt;Concatenate&lt;/li&gt;
&lt;li&gt;React Summit
and more ...&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Securing a job&lt;/h3&gt;
&lt;p&gt;When you are ready to secure a job, don&apos;t go for the money at first,   go for a structured environment. It will help you learn good software practices. Know the business  -  how the services talk to each other (how they are integrated). After mastering a particular area of software engineering, explore other areas - be rounded  ( front, middle, back-end). Have your own practice time, you&apos;re paid to learn so you need to do that to remain relevant.&lt;/p&gt;
&lt;p&gt;You can use these platforms to improve your skills:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.topcoder.com&quot;&gt;Topcoder&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://coderbyte.com&quot;&gt;Coderbyte&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.careercup.com&quot;&gt;Careercup&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://projecteuler.net&quot;&gt;Project Euler&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://leetcode.com&quot;&gt;Leetcode&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.spoj.com&quot;&gt;Spoj&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://hackerrank.com&quot;&gt;Hackerrank&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.geeksforgeeks.org&quot;&gt;Geeks for geeks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.crackingthecodinginterview.com&quot;&gt;Cracking the coding interview&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Platforms to source for opportunities&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://linkedin.com/&quot;&gt;LinkedIn&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.glassdoor.com/&quot;&gt;Glassdoor&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://angel.co/&quot;&gt;Angel.co&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://jooble.org/&quot;&gt;Jooble&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Organizations seek for people with the following skills:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;System design&lt;/li&gt;
&lt;li&gt;Database design&lt;/li&gt;
&lt;li&gt;Problem-solving&lt;/li&gt;
&lt;li&gt;Debugging&lt;/li&gt;
&lt;li&gt;Codebase navigation&lt;/li&gt;
&lt;li&gt;Code review capability&lt;/li&gt;
&lt;li&gt;Performance optimization&lt;/li&gt;
&lt;li&gt;Software testing&lt;/li&gt;
&lt;li&gt;Programming language proficiency&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Opportunities in the tech industry&lt;/h2&gt;
&lt;p&gt;There are various opportunities in the tech industry.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Project Management&lt;/li&gt;
&lt;li&gt;Product Design&lt;/li&gt;
&lt;li&gt;UI/UX Design&lt;/li&gt;
&lt;li&gt;Software Architect&lt;/li&gt;
&lt;li&gt;Software Engineering&lt;/li&gt;
&lt;li&gt;Database Administration&lt;/li&gt;
&lt;li&gt;Data Science&lt;/li&gt;
&lt;li&gt;Quality Assurance&lt;/li&gt;
&lt;li&gt;Network Administration&lt;/li&gt;
&lt;li&gt;Security Personnels&lt;/li&gt;
&lt;li&gt;Ethical Hacking&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Platforms to source for opportunities&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://linkedin.com/&quot;&gt;LinkedIn&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.glassdoor.com/&quot;&gt;Glassdoor&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://angel.co/&quot;&gt;Angel.co&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Tools Used in tech&lt;/h2&gt;
&lt;p&gt;You must not know how to code to be in the tech industry as great job opportunities exist in in various areas. Underlisted are tools used by different areas that can help you get started:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Project Management&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Trello&lt;/li&gt;
&lt;li&gt;Jira&lt;/li&gt;
&lt;li&gt;Asana&lt;/li&gt;
&lt;li&gt;Github board&lt;/li&gt;
&lt;li&gt;Pivotal tracker&lt;/li&gt;
&lt;li&gt;Slack&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Product Design&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Adobe XD&lt;/li&gt;
&lt;li&gt;Figma&lt;/li&gt;
&lt;li&gt;Sketch (Mac only)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Architectural Design&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Balsamiq&lt;/li&gt;
&lt;li&gt;Cloudfront&lt;/li&gt;
&lt;li&gt;Microsoft Visio&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Software Engineering&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Offline Editors&lt;/strong&gt;: &lt;a href=&quot;https://code.visualstudio.com&quot;&gt;Visual Studio Code&lt;/a&gt;, &lt;a href=&quot;https://www.sublimetext.com&quot;&gt;Sublime Text&lt;/a&gt;, &lt;a href=&quot;https://atom.io&quot;&gt;Atom&lt;/a&gt;, &lt;a href=&quot;https://www.jetbrains.com/webstorm&quot;&gt;Web Storm&lt;/a&gt;, &lt;a href=&quot;https://www.jetbrains.com/phpstorm&quot;&gt;PHP Storm&lt;/a&gt;, &lt;a href=&quot;https://www.jetbrains.com/pycharm/download/&quot;&gt;Pycharm&lt;/a&gt;, &lt;a href=&quot;https://developer.android.com/studio%60&quot;&gt;Android Studio&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Online Editors&lt;/strong&gt;: &lt;a href=&quot;http://repl.it&quot;&gt;Repl.it&lt;/a&gt;, &lt;a href=&quot;http://codepen.io&quot;&gt;Codepen&lt;/a&gt;, &lt;a href=&quot;http://jsbin.com&quot;&gt;JS Bin&lt;/a&gt;, &lt;a href=&quot;http://jsfiddle.net&quot;&gt;JS fiddle&lt;/a&gt;, Sassmeister&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Terminal&lt;/strong&gt;: iTerm2, Bash&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Version Control&lt;/strong&gt;: Github, Gitlab, Bitbucket&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Database Administration&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;SQL Yog&lt;/li&gt;
&lt;li&gt;Sequel Pro&lt;/li&gt;
&lt;li&gt;SQL Workbench&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Data Science&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Power BI&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Network Administration&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Packet Tracer&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Quality Assurance&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Jest&lt;/li&gt;
&lt;li&gt;Karma&lt;/li&gt;
&lt;li&gt;Jasmine&lt;/li&gt;
&lt;li&gt;Selenium
and more...&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Conclusively, you should note the underlisted points to excel in software engineering&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Learn the fundamentals. It helps you to understand the &quot;how&quot; and &quot;why&quot; involved in taking a specific approach to problem-solving.&lt;/li&gt;
&lt;li&gt;The best programmers are just the ones that never gave up.&lt;/li&gt;
&lt;li&gt;Great software engineers are problem solvers, not code warriors.&lt;/li&gt;
&lt;li&gt;Writing good software isn&apos;t about fancy one-liners, it&apos;s about writing maintainable code that serves a business need.&lt;/li&gt;
&lt;li&gt;For every code you write, consider performance and scale&lt;/li&gt;
&lt;li&gt;Learn the actual language of choice so that you can distinguish what the language can do and what the framework is helping with.&lt;/li&gt;
&lt;li&gt;Prefer official docs over Stack Overflow.&lt;/li&gt;
&lt;li&gt;Do your own quality assurance.&lt;/li&gt;
&lt;li&gt;Don&apos;t ignore the world around your work.&lt;/li&gt;
&lt;li&gt;Seek constructive criticism.&lt;/li&gt;
&lt;li&gt;Have side projects.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can have a look at &lt;a href=&quot;https://research.hackerrank.com/developer-skills/2018/&quot;&gt;Hackerrank 2018 Developer Skills Report&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[2018, A Year In My Life]]></title><description><![CDATA[2018 was an awesome year for me. I wouldn’t say it’s a perfect year, though I improved personally and professionally and I’ll be sharing my…]]></description><link>https://chiamakaikeanyi.dev/2018-a-year-in-my-life/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/2018-a-year-in-my-life/</guid><pubDate>Tue, 01 Jan 2019 02:00:00 GMT</pubDate><content:encoded>&lt;p&gt;2018 was an awesome year for me. I wouldn’t say it’s a perfect year, though I improved personally and professionally and I’ll be sharing my accomplishments with you.&lt;/p&gt;
&lt;p&gt;The year started with few resolutions to improve in some areas of my life and I made progress with these:&lt;/p&gt;
&lt;h2&gt;Relationship&lt;/h2&gt;
&lt;p&gt;I made conscious efforts to get to know my maker on a more personal level. He has been my guide and holds my head up when I’m feeble. I hope to do His will one day at a time.&lt;/p&gt;
&lt;p&gt;Within the tech community, I have met a couple of people as a result of attending meetups. I hope to solidify these relationships and get to meet new people this year.&lt;/p&gt;
&lt;h2&gt;Career&lt;/h2&gt;
&lt;p&gt;My career as a software engineer hasn’t gotten to its peak. In 2018, I was faced with a couple of challenges which made me stronger. I worked as part of a team on an application being used by many. When I started working with React, it seemed overwhelming, then came Redux, Next.js, GraphQL, Docker and Kubernetes. It is fulfilling looking back at those tough moments when I thought I couldn’t pull through and the &lt;strong&gt;“aha!”&lt;/strong&gt; moments when I nailed it. The best part of my career path is having to tackle something new every day thereby eradicating the possibility of boredom.&lt;/p&gt;
&lt;h2&gt;Volunteering&lt;/h2&gt;
&lt;p&gt;To help preach tech to the younger generation, I volunteered as a Learning Community Ambassador (Facilitator) in the Andela Learning Community program in partnership with Google and Udacity. It feels fulfilling listening to people and helping them solve challenges they are faced with. Seeing someone battle with a piece of code and being able to help. Watching them grow from writing “hello world” to solving more advanced challenges.&lt;/p&gt;
&lt;h2&gt;Writing&lt;/h2&gt;
&lt;p&gt;After putting up an article on an event organized by Facebook Developers Circles, Lagos, I was reached out to which led to my joining the Writers’ Corner arm of the community. My article was also published on Lean Women in Tech India. I got to publish a few articles on freeCodeCamp. My most popular article was &lt;a href=&quot;/how-to-configure-your-macos-terminal-with-zsh-like-a-pro&quot;&gt;How to Configure your macOS Terminal with Zsh like a Pro&lt;/a&gt;. Overall, I would say that I improved in writing and will write a lot more this year. To keep me in check, I launched this blog towards the end of the year.&lt;/p&gt;
&lt;h2&gt;Poetry&lt;/h2&gt;
&lt;p&gt;Asides coding, I love art and poetry. The act of playing with words, crafting scenes and getting to create a world out of your own thoughts. I wrote &lt;a href=&quot;https://medium.com/poesie/archive/2018&quot;&gt;10 poems&lt;/a&gt; and spoken words in 2018 surpassing the &lt;a href=&quot;https://medium.com/poesie/archive/2017&quot;&gt;3 poems&lt;/a&gt; that I wrote in 2017.&lt;/p&gt;
&lt;h2&gt;Photography&lt;/h2&gt;
&lt;p&gt;I enjoy taking random pictures. Capturing lovely moments and sharing with those involved and watch them beam with smiles. I try to live by the principle of leaving people happier than I meet them. I also love capturing places especially on cool evenings and at least get to know my environment better. I hope to tour Lagos in 2019 and document awesome places I think you should visit too.&lt;/p&gt;
&lt;h2&gt;Fitness&lt;/h2&gt;
&lt;p&gt;Doing this, I do not intend to lose weight, but to stay fit. I created a routine of exercising for 30 minutes daily to remain fit and energized to tackle each day’s challenges. I couldn’t stick to this after a while and hope to increase my perseverance level this year.&lt;/p&gt;
&lt;h2&gt;Reading&lt;/h2&gt;
&lt;p&gt;I spent a lot of time in 2018 reading tech articles, I learnt a lot from great minds. I came across The Richest Man in Babylon by George S. Clason and wrote a few highlights on it:&lt;/p&gt;
&lt;p&gt;Want to become rich but don’t have an iota of knowledge on how to accomplish your heartfelt desire, this book is a great asset that can help you through this quest. Going through the pages of the book, I noted the seven cures for a lean purse; becoming rich is not a miracle but can be actualized by the application of the following principles hereunder. Note that “&lt;strong&gt;A part of all you earn is yours to keep&lt;/strong&gt;”&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;For every ten coins thou placest within thy purse take out for use but nine. Thy purse will start to fatten at once and its increasing weight will feel good in thy hand and bring satisfaction to thy soul.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Budget thy expenses that thou mayest have coins to pay for thy necessities, to pay for thy enjoyments and to gratify thy worthwhile desires without spending more than nine-tenths of thy earnings.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Put each coin to labouring that it may reproduce its kind even as the flocks of the field and help bring to thee income, a stream of wealth that shall flow constantly into thy purse.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Guard thy treasure from loss by investing only where thy principal is safe, where it may be reclaimed if desirable, and where thou will not fail to collect a fair rental. Consult with wise men. Secure the advice of those experienced in the profitable handling of gold. Let their wisdom protect thy treasure from unsafe investments.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Own thy own home.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Provide in advance for the needs of thy growing age and the protection of thy family.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Cultivate thy own powers, to study and become wiser, to become more skilful, to so act as to respect thyself&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Go forth and practice these truths that thou mayest prosper and grow wealthy, as is thy right.&lt;/p&gt;
&lt;p&gt;I listened to podcasts on &lt;a href=&quot;https://www.youtube.com/watch?v=pY6TA2LyMtk&quot;&gt;Deep Work: Rules for Focused Success in a Distracted World&lt;/a&gt; and &lt;a href=&quot;https://theartofcharm.com/podcast-episodes/cal-newport-so-good-they-cant-ignore-you-episode-482&quot;&gt;So Good They Can’t Ignore You&lt;/a&gt; by Cal Newport. I will definitely read “The Subtle Art of Not Giving a F*ck” by Mark Manson and “Awaken the Giant Within” by Anthony Robbins this year. I think they are books worth your time.&lt;/p&gt;
&lt;p&gt;In 2019, I hope to …&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Grow rapidly in my role as a software engineer&lt;/li&gt;
&lt;li&gt;Get involved in open source projects&lt;/li&gt;
&lt;li&gt;Read and listen more&lt;/li&gt;
&lt;li&gt;Write more&lt;/li&gt;
&lt;li&gt;Keep fit&lt;/li&gt;
&lt;li&gt;Meet new people&lt;/li&gt;
&lt;li&gt;Overcome stage fright and speak at conferences&lt;/li&gt;
&lt;li&gt;Definitely, enrol in a driving school&lt;/li&gt;
&lt;li&gt;Tour Lagos, Nigeria and document awesome places I think you should visit too&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Becoming Better At Writing]]></title><description><![CDATA[Are writers born or made? This is the first question you need to ask yourself. Hmm! I guess they are born, you might have muttered. You see…]]></description><link>https://chiamakaikeanyi.dev/becoming-better-at-writing/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/becoming-better-at-writing/</guid><pubDate>Thu, 20 Dec 2018 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Are writers born or made? This is the first question you need to ask yourself. Hmm! I guess they are born, you might have muttered.&lt;/p&gt;
&lt;p&gt;You see yourself constantly writing and ending up not publishing them. “I don’t think it is good enough, Will it be appreciated? Oh! my use of words suck”. These keep popping in your head. You have been trying to write for a while and still see yourself not getting better at it? Brace up, let’s dive right in. That shell you’ve wrapped around yourself needs to be broken. Writer’s block is not for you.&lt;/p&gt;
&lt;p&gt;Writers are not born, you can develop the act of writing. You can grow to be like or better than top writers you admire by putting in more effort. It will surprise you at how amazing you will become when you work towards it. Persistence fuels success.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;A writer is a person who uses written words in various styles and techniques to communicate their ideas.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Writers use words to express their feeling or share knowledge. It may not be perfect, but it should be communicative enough to your target audience.&lt;/p&gt;
&lt;h2&gt;Why Write?&lt;/h2&gt;
&lt;p&gt;People write for different reasons; some writers feel that there are concepts that are not properly explained or are misunderstood and seek to correct the wrong notion being circulated while others seek to create a world they always wish they had through writing.&lt;/p&gt;
&lt;p&gt;So why do you write, torturing yourself to put it down?
Find a reason to write. Your reason is your motivation, it gets you going. Seek to brighten someone’s day through your writing.&lt;/p&gt;
&lt;p&gt;When you write;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You learn every day&lt;/li&gt;
&lt;li&gt;You educate and connect to the world better&lt;/li&gt;
&lt;li&gt;You get the opportunity to make an impact on someone’s life&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;According to George Orwell,&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;“When I sit down to write a book, I do not say to myself, ‘I am going to produce a work of art.’ I write it because there is some lie that I want to expose, some fact to which I want to draw attention, and my initial concern is to get a hearing.”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Our problems stem from man’s inability to sit in a room and act. We keep waiting for inspiration before we act. Renowned writers do not wait for inspiration. They commit their thoughts not minding how bad it might turn out to be. You may be smart but what matters are the choices you make today. Choose to write today, the number of words you put out to the world should not matter at first rather you should work towards publishing quality works and with time, you will grow into writing more quality contents.&lt;/p&gt;
&lt;h2&gt;Here’s how to get better&lt;/h2&gt;
&lt;p&gt;In a quest to becoming better at writing, you need to define your parameters first;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Which type of article do you want to write?&lt;/li&gt;
&lt;li&gt;What aspect of the type chosen do you want to write on?&lt;/li&gt;
&lt;li&gt;What do you hope to achieve through the article?&lt;/li&gt;
&lt;li&gt;Which aspects do you need to cover?&lt;/li&gt;
&lt;li&gt;Who are you writing for?&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Structure&lt;/h3&gt;
&lt;p&gt;At some point, topics pop into your head, don’t let them go, jot them down immediately and form a skeleton of the article. Put the most important information first. When creating headlines, don’t use click baits. It gets you the click but makes you lose your audience. Break down your story in such a way that it will be appealing to everyone, let each section explain a particular thought. Use readable font types and sizes with adequate spacing.&lt;/p&gt;
&lt;h3&gt;Tone&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/lacks_clarity.gif?raw=true&quot; alt=&quot;Lacks clarity&quot;&gt;&lt;/p&gt;
&lt;p&gt;You wouldn’t want to get that feedback right? In this digital era, readers allocate very little time to your content to ascertain if it is worth their time. Find your voice in writing, be concise and unique. Use easier words to convey your thoughts.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;If you can’t explain the concept to a child, then, you still have a long way to go. — Richard Feynman&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Simplicity should be your watchword. Knowledge is a process of piling up facts; wisdom lies in their simplification.&lt;/p&gt;
&lt;p&gt;When considering making a good impression on your readers, what you write is not the only thing you should think about but how you convey your thoughts. Analyze different interpretations that your readers may likely give to your tone.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://app.grammarly.com/&quot;&gt;Grammarly&lt;/a&gt; can help you restructure your sentences. It is a nice tool I recently discovered that uses artificial intelligence to transform writing styles.&lt;/p&gt;
&lt;h3&gt;Visuals&lt;/h3&gt;
&lt;p&gt;Every content you create needs an element of visuals in it. Images, illustrations, graphs etc., attracts and sustains your audiences’ interest. The impact of this element should not be overlooked in your quest to becoming a better writer. Tons of them are available on &lt;a href=&quot;https://unsplash.com/&quot;&gt;Unsplash&lt;/a&gt;, &lt;a href=&quot;https://www.freepik.com/&quot;&gt;Freepik&lt;/a&gt;, &lt;a href=&quot;https://undraw.co/illustrations&quot;&gt;Undraw&lt;/a&gt;, &lt;a href=&quot;https://pixabay.com/&quot;&gt;Pixabay&lt;/a&gt;, &lt;a href=&quot;https://www.pexels.com/&quot;&gt;Pexels&lt;/a&gt; and other platforms providing varieties of free images to choose from.&lt;/p&gt;
&lt;h3&gt;Read&lt;/h3&gt;
&lt;p&gt;Read works of great writers. When you consistently read the work of a great author, you notice that it soon begins to reflect on your work of art.&lt;/p&gt;
&lt;p&gt;Writing is a function of the mind, declutter your mind and arrange your thoughts.&lt;/p&gt;
&lt;h2&gt;Promotion&lt;/h2&gt;
&lt;p&gt;Promote your articles on LinkedIn, Twitter and other social platforms. Be open to criticism, get people to criticize your work and learn from it. Great authors seek feedback and bank on it to grow.&lt;/p&gt;
&lt;h2&gt;Tools That Can Come in Handy&lt;/h2&gt;
&lt;p&gt;Tools offer great ways to be more productive. The under-listed tools can aid you in becoming better at writing.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://coschedule.com/headline-analyzer&quot;&gt;Headline Analyzer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://app.grammarly.com/&quot;&gt;Grammarly&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.hemingwayapp.com/&quot;&gt;Hemingway Editor&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.copyscape.com/&quot;&gt;Copyscape&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.powerthesaurus.org/&quot;&gt;Power thesaurus&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://asciinema.org/&quot;&gt;Asciinema&lt;/a&gt; (for techies)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Don’t be ashamed to identify as an author. Go out there and conquer your fears.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Working with Git]]></title><description><![CDATA[John is a budding software developer excited about building usable products. He develops and hosts applications using cheap hosting services…]]></description><link>https://chiamakaikeanyi.dev/working-with-git/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/working-with-git/</guid><pubDate>Thu, 06 Dec 2018 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;John is a budding software developer excited about building usable products. He develops and hosts applications using cheap hosting services. After a few months of diving into software development, he felt it was time to get a job to put into practise what he has learnt and also work in a team.&lt;/p&gt;
&lt;p&gt;During an interview with one of the well-known firms he applied to, he was given a task to work on. One of the requirements for being successful was to have an understanding of working with git. Poor John who has been working alone was not aware of the usefulness of version control in software development. He has been hearing about the concept but does not fully understand how it works.&lt;/p&gt;
&lt;p&gt;Guess what! He lost the opportunity because he was actually expected to push the code to a git repository when he is done with the coding task assigned to him but was not told. So, he just finished and left. A few minutes later, the interviewer called him and asked  - &quot;Hi John, hope you pushed your code to git?&quot;&lt;/p&gt;
&lt;p&gt;He felt very bad losing that opportunity as a result of not understanding that version control is an integral part of software engineering.&lt;/p&gt;
&lt;p&gt;If you are like John, this article is for you. Let&apos;s dive right in.&lt;/p&gt;
&lt;h2&gt;What is version control?&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;A system that records changes to a file or set of files over time so that you can recall specific versions later&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;We have &lt;strong&gt;Centralized Version Control Systems&lt;/strong&gt; where a single server contains all the versioned files, and a number of clients that check out files from that central place and &lt;strong&gt;Distributed Version Control Systems&lt;/strong&gt; in which every clone is really a full backup of all the data.&lt;/p&gt;
&lt;p&gt;The second option is widely used. The popular &lt;a href=&quot;https://github.com&quot;&gt;GitHub&lt;/a&gt;, &lt;a href=&quot;https://gitlab.com&quot;&gt;Gitlab&lt;/a&gt; and &lt;a href=&quot;https://bitbucket.org/&quot;&gt;Bitbucket&lt;/a&gt; use this method.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Git is a version control system for tracking changes in computer files and coordinating work on those files among multiple people. It is primarily used for source code management in software development, but it can be used to keep track of changes in any set of files.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&quot;It worked yesterday but not working today. Someone must have accidentally introduced a bug and I can&apos;t seem to figure out who. I&apos;m finding it difficult getting it back to its previous state. Argh!&quot;&lt;/p&gt;
&lt;p&gt;When working in a team, the above scenario is bound to happen and Git is at the rescue. All versions of the code are recorded for reference purposes.&lt;/p&gt;
&lt;h2&gt;Git Workflow&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Master Branch:&lt;/strong&gt;
This is a replica of the code in production. No one is allowed to code directly on this branch.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Release Branch:&lt;/strong&gt;
This is created from the master branch. This becomes necessary when multiple projects are running on the same code base e.g. when paying your technical debts by trying to get rid of legacy code. To work on a feature, you need to create another branch from this branch.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Feature Branch:&lt;/strong&gt;
For every feature added, there should be a feature branch. This ensures parallel developments making rollbacks and cherrypicking easier.&lt;/p&gt;
&lt;section class=&quot;block-emphasis&quot;&gt;
Master branch → Release Branch → Feature branch → Task complete → git add → git commit → git pull → git merge → git push → Create pull request → Code review → Pull request merged to release branch → Pull request merged to master branch  → Feature deployed to production
&lt;/section&gt;
&lt;h2&gt;Steps&lt;/h2&gt;
&lt;p&gt;Open your terminal&lt;/p&gt;
&lt;p&gt;Verify if git is installed&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;--version&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Set a git username globally&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; config &lt;span class=&quot;token parameter variable&quot;&gt;--global&lt;/span&gt; user.name &lt;span class=&quot;token string&quot;&gt;&quot;your_user_name&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Set a git email globally&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; config &lt;span class=&quot;token parameter variable&quot;&gt;--global&lt;/span&gt; user.email &lt;span class=&quot;token string&quot;&gt;&quot;your_email&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Confirm that you have set your git details correctly&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; config &lt;span class=&quot;token parameter variable&quot;&gt;--global&lt;/span&gt; user.name

&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; config &lt;span class=&quot;token parameter variable&quot;&gt;--global&lt;/span&gt; user.email&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Initialize git in your project&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;mkdir&lt;/span&gt; project-name

&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; project-name

&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; init&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;or Start with a remote repository&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; clone repository_URL&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Create a new branch for the aspect of the project you want to work on and change the current working directory to your new branch&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; checkout &lt;span class=&quot;token parameter variable&quot;&gt;-b&lt;/span&gt; name_of_your_new_branch&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;or Switch to an existing branch&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; checkout name_of_the_branch&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Create README file&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;# repository_name&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;&gt;&lt;/span&gt; README.md&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Add specific file&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;add&lt;/span&gt; filename.extension&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;or Add all changes&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;add&lt;/span&gt; &lt;span class=&quot;token builtin class-name&quot;&gt;.&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Check the current state of your branch&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; status&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Commit changes&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; commit &lt;span class=&quot;token parameter variable&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;commit_message&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If the task is associated with a ticket number, use the ticket number as a prefix to the commit message e.g.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; commit &lt;span class=&quot;token parameter variable&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Feature-add-filters&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;View your current remote repository&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; remote show origin&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Add a new remote for your branch:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; remote &lt;span class=&quot;token function&quot;&gt;add&lt;/span&gt; name_of_your_remote remote_URL

e.g. &lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; remote &lt;span class=&quot;token function&quot;&gt;add&lt;/span&gt; origin https://github.com/username/project-name.git&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Change your remote URL&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; remote set-url origin remote_URL&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Push changes from your branch to the remote repository&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; push &lt;span class=&quot;token parameter variable&quot;&gt;-u&lt;/span&gt; name_of_your_remote name_of_your_branch&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Pushing to master&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; push &lt;span class=&quot;token parameter variable&quot;&gt;-u&lt;/span&gt; origin master&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Pushing to a given remote branch.
If the remote branch do not exist, it would be created&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; push &lt;span class=&quot;token parameter variable&quot;&gt;-u&lt;/span&gt; origin feature_branch_name&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If the task is associated with a ticket number, use the ticket number as the feature branch name e.g.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; push origin &lt;span class=&quot;token parameter variable&quot;&gt;-u&lt;/span&gt; feature-filters&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To push the current branch and set the remote as upstream:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; push --set-upstream origin name_of_your_new_remote

e.g. &lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; push --set-upstream origin master&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;View differences in branches&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;diff&lt;/span&gt; name_of_the_source_branch name_of_the_target_branch&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Update your branch when the original branch from the official repository has been updated&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; fetch name_of_your_remote&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;or&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; pull origin name_of_your_new_remote&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Merge changes from master to your branch:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; checkout your_branch_name

&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; merge master&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Merge changes from your branch to the master branch:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; checkout master

&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; merge your_branch_name&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Fetch updates from a forked repository&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; the_forked_repo

&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; remote &lt;span class=&quot;token function&quot;&gt;add&lt;/span&gt; upstream forked_repo_URL

&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; pull upstream master&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Unstage a file&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; reset HEAD filename.extension&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;View all your branches:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; branch&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To rename a local branch,&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If you are on the branch:&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; branch &lt;span class=&quot;token parameter variable&quot;&gt;-m&lt;/span&gt; new_name&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;If you are on another branch:&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; branch &lt;span class=&quot;token parameter variable&quot;&gt;-m&lt;/span&gt; current_name new_branch_name&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To rename a remote branch, delete the current branch and push the new one:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; push origin :current_branch_name

&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; push origin &lt;span class=&quot;token parameter variable&quot;&gt;-u&lt;/span&gt; new_branch_name&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To deploy selected features&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; cherrypick commit_hash&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;View git logs&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; log &lt;span class=&quot;token parameter variable&quot;&gt;--summary&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; log &lt;span class=&quot;token parameter variable&quot;&gt;--graph&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;View your git configurations&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; config &lt;span class=&quot;token parameter variable&quot;&gt;--list&lt;/span&gt; --show-origin&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Delete a directory from Git AND local&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-r&lt;/span&gt; directory_name&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Delete a directory from Git BUT NOT LOCAL&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-r&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;--cached&lt;/span&gt; directory_name&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Delete a file from Git AND local&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;rm&lt;/span&gt; filename.extension&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Delete a file from Git BUT NOT LOCAL&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;--cached&lt;/span&gt; filename.extension&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Forcefully Delete a staged file&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-f&lt;/span&gt; filename.extension&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Delete a branch on your local file system&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; branch &lt;span class=&quot;token parameter variable&quot;&gt;-d&lt;/span&gt; name_of_your_branch&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Delete the branch on Github&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; push origin :name_of_your_branch&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To view contributions by each member of your team,&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; shortlog &lt;span class=&quot;token parameter variable&quot;&gt;-sn&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;--all&lt;/span&gt; --no-merges&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The shortlog provides summaries of git log; the -s flag will suppress commit description and shows a commit count summary, the -n flag will sort the output according to the number of commits per author. The --all flag logs all branches, and --no-merges ensures that merge commits are not counted.&lt;/p&gt;
&lt;p&gt;To get all your commits to a remote branch on the working tree of your local machine,&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; reset &lt;span class=&quot;token parameter variable&quot;&gt;--soft&lt;/span&gt; origin/master&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To correct a wrong name or email used to make a push to a project,&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;$ &lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; filter-branch --env-filter &lt;span class=&quot;token string&quot;&gt;&apos;
WRONG_EMAIL=&quot;old-email@example.com&quot;
NEW_NAME=&quot;New Name&quot;
NEW_EMAIL=&quot;new-email@example.com&quot;

if [ &quot;$GIT_COMMITTER_EMAIL&quot; = &quot;$WRONG_EMAIL&quot; ]
then
    export GIT_COMMITTER_NAME=&quot;$NEW_NAME&quot;
    export GIT_COMMITTER_EMAIL=&quot;$NEW_EMAIL&quot;
fi
if [ &quot;$GIT_AUTHOR_EMAIL&quot; = &quot;$WRONG_EMAIL&quot; ]
then
    export GIT_AUTHOR_NAME=&quot;$NEW_NAME&quot;
    export GIT_AUTHOR_EMAIL=&quot;$NEW_EMAIL&quot;
fi
&apos;&lt;/span&gt; --tag-name-filter &lt;span class=&quot;token function&quot;&gt;cat&lt;/span&gt; -- &lt;span class=&quot;token parameter variable&quot;&gt;--branches&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;--tags&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To update a branch and its dependencies&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; rebase BRANCH_NAME --update-refs&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To push updates of branches to a remote repository&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; push --force-with-lease origin BRANCH_1 BRANCH_N&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Version Control Tools&lt;/h2&gt;
&lt;p&gt;Some tools make it possible for us to avoid the hassle of writing these commands by abstracting its complexities.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;GitLens extension for VS Code&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Source tree (for Mac and Windows)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;VCS menu option on IntelliJ IDEs (PHP Storm, Android Studio, etc.)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As a software developer, it is advisable to use the command line. Learn &lt;a href=&quot;/how-to-configure-your-macos-terminal-with-zsh-like-a-pro/&quot;&gt;how to configure your terminal with ZSH&lt;/a&gt; for maximum output.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Transforming Error Pages from Dead Ends to User Retention Opportunities]]></title><description><![CDATA[HTTP 404 Not Found errors are an inevitable part of any application. Users mistype URLs, links go stale, and content hierarchies are…]]></description><link>https://chiamakaikeanyi.dev/beyond-the-404-error-pages/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/beyond-the-404-error-pages/</guid><pubDate>Thu, 29 Nov 2018 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;HTTP 404 Not Found errors are an inevitable part of any application. Users mistype URLs, links go stale, and content hierarchies are refactored. While the default, unstyled server 404 page is technically functional, from a product design perspective, it&apos;s a catastrophic dead end in the user journey.&lt;/p&gt;
&lt;p&gt;This single page represents an unhandled exception in the user experience. A blank white page with &quot;Not Found&quot; builds frustration, erodes trust, and directly contributes to a higher bounce rate.&lt;/p&gt;
&lt;p&gt;Instead of treating the 404 page as a failure, view it as a critical touchpoint — an opportunity to gracefully handle an error, reinforce your brand, and guide the user back into a productive flow.&lt;/p&gt;
&lt;h2&gt;Consider these tips for an effective 404 error page that serves both the user and the product:&lt;/h2&gt;
&lt;h3&gt;Acknowledge the State, Don&apos;t Obfuscate&lt;/h3&gt;
&lt;p&gt;A common anti-pattern is to silently redirect all 404s to the homepage. This is disorienting; the user clicks a link expecting &quot;Product A&quot; and is now on the homepage with no explanation. This breaks their mental model and leaves them wondering what went wrong.&lt;/p&gt;
&lt;p&gt;404 pages must clearly and concisely state what happened.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/github.webp?raw=true&quot; alt=&quot;GitHub error page&quot;&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Use plain language: &quot;Page Not Found,&quot; &quot;We can&apos;t seem to find the page you&apos;re looking for.&quot;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Display the 404 status code. It’s helpful for technical users and clearly defines the error.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Briefly explain why this might have happened (e.g., &quot;The link may be broken, or the page may have been moved.&quot;).&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Maintain Brand and UI Consistency&lt;/h3&gt;
&lt;p&gt;A default error page is jarring. It makes the user feel like they&apos;ve &quot;broken&quot; the site or left it entirely.
404 pages should feel like it&apos;s part of the same application.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/airbnb.gif?raw=true&quot; alt=&quot;Airbnb error page&quot;&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Integrate your Design System: Use the same header, footer, typography, and color palette as the rest of your site.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Keep UI Components: If you have a navigation bar or main menu, keep it. This immediately gives the user familiar orientation points.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Voice and Tone: The page should sound like your brand. This consistency builds trust and reassures the user that they are still in the right place, even if the content isn&apos;t.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Provide Intelligent Recovery Paths&lt;/h3&gt;
&lt;p&gt;A &quot;Page Not Found&quot; message with no next step leaves the user stranded. The primary goal of a 404 page is user recovery. You must provide clear, actionable calls to action (CTAs).&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/steve-madden.webp?raw=true&quot; alt=&quot;Steve Madden error page&quot;&gt;&lt;/p&gt;
&lt;p&gt;Don&apos;t just offer a single &quot;Go Home&quot; link. Provide a hierarchy of options:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Primary CTA (Site-wide Search): This is often the most effective tool. The user was looking for something specific; empower them to find it immediately. Place the search bar prominently.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Secondary CTAs (Key Navigation): Provide direct links to the main pillars of your application (e.g., &quot;Dashboard,&quot; &quot;Products,&quot; &quot;Blog,&quot; &quot;Help Center&quot;).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Contextual Links (Advanced): If possible, parse the requested (but broken) URL. If the user tried to access /blog/my-post-title, you can confidently suggest a link to the main /blog index.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Default (Homepage): Always include a link back to the homepage as a reliable fallback.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Defuse Frustration with Brand Voice&lt;/h3&gt;
&lt;p&gt;This is where product design shines. A 404 is a moment of frustration. You have an opportunity to turn that negative emotion into a neutral or even positive brand interaction.&lt;/p&gt;
&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/mint.webp?raw=true&quot; alt=&quot;Mint error page&quot; width=&quot;100%&quot;/&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Use Empathy: A simple, &quot;Sorry about that!&quot; goes a long way.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Show Personality: This is a classic place for creative illustrations, clever copy, or even a simple interactive element (like a mini-game) that aligns with your brand.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Balance Form and Function: Creativity should never come at the expense of clarity. A beautiful illustration is useless if the user can&apos;t find the search bar.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Add a Feedback Loop: Log, Analyze, and Iterate&lt;/h3&gt;
&lt;p&gt;As an engineer, you know that your 404 page is also a valuable debugging and analytics tool.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Log Your 404s: Server-side logging of 404 hits (and their Referer headers) is crucial for finding broken internal links you need to fix. It also reveals which external sites are sending you bad traffic.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Track Page Analytics: Fire analytics events on your 404 page. Are users clicking &quot;Home&quot; or are they using the search bar? What are they searching for? This data tells you how effective your recovery paths are and can inform what content you might be missing.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Stop treating the 404 page as an afterthought. Integrate it into your core design system and product flow. By treating it as a key UX component, you can transform a moment of user frustration into an opportunity for retention, brand-building, and valuable data collection.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Highlights from Chrome Dev Summit 2018]]></title><description><![CDATA[Have you heard of Google Chrome Dev Summit? If you haven’t heard of it and the awesome cool things Chrome engineers have been working on…]]></description><link>https://chiamakaikeanyi.dev/highlights-from-chrome-dev-summit-2018/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/highlights-from-chrome-dev-summit-2018/</guid><pubDate>Thu, 22 Nov 2018 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Have you heard of Google Chrome Dev Summit? If you haven’t heard of it and the awesome cool things Chrome engineers have been working on lately, this article is for you.&lt;/p&gt;
&lt;p&gt;I’m a front-end engineer working on an application that serves millions of users. I also use Chrome Dev Tools every day to debug and monitor performance. So I found it imperative to learn about the tools and technologies that will help me optimize my applications and contribute to building a better web. Debugging and optimizations become easier when you are aware of the tools to take advantage of, and metrics to look out for.&lt;/p&gt;
&lt;p&gt;Chrome Dev Summit offered me the opportunity to hear about updates on these tools and technologies, and showed me avenues to contribute toward making these tools better. I learned a lot from Chrome engineers during the summit, and I would like you to benefit from that knowledge so we can build an awesome web experience together.&lt;/p&gt;
&lt;p&gt;Chrome Dev Summit is an opportunity for Google Chrome engineers and leading web developers to celebrate the web platform, provide updates on their latest work, and get feedback from the community.&lt;/p&gt;
&lt;p&gt;This year, developers from across the globe converged at Yerba Buena Center for the Arts in San Francisco, California for a two-day (12th and 13th November) exploration of modern web experiences. It was celebrated in style as Chrome engineers mark the 10-year anniversary of shipping Google Chrome, the most used web browser.&lt;/p&gt;
&lt;p&gt;The event focused on what it means to build a fast, high-quality web experience using modern web technologies and best practices, as well as looking at new and exciting capabilities coming to the web platform. The major highlights are summarized below.&lt;/p&gt;
&lt;h2&gt;Performance Budgets&lt;/h2&gt;
&lt;p&gt;An increasing number of features in web applications today are also being accessed using low-end devices on high latency networks. Because of this, JavaScript becomes &lt;a href=&quot;https://medium.com/@addyosmani/the-cost-of-javascript-in-2018-7d8950fbb5d4&quot;&gt;expensive&lt;/a&gt; thereby requiring &lt;a href=&quot;https://addyosmani.com/blog/performance-budgets/&quot;&gt;performance budgeting&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;A Performance Budget is a framework that allows you to determine what changes represent progress and what changes represent regression, taking into account a set of shared metrics and budgets for each made actionable&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;However, we need to have metrics in place to measure before we can improve on them, as it is impossible to measure what we do not track. When we care about exceptional user experience irrespective of device or network conditions, &lt;a href=&quot;https://developers.google.com/web/progressive-web-apps/&quot;&gt;building a PWA&lt;/a&gt; with performance in mind becomes a priority.&lt;/p&gt;
&lt;p&gt;To build high-quality web experience, Google developed tools like Lighthouse, PageSpeed Insights, and Chrome User Experience Report(CrUX) to help developers monitor and enhance the web platform. A new lighthouse UI was announced at the event with PWA Refactor, reduction in lighthouse runtime and new score bucketing.&lt;/p&gt;
&lt;p&gt;We can also &lt;a href=&quot;https://github.com/ebidel/lighthouse-ci&quot;&gt;integrate Lighthouse&lt;/a&gt; to our development workflow so it runs on every commit helping us to keep an eye on performance.&lt;/p&gt;
&lt;h2&gt;Tools to help monitor the cost of packages:&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://www.npmjs.com/package/webpack-bundle-analyzer&quot;&gt;Webpack Bundle Analyzer&lt;/a&gt; which creates a treemap visualization of the contents of your bundles. It helps determine modules that make up the most of its size.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://bundlephobia.com/&quot;&gt;Bundlephobia&lt;/a&gt; helps to discover the cost of adding an npm package to your bundle.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://medium.com/r/?url=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2Fbundlesize&quot;&gt;Bundle size&lt;/a&gt; helps keep your bundle size in check. You can integrate it in such a way that PRs can&apos;t be merged once the bundle size is greater than the target maximum size.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;PageSpeed Insights Powered by Lighthouse&lt;/h2&gt;
&lt;p&gt;Because of the varying results analysis gotten from PageSpeed Insights and Lighthouse when measuring the performance of websites, the Chrome team introduced PageSpeed API v5. It is essentially Lighthouse API v1 to power PageSpeed Insights. This means that the differing results will be history. PageSpeed Insights also incorporates field data provided by the &lt;a href=&quot;https://developers.google.com/web/tools/chrome-user-experience-report/&quot;&gt;CrUX&lt;/a&gt;&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;fetch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;https://www.googleapis.com/pagespeedonline/v5/runPagespeed?&amp;amp;url=&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;url&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;First Input Delay&lt;/h2&gt;
&lt;p&gt;We are conversant with measuring Speed Index(SI), First Contentful Paint(FCP), Time to Interactive(TTI), First CPU Idle(FCPI) and other metrics which you may have seen using &lt;a href=&quot;https://developers.google.com/web/tools/lighthouse&quot;&gt;Lighthouse&lt;/a&gt; or &lt;a href=&quot;https://www.webpagetest.org&quot;&gt;WebPageTest&lt;/a&gt;. To help measure user&apos;s first impression of your site&apos;s interactivity and responsiveness, a new metric was introduced called First Input Delay.&lt;/p&gt;
&lt;p&gt;First Input Delay (FID) measures the time from when a user first interacts with your site (i.e. when they click a link, tap on a button, or use a custom, JavaScript-powered control) to the time the main thread is free from the long task it is performing, making it possible for the browser to respond to the user’s interaction.&lt;/p&gt;
&lt;p&gt;Is that not the same as TTI you may ask? Well, no it is not. Time to interactive (TTI) measures how long it takes your app to load and become capable of quickly responding to user interactions. On the other hand, First Input Delay (FID) is a metric that measures the delay that users experience when they interact with the page while it’s not yet interactive.&lt;/p&gt;
&lt;p&gt;The browser receives the input when the main thread is busy, so it has to wait until it&apos;s not busy to respond to the input. The time it must wait is the FID value for this user on this page.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/GoogleChromeLabs/first-input-delay&quot;&gt;FID&lt;/a&gt; is a field metric meaning that it can be seen when actual users are really interacting with the web app, while TTI is a lab metric. Field metrics capture a wide spectrum of real-world network conditions and devices used by Chrome users. This can be well measured using Real User Monitoring (RUM) tools like the &lt;a href=&quot;https://developers.google.com/web/tools/chrome-user-experience-report/&quot;&gt;Chrome UX Report&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Server-side rendered JavaScript apps and sites with third-party iframes need to be particular about tracking this metric. They are susceptible to high FID values especially on low-end devices that take longer to parse and execute JavaScript.&lt;/p&gt;
&lt;h2&gt;WebP Image Format&lt;/h2&gt;
&lt;p&gt;Images don&apos;t just become performant on the fly, there are appropriate measures to be put in place to achieve that - using the right format, compression techniques and image lazy-loading. With the introduction of &lt;a href=&quot;https://developers.google.com/speed/webp/&quot;&gt;WebP&lt;/a&gt;, a new image format that results in an average of 30% savings, the cost of serving images (which is the largest component of most sites) is reduced.&lt;/p&gt;
&lt;p&gt;WebP provides superior lossy and lossless compression for images on the web with support for transparency, making the web faster. Due to the fact that WebP is not yet supported across all browsers, it is advisable to use the &lt;picture&gt; element to provide fallbacks. The image format would then be used on supported browsers while web browsers that don’t yet support WebP will use the image in the format they support.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;picture&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;source&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;image/webp&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;srcset&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;imagename.webp&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;source&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;image/jpeg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;srcset&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;imagename.jpeg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;imagename.jpeg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;image description&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;picture&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To compress images to and from the WebP format, &lt;a href=&quot;https://developers.google.com/speed/webp/docs/cwebp&quot;&gt;cwebp&lt;/a&gt; and &lt;a href=&quot;https://developers.google.com/speed/webp/docs/dwebp&quot;&gt;dwebp&lt;/a&gt; command-line tools can be used respectively. Go and try out this image format on &lt;a href=&quot;https://squoosh.app/&quot;&gt;squoosh&lt;/a&gt; (upload your image and view the compression rate).&lt;/p&gt;
&lt;h2&gt;Native Lazy Loading&lt;/h2&gt;
&lt;p&gt;To improve user experience on the web, native lazy-loading will be coming to Chrome. When added to image tags and cross-origin iframes, this defers the loading of the resource until the page is scrolled down near them. It is supported across all chrome platforms — Mac, Windows, Linux, Chrome OS, Android&lt;/p&gt;
&lt;p&gt;To lazy-load resources, use the &lt;code class=&quot;language-text&quot;&gt;lazyload&lt;/code&gt; attribute with “on or off” value. If no value is specified, the browser decides which resource to lazy load.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;imagename.png&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;lazyload&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;on&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Zero Friction Navigation on the Web&lt;/h2&gt;
&lt;p&gt;Navigating on the web has not been seamless compared to the experience with native apps. It is a painful experience, especially when navigating the web using low-end devices on slow networks, leaving users staring at a white screen waiting for content to be displayed on the screen. To come to the rescue of these web users, Chrome engineers announced &lt;strong&gt;Web Packaging and Portals&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Built on the Accelerated Mobile Pages (AMP) model (available on mobile devices only) and achieved through &lt;a href=&quot;https://developers.google.com/web/updates/2018/11/signed-exchanges&quot;&gt;signed exchanges&lt;/a&gt;, &lt;a href=&quot;https://github.com/WICG/webpackage&quot;&gt;Web Packaging&lt;/a&gt; introduces the ability to sign a web page with a special encryption key that proves the page&apos;s original domain. It then creates a package that can be served from anywhere, which will be used by the browser to represent the domain enabling privacy-preserving instant navigations.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/KenjiBaheux/portals&quot;&gt;Portals&lt;/a&gt; work like an iframe but can be navigated into allowing users to transition to the portal&apos;s content. It abstracts navigation between pages making the user feel like they are on a single-page application.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;portal&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;https://mywebsite.com&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;portal&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;When the created view is clicked on, add some animations and trigger the activate event&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;portal&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;activate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The two proposals combined together enable zero-friction page transitions across the web. This is still early in the development stage, and is therefore subject to change.&lt;/p&gt;
&lt;h2&gt;Web.dev&lt;/h2&gt;
&lt;p&gt;A web platform built to help developers learn how to build for the web and ensure the website is meeting good practice goal. &lt;a href=&quot;https://web.dev/&quot;&gt;Web.dev&lt;/a&gt; focuses on why developers need to care about a given concept, and gives tips to help developers build a better web keeping it fast, discoverable, accessible, safe and resilient.&lt;/p&gt;
&lt;h2&gt;VisBug&lt;/h2&gt;
&lt;p&gt;Built with accessibility in mind, &lt;a href=&quot;https://chrome.google.com/webstore/detail/visbug/cdockenadnadldjbbgcallicgledbeoc&quot;&gt;VisBug&lt;/a&gt; is a tool that can come in handy for engineers. With this extension, you can explore and tweak your site right in the browser to view the building blocks and how it looks if designed differently.&lt;/p&gt;
&lt;h2&gt;Squoosh&lt;/h2&gt;
&lt;p&gt;Squoosh is a 15kB JavaScript-driven progressive web application for image compression written in C. It is compiled using &lt;a href=&quot;https://github.com/kripken/emscripten&quot;&gt;emscripten&lt;/a&gt; to web assembly with best-in-class codecs right in the browser.&lt;/p&gt;
&lt;p&gt;Having performance in mind, the team made use of appropriate technologies following coding and performance best practices to yield a performant application:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Preact (a 3kB library) to orchestrate the DOM&lt;/li&gt;
&lt;li&gt;WebPack for bundling and code splitting&lt;/li&gt;
&lt;li&gt;Web workers for lazy loading and concurrency&lt;/li&gt;
&lt;li&gt;Dynamic module imports&lt;/li&gt;
&lt;li&gt;Web components (a lower level primitive used by Polymer) for custom element polyfill on Edge&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As Jake Archibald would say, &lt;a href=&quot;https://squoosh.app/&quot;&gt;go squoosh&lt;/a&gt; some images.&lt;/p&gt;
&lt;h2&gt;Key Points&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Performance decisions should be made based on data. Respect the user, their data and preferences.&lt;/li&gt;
&lt;li&gt;As developers, we need to test using low-end devices on slow network connections because when we develop for the web using fast devices on fast network connections, we can&apos;t really feel what our users feel and think we met our performance goals.&lt;/li&gt;
&lt;li&gt;Performance is not an engineering priority. The success of performance initiatives depends on cross-functional buy-ins. There should be an organizational alignment across all teams that affect the website (marketing, design, engineering etc.).&lt;/li&gt;
&lt;li&gt;Understand how service workers affect the performance of your site. It can affect it positively or negatively depending on the implementation.&lt;/li&gt;
&lt;li&gt;Users value consistent user journey. So, try to reduce friction on your web applications.&lt;/li&gt;
&lt;li&gt;Measure apps using the RAIL model  -  Response, Animation, Idle, and Load.&lt;/li&gt;
&lt;li&gt;Use HEART (Happiness, Engagement, Adoption, Retention, Task Success) framework to determine the quality of your web app UI.&lt;/li&gt;
&lt;li&gt;Some of these announced features covered here and more are behind Chrome flags (chrome://flags)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;This is just a tip of the iceberg, you wouldn&apos;t want to miss the details. The future is on the web and performance is at the root of it all. All recorded sessions throughout the event are available on the &lt;a href=&quot;https://www.youtube.com/playlist?list=PLNYkxOF6rcIDjlCx1PcphPpmf43aKOAdF&quot;&gt;Google Chrome Developers Channel&lt;/a&gt;. The code is available on &lt;a href=&quot;https://github.com/GoogleChromeLabs&quot;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Let&apos;s build a better web 🚀&lt;/p&gt;</content:encoded></item><item><title><![CDATA[ How to Configure your macOS Terminal with Zsh like a Pro]]></title><description><![CDATA[Sometimes, using the default terminal sucks. You want to go out of the ordinary, to add life to the boring terminal and improve your…]]></description><link>https://chiamakaikeanyi.dev/how-to-configure-your-macos-terminal-with-zsh-like-a-pro/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/how-to-configure-your-macos-terminal-with-zsh-like-a-pro/</guid><pubDate>Thu, 15 Nov 2018 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Sometimes, using the default terminal sucks. You want to go out of the ordinary, to add life to the boring terminal and improve your productivity.&lt;/p&gt;
&lt;p&gt;In this walk-through, we will configure iTerm2 with ZSH and its dependencies. This is a no-brainer, and after this, you’ll ponder the reason for not discovering ZSH earlier. Well, since you’re here already, let’s kick-start this.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.zsh.org/&quot;&gt;Z shell&lt;/a&gt; (Zsh) is a Unix shell built on top of bash (the default shell for macOS) with a large number of improvements.&lt;/p&gt;
&lt;h2&gt;Keynotes&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Homebrew installation&lt;/li&gt;
&lt;li&gt;iTerm2 installation&lt;/li&gt;
&lt;li&gt;ZSH and Oh My ZSH installations&lt;/li&gt;
&lt;li&gt;Setting up the dependencies to create a beautiful terminal&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Step 1: Install Homebrew&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://brew.sh/&quot;&gt;Homebrew&lt;/a&gt; is a free and open-source software package management system that simplifies the installation of software on Apple’s macOS.&lt;/p&gt;
&lt;p&gt;Before installing Homebrew, we need to install the CLI tools for Xcode. Open your terminal and run the command:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;xcode-select —-install&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If you get an error, run &lt;code class=&quot;language-text&quot;&gt;xcode-select -r&lt;/code&gt; to reset xcode-select.&lt;/p&gt;
&lt;p&gt;Then, install Homebrew.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;/usr/bin/ruby &lt;span class=&quot;token parameter variable&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/Homebrew/install/master/install&lt;span class=&quot;token variable&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Step 2: Install iTerm2&lt;/h2&gt;
&lt;p&gt;iTerm2 is a replacement for terminal and the successor to iTerm. Most software engineers prefer &lt;a href=&quot;https://www.iterm2.com/&quot;&gt;iTerm2&lt;/a&gt; over the default terminal that ships with macOS as a result of &lt;a href=&quot;https://www.iterm2.com/features.html&quot;&gt;its cool features&lt;/a&gt;. You can integrate zsh into iTerm2 to increase productivity.&lt;/p&gt;
&lt;p&gt;To install iTerm2, run the command:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;brew cask &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; iterm2&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Step 3: Install ZSH&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Zsh is a shell designed for interactive use, although it is also a powerful scripting language.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;By default, macOS ships with zsh located in &lt;code class=&quot;language-text&quot;&gt;/bin/zsh&lt;/code&gt;. Let’s install zsh using brew and make iTerm2 use it.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;brew &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;zsh&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Step 4: Install Oh My Zsh&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;“Oh My Zsh is an open source, community-driven framework for managing your zsh configuration. It will not make you a 10x developer…but you might feel like one”
— Robby Russell&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;It runs on Zsh to provide cool features configurable within the &lt;code class=&quot;language-text&quot;&gt;~/.zhrc&lt;/code&gt; config file. Install &lt;a href=&quot;https://github.com/robbyrussell/oh-my-zsh&quot;&gt;Oh My Zsh&lt;/a&gt; by running the command&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;sh&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh&lt;span class=&quot;token variable&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Check the installed version&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;zsh&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;--version&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can upgrade it to get the latest features it offers.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;upgrade_oh_my_zsh&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Restart iTerm2 to dive into the new experience of using Zsh. Welcome to the “Oh My Zsh” world 😄.&lt;/p&gt;
&lt;p&gt;That’s not all. Now, we will install the dependencies to get the best out of Zsh.&lt;/p&gt;
&lt;h2&gt;Step 5: Change the Default Theme&lt;/h2&gt;
&lt;p&gt;Oh My Zsh comes bundled with a lot of themes. The default theme is robbyrussell, but you can change it to any theme of your choice. In this scenario, I changed it to agnoster, an already pre-installed theme.&lt;/p&gt;
&lt;p&gt;You need to set this theme in your &lt;code class=&quot;language-text&quot;&gt;~/.zshrc&lt;/code&gt; config file. To open the config file (.zshrc), run the command: &lt;code class=&quot;language-text&quot;&gt;nano ~/.zshrc&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Or open the file in a text editor with &lt;code class=&quot;language-text&quot;&gt;open ~/.zshrc&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Set the zsh theme&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;ZSH_THEME&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;agnoster&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;and update your changes &lt;code class=&quot;language-text&quot;&gt;source ~/.zshrc&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;Using a Custom Theme&lt;/h2&gt;
&lt;p&gt;To install another theme not pre-installed, clone the repository into custom/themesdirectory. In this scenario, we’ll install &lt;a href=&quot;https://github.com/bhilburn/powerlevel9k/wiki/Install-Instructions#option-2-install-for-oh-my-zsh&quot;&gt;powerlevel9k&lt;/a&gt;,&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;$ &lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then, select this theme in your .zshrc file&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;ZSH_THEME&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;powerlevel9k/powerlevel9k&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Update your changes by running the command &lt;code class=&quot;language-text&quot;&gt;source ~/.zshrc&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Navigate to &lt;code class=&quot;language-text&quot;&gt;iTerm2 &gt; Preferences &gt; Profiles &gt; Colors&lt;/code&gt; if you wish to change the background color of the terminal.&lt;/p&gt;
&lt;p&gt;The selected theme in this scenario requires powerline fonts. So, let’s install that.&lt;/p&gt;
&lt;h2&gt;Step 6: Install Fonts&lt;/h2&gt;
&lt;p&gt;I will be using &lt;a href=&quot;https://github.com/powerline/fonts/tree/master/Inconsolata&quot;&gt;Inconsolata&lt;/a&gt;. Get your preferred font out of these &lt;a href=&quot;https://github.com/powerline/fonts&quot;&gt;powerline fonts&lt;/a&gt;. Then, download and install it.&lt;/p&gt;
&lt;p&gt;Or download the entire font.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; clone https://github.com/powerline/fonts.git
&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; fonts
./install.sh&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To change the font, navigate to &lt;code class=&quot;language-text&quot;&gt;iTerm2 &gt; Preferences &gt; Profiles &gt; Text &gt; Change Font&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Now, you can see Inconsolata listed as one of the fonts. Select your preferred font. For fonts that support ligatures like &lt;a href=&quot;https://github.com/tonsky/FiraCode&quot;&gt;Fira Code&lt;/a&gt;, check the “Use ligatures” option to view your arrows and other operators in a stylish manner like ( → ).&lt;/p&gt;
&lt;h2&gt;Step 7: Install Color Scheme&lt;/h2&gt;
&lt;p&gt;Let’s change the color scheme to bring out the beauty of our terminal. Navigate to &lt;a href=&quot;https://github.com/mbadolato/iTerm2-Color-Schemes&quot;&gt;iTerm2-Color-Schemes&lt;/a&gt; and download the ZIP folder. Then, extract the downloaded folder cos what we need resides in the schemes folder.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Navigate to the schemes folder and select your preferred color schemes to import them.&lt;/li&gt;
&lt;li&gt;Double-click on a specific color scheme to activate it. In this scenario, I activated Batman. You can choose to activate one of the preloaded color schemes such as Solarized Dark. It is also a good color scheme.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Navigate to &lt;code class=&quot;language-text&quot;&gt;iTerm2 &gt; Preferences &gt; Profile &gt; Colors &gt; Color Presets &gt; Import&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Tada! 🎉 We’re done with the basic settings.&lt;/p&gt;
&lt;h2&gt;Step 8: Install Plugins&lt;/h2&gt;
&lt;p&gt;Oh My ZSH comes preloaded with a git plugin. To add more, for instance, docker, auto-suggestion, syntax highlighting and more:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Clone the Git repository. Let&apos;s add docker plugin.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; clone https://github.com/zsh-users/zsh-docker.git &lt;span class=&quot;token variable&quot;&gt;${ZSH_CUSTOM&lt;span class=&quot;token operator&quot;&gt;:-&lt;/span&gt;~&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;.oh-my-zsh&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;custom}&lt;/span&gt;/plugins/zsh-docker&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Run the command &lt;code class=&quot;language-text&quot;&gt;open ~/.oh-my-zsh&lt;/code&gt; and navigate to &lt;code class=&quot;language-text&quot;&gt;.oh-my-zsh &gt; custom &gt; plugins&lt;/code&gt; directory to view the cloned directory.&lt;/li&gt;
&lt;li&gt;Then, add the plugin to the plugin section of the &lt;code class=&quot;language-text&quot;&gt;~/.zshrc&lt;/code&gt; config file&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;plugins&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt;
  zsh-syntax-highlighting
  zsh-autosuggestions
&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Update your changes by running the command &lt;code class=&quot;language-text&quot;&gt;source ~/.zshrc&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Step 9: Add Aliases&lt;/h2&gt;
&lt;p&gt;Aliases are shortcuts used to reduce the time spent on typing commands. To add aliases to commands you use frequently, navigate to the aliases section within the .zshrc file and add the aliases&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;alias&lt;/span&gt; &lt;span class=&quot;token assign-left variable&quot;&gt;gs&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;git status&quot;&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;alias&lt;/span&gt; &lt;span class=&quot;token assign-left variable&quot;&gt;gp&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;git push&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;For a complete guide on configuring and using aliases, read &lt;a href=&quot;/avoiding-shell-hell-aliases-to-the-rescue/&quot;&gt;my article on Aliases&lt;/a&gt;. You can go a step further to &lt;a href=&quot;/how-to-create-a-custom-message-on-your-terminal/&quot;&gt;create a custom message on your terminal&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If you know about other means of improving productivity using ZSH, you can reach out to me on &lt;a href=&quot;https://twitter.com/chiamakaikeanyi&quot;&gt;Twitter&lt;/a&gt;. I will be glad to hear from you.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Winning with Chrome DevTools: How to Capture Full Page Screenshots]]></title><description><![CDATA[A lot of people are yet to discover the amazing things they can achieve with Google Chrome. Those without the desire to explore do not…]]></description><link>https://chiamakaikeanyi.dev/winning-with-chrome-devtools-how-to-capture-full-page-screenshots/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/winning-with-chrome-devtools-how-to-capture-full-page-screenshots/</guid><pubDate>Thu, 08 Nov 2018 04:00:00 GMT</pubDate><content:encoded>&lt;p&gt;A lot of people are yet to discover the amazing things they can achieve with Google Chrome. Those without the desire to explore do not really know the usefulness of a tool within their reach. To some, Chrome is just a browser, to others, it is a great tool.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Chrome DevTools is a set of web developer tools built directly into the Google Chrome browser.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;With Chrome Developer Tools (DevTools), you can access hidden and experimental settings one of which is discussed in this article.&lt;/p&gt;
&lt;p&gt;Screenshots are very essential for visualization in education, during presentations, technical support etc. There are scenarios where capturing a full page screenshot of a web page is needed and not just the viewport (the visible area of the web page) but achieving this earlier has not been easy. With the introduction of full page screenshot functionality in Chrome DevTools, the stress we usually go through using photo editors to combine different sections of a captured web page has been eliminated.&lt;/p&gt;
&lt;p&gt;Sometime last year, I was in need of capturing a full page screenshot of an online course I took. I spent a good amount of time capturing chunks of it and then combining them using Adobe Photoshop to create the view I wanted. Not long after, Chrome released a new version with the ability to capture full page screenshots. I was happy when I watched &lt;a href=&quot;https://youtu.be/4mx1m7UbBR0&quot;&gt;the video&lt;/a&gt; from the “What’s New” section of Chrome DevTools. At last, I wouldn’t have to spend time combining chunk of captured viewports.&lt;/p&gt;
&lt;p&gt;For this walk-through, I will be using one of the websites I developed — nilezmall.com.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: Nilezmall is currently down. I learned to choose my battle wisely after I was instructed to shut down the site by the client due to maintenance costs.&lt;/p&gt;
&lt;h2&gt;Accessing DevTools&lt;/h2&gt;
&lt;p&gt;To access the DevTools of any web page,&lt;/p&gt;
&lt;p&gt;Launch the Google Chrome browser and open DevTools using any of the methods below:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Using Quick Link: Right-click on any part of the browser and select Inspect option&lt;/li&gt;
&lt;li&gt;Using Chrome Menu: Click Customize and control Google Chrome (the three vertical dots at the top-right corner) &gt; More tools &gt; Developer tools.&lt;/li&gt;
&lt;li&gt;Using the keyboard: Press &lt;kbd&gt;CTRL + SHIFT + I&lt;/kbd&gt; in Windows and Linux environments or &lt;kbd&gt;CMD + OPT + J&lt;/kbd&gt; in a Mac environment.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/access_devtools.png?raw=true&quot; alt=&quot;Accessing Google Chrome developer tools&quot;&gt;&lt;/p&gt;
&lt;h2&gt;Capturing Full Page Screenshots&lt;/h2&gt;
&lt;p&gt;You can capture a full page screenshot using any of these options:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Using command menu or&lt;/li&gt;
&lt;li&gt;By switching to responsive (device) mode&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;1. Using the Command Menu&lt;/h2&gt;
&lt;p&gt;At this stage, your DevTools must have been opened using the steps above to enable you to achieve the desired result with the commands below.&lt;/p&gt;
&lt;p&gt;To access the command menu in Windows and Linux environments, press &lt;kbd&gt;CTRL + SHIFT + P&lt;/kbd&gt;&lt;/p&gt;
&lt;p&gt;In Mac environment, use &lt;kbd&gt;CMD + SHIFT + P&lt;/kbd&gt;&lt;/p&gt;
&lt;p&gt;Then, type &lt;strong&gt;screenshot&lt;/strong&gt; and select &lt;strong&gt;capture full size screenshot&lt;/strong&gt; option.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/command_menu.png?raw=true&quot; alt=&quot;Using the command menu&quot;&gt;&lt;/p&gt;
&lt;h2&gt;2. Using Responsive Mode&lt;/h2&gt;
&lt;p&gt;To switch to responsive or device mode in Windows and Linux environments after opening your DevTools, press&lt;/p&gt;
&lt;p&gt;&lt;kbd&gt;CTRL + SHIFT + M&lt;/kbd&gt;&lt;/p&gt;
&lt;p&gt;In a Mac environment, use&lt;/p&gt;
&lt;p&gt;&lt;kbd&gt;CMD + SHIFT + M&lt;/kbd&gt;&lt;/p&gt;
&lt;p&gt;You can also click on the mobile device icon at the bottom-left corner of the browser.&lt;/p&gt;
&lt;p&gt;Select your preferences (device type, zoom level, orientation etc.). The screenshot captured using this option matches the device dimensions of the emulated phone.&lt;/p&gt;
&lt;p&gt;Click on the &lt;strong&gt;Customize and control Dev Tools&lt;/strong&gt; (the second three vertical dots at the top-right corner) and select &lt;strong&gt;capture full size screenshot&lt;/strong&gt; option&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/responsive_mode.png?raw=true&quot; alt=&quot;Using responsive mode&quot;&gt;&lt;/p&gt;
&lt;p&gt;Voilà, we have successfully captured a full page screenshot with ease.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/chiamakaikeanyi/files/blob/main/full_size_screenshot.png?raw=true&quot; alt=&quot;The web page we captured&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;NB&lt;/code&gt;: Chrome DevTools appears to have a cut off of 16384px in page height for a full screenshot. Firefox seems to go further (at least 18k px)&lt;/p&gt;
&lt;p&gt;If you are a Software Engineer, you may want to check out these useful chrome URLs (chrome://chrome-urls/)&lt;/p&gt;
&lt;p&gt;Explore more features available on &lt;a href=&quot;https://developers.google.com/web/tools/chrome-devtools/&quot;&gt;Google Chrome DevTools&lt;/a&gt; and keep winning.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Why I Blog]]></title><description><![CDATA[Each day, on this road less taken, I learn a lot by reading tech articles, documentations, solving daily challenges faced at work and…]]></description><link>https://chiamakaikeanyi.dev/why-i-blog/</link><guid isPermaLink="false">https://chiamakaikeanyi.dev/why-i-blog/</guid><pubDate>Thu, 01 Nov 2018 06:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Each day, on this road less taken, I learn a lot by reading tech articles, documentations, solving daily challenges faced at work and listening to podcasts from great minds which I rarely document.&lt;/p&gt;
&lt;p&gt;I&apos;ve learnt that writing improves one&apos;s thought process through research and documentation and helps to reinforce one&apos;s knowledge. Over time, I&apos;ve also learnt that the adage&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;What will be will be&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;does not apply to all scenarios. A better adage would be,&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;What we want to be, we make it be.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I also love this quote by Steve Jobs,&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Your time is limited, so don’t waste it living someone else’s life. Don’t be trapped by dogma — which is living with the results of other people’s thinking. Don’t let the noise of others’ opinions drown out your own inner voice. And most important, have the courage to follow your heart and intuition. They somehow already know what you truly want to become. Everything else is secondary.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Sequel to this, I have finally chosen to start this blog, an intellectual journal. Each time I type &lt;code class=&quot;language-text&quot;&gt;git push&lt;/code&gt; and hit the &lt;kbd&gt;Enter&lt;/kbd&gt; key letting the CI build pass, I let my thoughts out to the world to be read by probably a lot of people.&lt;/p&gt;
&lt;p&gt;I hope to become more disciplined on this journey and grow to become who I really want to be and help lives, one at a time.&lt;/p&gt;
&lt;p&gt;Wondering who I am?&lt;/p&gt;
&lt;p&gt;I&apos;m &lt;a href=&quot;/&quot;&gt;Chiamaka&lt;/a&gt; which means &lt;em&gt;&quot;God is beautiful&quot;&lt;/em&gt;, a Software Engineer building usable products in the city that never sleeps - Lagos, Nigeria.&lt;/p&gt;</content:encoded></item></channel></rss>