<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: KyleFontenot</title>
    <description>The latest articles on DEV Community by KyleFontenot (@kylefontenot).</description>
    <link>https://dev.to/kylefontenot</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F620849%2Fb6dbef00-8321-4cb3-b757-1a023a8a37b8.jpeg</url>
      <title>DEV Community: KyleFontenot</title>
      <link>https://dev.to/kylefontenot</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kylefontenot"/>
    <language>en</language>
    <item>
      <title>Astro is awesome</title>
      <dc:creator>KyleFontenot</dc:creator>
      <pubDate>Fri, 05 Aug 2022 02:18:45 +0000</pubDate>
      <link>https://dev.to/kylefontenot/astro-is-awesome-38cl</link>
      <guid>https://dev.to/kylefontenot/astro-is-awesome-38cl</guid>
      <description>&lt;p&gt;Astro is my daily driver for creating websites in my freelance web development business, and I wanted to highlight the tool for anyone unfamiliar, and also to get readers acquainted easily to the code. I will have a second blog post on the usage: here.&lt;/p&gt;

&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://astro.build/" rel="noopener noreferrer"&gt;Astro&lt;/a&gt; is a really lovely, well-thought-out framework for creating websites with little to no Javascript client-side. It uses Vite under the hood, with all the yummy features like CSS Modules, easy PostCSS, static route generation, and built-in SCSS. Astro is primarily a static-site framework because it builds everything into static assets to be served. The Astro team is leveraging a lot of SSR capabilities to not only optimize page load speeds but for using a full SSR implementation (in beta as of writing this).&lt;/p&gt;

&lt;p&gt;It enables an "islands" approach to each component; each component created by default doesn't have any Javascript attached to it, forcing the developer to opt-in each component that needs some client-side code. When developers opt-in for JS, they have their own option for using a JS framework like React, Vue, Svelte, SolidJS, or just Vanilla with just a simple renderer installation with a CLI command like: &lt;code&gt;astro add react&lt;/code&gt;. &lt;/p&gt;

&lt;h3&gt;
  
  
  Quick Background
&lt;/h3&gt;

&lt;p&gt;I took up Astro the instant I discovered and read what makes it unique, because it fit into my development really well. Gatsby initially fulfilled this role of static-site generation for my small business clients, but discovering Svelte and SolidJS broke the React paradigm for me. By offering all modern capabilities of a major framework such as Gatsby (with the exception of the beta SSR), but with barely any runtime JS and a ton of flexibility. SolidJS is essentially what drove me to Astro, as it was one of the only ways of creating a MPA using SolidJS (at the time). &lt;/p&gt;

&lt;h2&gt;
  
  
  Page Load Comparison To NextJS
&lt;/h2&gt;

&lt;p&gt;Astro mentions its benefits on its documentation site, but it's better to see a direct example for the statistics. I created the exact same basic website using NextJS and Astro. Here is the example website with each corresponding Lighthouse score. &lt;/p&gt;

&lt;p&gt;For the purposes of consistency, I used the Image component per designated framework as an obstacle for page load, a simple external SCSS stylesheet import, and the SolidJS renderer installed for Astro. With the SolidJS renderer in Astro, anyone can literally do anything React is able to do (there's always vanilla, but just for React-fans).&lt;br&gt;
For consistency, both websites are created:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;From templates taken directly from each framework's official documentation website. &lt;/li&gt;
&lt;li&gt;With Lighthouse audits executed on a Chrome private window to remove possiblities of extensions interacting.&lt;/li&gt;
&lt;li&gt;With a cleared cache every test. &lt;/li&gt;
&lt;li&gt;Using CSS Modules and Sass.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frjhjd0201xdloq7kydwa.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frjhjd0201xdloq7kydwa.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Out of the box, it's a bit surprising that such a simple website with only semantic HTML elements, and a dynamically presented image can show such a stark difference with frameworks (and let's not mention how we have to clarify a &lt;code&gt;_document.js&lt;/code&gt; file for &lt;code&gt;lang="en"&lt;/code&gt; for NextJS). With a previous project of mine, I used NextJS because it simply scored better in Lighthouse, being a more mature framework. But just as Astro surmises on their documentation site, it's all about content. And clearly, Google is heading in the same direction. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxcbb6m87ssy3ys2er713.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxcbb6m87ssy3ys2er713.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's crazy.&lt;/p&gt;

&lt;p&gt;The circled scores above are the most pivotal stats: Astro scoring and average ascore of 98ms, versus NextJS scoring values between 600 and 1000ms. Even viewing the amount of resources used for such a basic site is pretty shocking. Two big factors affecting these are React itself in the bundle, but perhaps Vite as well. Webpack looks remarkably sluggish compared to newer HMR bundlers. And speaking of bundlers, this Astro site would probably take around 6 seconds to build, costing the developers and clients even less for hosting.&lt;/p&gt;
&lt;h3&gt;
  
  
  Routing Patterns
&lt;/h3&gt;

&lt;p&gt;Astro, like many modern frameworks nowadays, have a static file route option for easily creating pages. In the &lt;code&gt;/src/pages/&lt;/code&gt; folder, each &lt;code&gt;.astro&lt;/code&gt; and &lt;code&gt;.md&lt;/code&gt; file is automatically created into a page. For anyone familiar with NextJS's approach to this, it is exactly the same, particularly with dynamic routing using syntax like &lt;code&gt;[blogPost].astro&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;One perspective Astro takes, is clarifying &lt;code&gt;layouts&lt;/code&gt; for use of pages. It's essentially just parent components that receive children components, and typically span or inherit the &lt;code&gt;html&lt;/code&gt;, and &lt;code&gt;head&lt;/code&gt; tags. NextJS's equivalent is a very special and particular approach by using proprietary &lt;code&gt;&amp;lt;Head/&amp;gt;&lt;/code&gt; and &lt;code&gt;_document.js&lt;/code&gt; tools to optimize its page load. Astro proves, if you keep it simple with great tools, these types of workarounds aren't necessary. In Astro, keep your &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; tags as they should be, and nest your components like you normally would. &lt;/p&gt;
&lt;h3&gt;
  
  
  Styling
&lt;/h3&gt;

&lt;p&gt;CSS modules are natively supported in Astro, and are a great option for building, but Astro also has a built-in &lt;code&gt;style&lt;/code&gt; method that assesses CSS from within a &lt;code&gt;style&lt;/code&gt; tag inside the Astro component it belongs to. This style below is only applied to this specific component. There is a method of making this global if you need to though. Here's the example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;button class="special"&amp;gt;Button&amp;lt;/button&amp;gt;
&amp;lt;style&amp;gt;
  .special {
    outline: 5px solid blue;
  }
&amp;lt;/style&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Ease
&lt;/h3&gt;

&lt;p&gt;Astro's team has offered really handy CLI tools for perpetuating their integrations idea of Astro's. Integrations are pretty much the same as any other frameworks' "plugin" system, with just a &lt;code&gt;yarn astro ___&lt;/code&gt; command. The integrations make it extremely easy to install Tailwind, SolidJS, native SSR tools, and more. I see this as very similar to Gatsby's plugin system, especially when/if the ecosystem expands in the future. &lt;/p&gt;

&lt;h3&gt;
  
  
  Misc. Built-In Tools
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Markdown

&lt;ul&gt;
&lt;li&gt;Out of the box, Astro natively supports Markdown, with even MDX-like capabilities for placing in custom components. &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;RSS support&lt;/li&gt;

&lt;li&gt;A flexible Code component with tons of language support&lt;/li&gt;

&lt;li&gt;Powerful directive configurations for finely splitting code.&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://docs.astro.build/en/getting-started/" rel="noopener noreferrer"&gt;Check out the official Astro docs for more!&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'm planning on making an Astro primer article next for to make it easy for someone to jump in!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Bionic Reading and "mini-library" for it</title>
      <dc:creator>KyleFontenot</dc:creator>
      <pubDate>Fri, 08 Jul 2022 00:12:23 +0000</pubDate>
      <link>https://dev.to/kylefontenot/bionic-reading-and-mini-library-for-it-ndn</link>
      <guid>https://dev.to/kylefontenot/bionic-reading-and-mini-library-for-it-ndn</guid>
      <description>&lt;p&gt;&lt;a href="https://bionic-reading.com/" rel="noopener noreferrer"&gt;Bionic reading&lt;/a&gt; is a really interesting idea of improving readability –especially with dyslexic readers– by emphasizing the beginning letter(s) of each word of a paragraph.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgwatc2sdes5bcqexcz1y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgwatc2sdes5bcqexcz1y.png" alt="Screenshot of bionic reading in use on a lorem ipsum paragraph"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's a fascinating concept that can be used for many reading uses, and it seems like something that many people may prefer. The official website advertises an official API and a few other tools for enabling and mutating blocks of text into a "bionic"-style, but I wanted to explore implementing something like this simply with Javascript. I searched NPM for something similar, but with no solid results.&lt;/p&gt;

&lt;p&gt;So I made a mini library for myself. &lt;/p&gt;

&lt;h2&gt;
  
  
  Obstacles
&lt;/h2&gt;

&lt;p&gt;My qualifications for it was to create a drop and go function or class like most JS libraries that would affect all paragraphs(or specified selector or class) of text on the HTML document. There's quite a few obstacles to consider in this particular idea:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How would I be able to isolate only the first letters of each word while still retaining the inline, static dimensions of the original paragraph?&lt;/li&gt;
&lt;li&gt;How would I stylize a way for the emphasized letters to be exactly the same font, almost like an outline, that is  1 pixel at most wider than the original font?&lt;/li&gt;
&lt;li&gt;Do I implement this with CSS or some way with Javascript that will perfectly outline a font shape?&lt;/li&gt;
&lt;li&gt; Are pseudo elements an option?&lt;/li&gt;
&lt;li&gt;If I were to use CSS, what would be the best property to use?

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;text-shadow&lt;/code&gt;?&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;font-weight&lt;/code&gt;?&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;transform: translate()&lt;/code&gt;?&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;How would web crawlers understand?&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  My Solution
&lt;/h2&gt;

&lt;p&gt;I came to my solution that uses CSS's &lt;code&gt;text-shadow&lt;/code&gt; and the Shadow DOM to create a distinction between the original light DOM content and the specifically styled bionic node attached as a child. I chose &lt;code&gt;text-shadow&lt;/code&gt; as a default because it is the most likely to not be used and changed externally (since the shadow DOM is &lt;code&gt;open&lt;/code&gt; for flexibility)., and because&lt;code&gt;text-shadow&lt;/code&gt; also keeps the exact fidelity of the font used. Also text-shadow doesn't rely on the availability of a bolder font weight loaded.&lt;/p&gt;

&lt;p&gt;This would still show indexable to web crawlers, but because of the requirement on keeping the added outline exactly the same as the computed font, it would be much harder, if not impossible to add in a shape without adding an HTML node. The shadow DOM at least creates the distinction, readable to devs, while still unaffecting the "light DOM" node's indexability.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Bionic&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;HTMLParagraphElement&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;elem&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;root&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;bionic-reading&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;shadow&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;attachShadow&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;open&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;paragraph&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;bionic-reading&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;elemStyle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getComputedStyle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;elem&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nx"&gt;paragraph&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;elemStyle&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;paragraph&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;elem&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;classList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;bionic&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;paragraph&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;classList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;bionic&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;style&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`
      .bionic {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
      }
    `&lt;/span&gt;
    &lt;span class="nx"&gt;elem&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;position&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;relative&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;color&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;transparent&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;paragraph&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;margin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;0&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="nx"&gt;paragraph&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;paragraph&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt; &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;word&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;`&amp;lt;span style="text-shadow:-2px 0 0 &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;elemStyle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;;"&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;word&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;/span&amp;gt;`&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;word&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;substring&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt; &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nx"&gt;shadow&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appendChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nx"&gt;shadow&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appendChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;paragraph&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;root&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;bionic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;selector&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;p&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
  &lt;span class="nx"&gt;customElements&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;define&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;bionic-reading&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Bionic&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;extends&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;selector&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelectorAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;selector&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;elem&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;bionic&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Bionic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;elem&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;elem&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;parentNode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;insertBefore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bionic&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;elem&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;nextSibling&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;elem&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appendChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bionic&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;bionic&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Essentially, it creates a child Shadow DOM, adds in an absolutely positioned clone of the light DOM node, and then injects a &lt;code&gt;span&lt;/code&gt; that creates a &lt;code&gt;text-shadow&lt;/code&gt; for every first letter of each word. Styles from the light DOM are inherited for the sake of keeping text-based styles like letter-spacing and color consist so that the emphasized letters line up perfectly. &lt;br&gt;
It requires the light DOM node to be relatively positioned (which shouldn't make a difference from &lt;code&gt;static&lt;/code&gt; in how we normally use semantic paragraphs anyways).&lt;/p&gt;

&lt;p&gt;If I expand this tool potentially into an NPM package, I can easily allow for a few option parameters such as the  &lt;code&gt;property&lt;/code&gt; value that changes the CSS property used (&lt;code&gt;'text-shadow' | 'transform' | 'filter' | font-weight&lt;/code&gt; ), heaviness, letter padding, HTML and/or class selector. &lt;/p&gt;

&lt;p&gt;Let me know what you think!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>usability</category>
      <category>showdev</category>
    </item>
    <item>
      <title>My Vim config opinions and suggestions</title>
      <dc:creator>KyleFontenot</dc:creator>
      <pubDate>Mon, 04 Jul 2022 16:55:28 +0000</pubDate>
      <link>https://dev.to/kylefontenot/my-vim-config-opinions-and-suggestions-14ki</link>
      <guid>https://dev.to/kylefontenot/my-vim-config-opinions-and-suggestions-14ki</guid>
      <description>&lt;h2&gt;
  
  
  Vim is awesome. And config files are half the fun!
&lt;/h2&gt;

&lt;p&gt;For about two years, I've known about Vim and it's notoriety in both the developer community and the Linux community for being quicker, more expressive, and even a more native way of manipulating text. It was one of those things that I admired, knowing that once I took the dive, that I would never look back. &lt;br&gt;
The possibilities are endless when it comes to Vim's and Neovim's config files, especially when accounting for the huge world of plugins available out there. &lt;br&gt;
For a brief history, Wikipedia's entries on Vi and Vim show a good glance on the background of these programs: &lt;a href="https://en.wikipedia.org/wiki/Vim_(text_editor)"&gt;Vim&lt;/a&gt;. Vim was officially established in November 1991, so it's only a year younger than I! It's parent program it was derived from, Vi, was established near 1978! Besides it's historical significance, Vim has been automatically included in all Unix machines and will continue to be in the future, making it one of the most prevalent programs ever. &lt;/p&gt;

&lt;p&gt;I wanted to share my Vim config and opinions on a setup to maybe persuade the common pillars of usage with Vim. I host in on a Github gist at the moment of this writing, and can be found here: &lt;a href="https://gist.github.com/KyleFontenot/eb02222055be8402152abe681fc89814"&gt;my init.vim on GitHub&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  The characters: 0 and -
&lt;/h3&gt;

&lt;p&gt;In Vim, &lt;code&gt;0&lt;/code&gt; (the key for zero next to 9) is a very commonly used key for moving to the &lt;strong&gt;beginning&lt;/strong&gt; of the line of your cursor. Inversely, the character &lt;code&gt;$&lt;/code&gt; is the key to move to the &lt;strong&gt;end&lt;/strong&gt; of the line of your cursor. These are super handy to use, but why is the key to move rightward six keys to the left of the key to move the left most?&lt;/p&gt;


  4&lt;span&gt;$&lt;/span&gt;&lt;span&gt;This moves to the right-most. Why?&lt;/span&gt;
  5&lt;span&gt;%&lt;/span&gt;
  6&lt;span&gt;^&lt;/span&gt;
  7&lt;span&gt;&amp;amp;&lt;/span&gt;
  8&lt;span&gt;*&lt;/span&gt;
  9&lt;span&gt;(&lt;/span&gt;
  0&lt;span&gt;)&lt;/span&gt;&lt;span&gt;This moves to the left-most.&lt;/span&gt;
  -&lt;span&gt;_&lt;/span&gt;


&lt;p&gt;So there must be a use for the character `-`, the key just adjacent to the right of `0` right? Well, not really. I can't seem to find anything of use on this key, but there must be reason for this. Perhaps it is one of the many small nuances in Vim that seem funky to modern keyboards because of the way keyboards have changed since 1978. One example of this nuance is why the directional movement keys are &lt;code&gt;h, j, k, and l&lt;/code&gt; instead of &lt;code&gt;j, k, l, and ;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I can't seem to find anything except for tradition for why the &lt;code&gt;end-of-line&lt;/code&gt; command shouldn't be the &lt;code&gt;-&lt;/code&gt; key. Could be becuase of a change in keyboard layout historically as well. But to update your Vim to modern keyboards,tTry it, and never look back. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Map &lt;code&gt;$&lt;/code&gt; to &lt;code&gt;-&lt;/code&gt; for obvious left-orientation and ease of finger placement&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The config line would look something as simple as bellow. We use &lt;code&gt;map&lt;/code&gt; instead of &lt;code&gt;noremap&lt;/code&gt; because we want the &lt;code&gt;-&lt;/code&gt; key to persistent into other commands that would involve &lt;code&gt;$&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;map $ -
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  jj and/or jk
&lt;/h3&gt;

&lt;p&gt;Now this is an extremely common configuration amongst Vim users. For anyone unfamiliar with &lt;code&gt;jj&lt;/code&gt; or &lt;code&gt;jk&lt;/code&gt; and know at least some Vim; mapping &lt;code&gt;jj&lt;/code&gt; and &lt;code&gt;jk&lt;/code&gt; to &lt;code&gt;Escape&lt;/code&gt; allows the typer to exit insert mode into normal mode without having to leave the homekeys. This is essential for me, especially because sometimes I use my 2017 Macbook Pro that has a touchbar. Having zero physical feedback for the &lt;code&gt;escape&lt;/code&gt; key is worse than scratching a chalkboard. Scratching chalkboards got nothin' on me.&lt;/p&gt;

&lt;p&gt;What makes &lt;code&gt;jj&lt;/code&gt; and &lt;code&gt;jk&lt;/code&gt; usable in insert mode is because they aren't an occuring combination of letters in the english language. Well, in my normal flow when focusing on keyboard only, I often do a double &lt;code&gt;h&lt;/code&gt; or a double &lt;code&gt;k&lt;/code&gt; for when my fingers aren't aligned to the home row. So I was started pondering why wouldn't someone add in these binds as well? Unless you're typing in the word 'bukkake'... you should be fine.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;inoremap &amp;lt;silent&amp;gt; hh &amp;lt;Esc&amp;gt;
inoremap &amp;lt;silent&amp;gt; kk &amp;lt;Esc&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  d and x keys
&lt;/h3&gt;

&lt;p&gt;So every Vim user knows &lt;code&gt;d&lt;/code&gt; and &lt;code&gt;x&lt;/code&gt;. &lt;code&gt;d&lt;/code&gt; is for &lt;strong&gt;d&lt;/strong&gt;eleting, or more specifically cutting, which goes into a register. Well, I thought it was a little peculiar that &lt;code&gt;d&lt;/code&gt; not only deletes, but cuts, while &lt;code&gt;x&lt;/code&gt; only deletes one character. &lt;code&gt;x&lt;/code&gt; has a use, but it's quite niche compared to modern text editing. So my suggestion is to change &lt;code&gt;x&lt;/code&gt; almost entirely. &lt;/p&gt;

&lt;p&gt;Since &lt;code&gt;Ctrl-x&lt;/code&gt; or &lt;code&gt;Cmd-x&lt;/code&gt; is typically used for cutting system-wide in default operating systems, it makes the most sense to change &lt;code&gt;x&lt;/code&gt; to the previous functionality as &lt;code&gt;d&lt;/code&gt; whereas it &lt;strong&gt;cuts&lt;/strong&gt;. &lt;br&gt;
So here is a snippet of my &lt;code&gt;init.vim&lt;/code&gt; for how I rearranged these:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nnoremap d "0d
nnoremap x "*d
vnoremap d "0d
vnoremap x "*d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;d&lt;/code&gt; &lt;strong&gt;deletes&lt;/strong&gt;, and when you want to &lt;strong&gt;cut&lt;/strong&gt;, use &lt;code&gt;x&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;There is a caveat with changing this. We're changing &lt;code&gt;x&lt;/code&gt; to act just like &lt;code&gt;d&lt;/code&gt; would, meaning it requires an operator (like in a verb-object way like kakoune explains). So something like &lt;code&gt;xiw&lt;/code&gt; works to cut the word under the cursor. Because of this, to delete a single character (the old default &lt;code&gt;x&lt;/code&gt; keybind), you can type &lt;code&gt;dl&lt;/code&gt;. To cut a single character, it would be &lt;code&gt;xl&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;l&lt;/code&gt; is the default object for a &lt;strong&gt;letter&lt;/strong&gt; in Vim. Taking this into account, I like to bind &lt;code&gt;c&lt;/code&gt; in my operator mode to alias the &lt;code&gt;l&lt;/code&gt; key, since &lt;code&gt;c&lt;/code&gt; makes more sense for &lt;strong&gt;character&lt;/strong&gt; more than &lt;strong&gt;letter&lt;/strong&gt;, plus &lt;code&gt;c&lt;/code&gt; on the keyboard is adjacent to both &lt;code&gt;d&lt;/code&gt; and &lt;code&gt;x&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;onoremap c l
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That makes it really simple to &lt;code&gt;dc&lt;/code&gt; or (&lt;strong&gt;delete character&lt;/strong&gt;).&lt;/p&gt;




&lt;h2&gt;
  
  
  June 16: update
&lt;/h2&gt;

&lt;p&gt;Turns out, there is a very easy Vim plugin to do exactly what I outline with &lt;code&gt;d&lt;/code&gt;and &lt;code&gt;x&lt;/code&gt; called &lt;a href="https://github.com/svermeulen/vim-cutlass"&gt; Vim-Cutlass &lt;/a&gt; &lt;br&gt;
In addition, I converted my &lt;code&gt;init.vim&lt;/code&gt; file to it's own git repository. I had seen others I follow on Github use gists as an easy&lt;br&gt;
publication of their vim config, but I find that using a git repository for this helps tremendously becasuse of the occasional update,&lt;br&gt;
and also for easier redundancy across different computers that I use. &lt;/p&gt;
&lt;h3&gt;
  
  
  Vimium
&lt;/h3&gt;

&lt;p&gt;Also if you're a Vim user, you're most likely using the Vimium extension in your browser for simple navigation. Vimium is fantastic, and just works intuitively (check it out if you haven't). The default keybindings for Vimium has the handy keybinds for &lt;code&gt;d&lt;/code&gt; for the Vim equivalent of &lt;code&gt;&amp;lt;C-d&amp;gt;&lt;/code&gt; (Or &lt;code&gt;Ctrl-d&lt;/code&gt;)for moving the page down, and also &lt;code&gt;u&lt;/code&gt; for the same thing appropriately for moving a page up. My proposed keybinding is setting &lt;code&gt;e&lt;/code&gt; to the same behavior as &lt;code&gt;u&lt;/code&gt; in Vimium so that you're using the same hand and same finger for scrolling up and down the page. Setting &lt;code&gt;e&lt;/code&gt; doesn't interfere with any other binding and can be done easily in Vimium's settings. In Chrome-based browsers, that is in Settings &amp;gt; Extensions &amp;gt; Vimium &amp;gt; Extensions settings, and then you can paste in:&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;map e scrollPageUp&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Vimium's syntax is different from Vim's scripting, so no need for &lt;code&gt;n&lt;/code&gt; before &lt;code&gt;map&lt;/code&gt; or &lt;code&gt;nore&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>vim</category>
    </item>
    <item>
      <title>Another small Javascript Tidbit for enforcing a number</title>
      <dc:creator>KyleFontenot</dc:creator>
      <pubDate>Sun, 26 Jun 2022 18:23:18 +0000</pubDate>
      <link>https://dev.to/kylefontenot/another-small-javascript-tidbit-for-enforcing-a-number-3cm4</link>
      <guid>https://dev.to/kylefontenot/another-small-javascript-tidbit-for-enforcing-a-number-3cm4</guid>
      <description>&lt;p&gt;As I'm getting grasps with Typescript, I watched a really great &lt;a href="https://www.youtube.com/c/Academind"&gt;Youtube tutorial video by Academind (Maximilian) &lt;/a&gt; that ran through tons of details on Typescript. In the video, he shows the difference between Typescript and the transpiled Javascript generated which shows a pretty great syntax tool.&lt;/p&gt;

&lt;blockquote&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;...
const something = "5";
    &amp;gt; return +something
    &amp;gt; ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/blockquote&gt;

&lt;p&gt;The &lt;code&gt;+&lt;/code&gt; character right before a variable is a way to enforce a number type! In Javascript, literal strings have become completely second-nature to most developers, and one use of it is to enforce a string by using interpolation. This &lt;code&gt;+&lt;/code&gt; method is a really nice concise way of filtering a variable for numbers. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;+&lt;/code&gt; character before numbers assigns a positive values (and &lt;code&gt;-&lt;/code&gt; for negative), so for a dynamic language like Javascript, it's assuming and enforcing the variable as a number under the hood. &lt;/p&gt;

&lt;p&gt;This is the first time that I've seen an instance of this syntax used. Good stuff&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>Not A Beginner Ternary Statement</title>
      <dc:creator>KyleFontenot</dc:creator>
      <pubDate>Sat, 25 Jun 2022 23:50:36 +0000</pubDate>
      <link>https://dev.to/kylefontenot/not-a-beginner-ternary-statement-74e</link>
      <guid>https://dev.to/kylefontenot/not-a-beginner-ternary-statement-74e</guid>
      <description>&lt;p&gt;I've begun planning a JS library that I hope that would be published on NPM. As a self-taught programmer, I'm continually learning that observing other peoples' code is incredibly important. As I take notes for similar JS libraries to inspire me, I stumbled on this interesting line of Javascript.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;debug = typeof value === 'boolean' ? value : debug&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Here's the function scope for full context:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;defineProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ScrollReveal&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;debug&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;debug&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;set&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;debug&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;boolean&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;debug&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I use ternary statements constantly in my freelance web development, but the beginning part of the line is very interesting, as I've never seen this type of assignment/destructing in a ternary before. I didn't know that it was a thing, and it's brilliant. &lt;/p&gt;

&lt;p&gt;Left-to-right, the setter is returning (like all ternaries do) a value, but what makes this different is the &lt;code&gt;debug =&lt;/code&gt; part, which is assigning &lt;code&gt;typeof value&lt;/code&gt; to the lexical variable: &lt;code&gt;debug&lt;/code&gt;. So, when using this setter function, if the parameter isn't a boolean, it makes a small referential loop to &lt;code&gt;debug&lt;/code&gt;, which is whatever type the parameter is. &lt;/p&gt;

&lt;p&gt;I see this being useful for more concisely skipping type clauses in functions, but for when approaching an interface in a negating direction (instead of adding allowed types like &lt;code&gt;string | boolean&lt;/code&gt;). If you want to make a type by remove types from &lt;code&gt;any&lt;/code&gt;(in JS instead of Typescript world), perhaps this is a nice clean way of doing that. &lt;/p&gt;

&lt;p&gt;The beauty of Javascript (or just any programming): You'll always learn more.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
