<?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: steviepee</title>
    <description>The latest articles on DEV Community by steviepee (@steviepee).</description>
    <link>https://dev.to/steviepee</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%2F1907364%2F046d7d35-628e-4234-a409-0897ae50a321.jpeg</url>
      <title>DEV Community: steviepee</title>
      <link>https://dev.to/steviepee</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/steviepee"/>
    <language>en</language>
    <item>
      <title>We love to see it: A look at AR</title>
      <dc:creator>steviepee</dc:creator>
      <pubDate>Mon, 14 Apr 2025 13:59:32 +0000</pubDate>
      <link>https://dev.to/steviepee/we-love-to-see-it-a-look-at-ar-29o4</link>
      <guid>https://dev.to/steviepee/we-love-to-see-it-a-look-at-ar-29o4</guid>
      <description>&lt;h2&gt;
  
  
  The Desert Of The Real
&lt;/h2&gt;

&lt;p&gt;First, let's take mention of the elephant in the room (talking about AR, there truly could be one in here): Are AR and VR the same thing. The answer is yes, if you think scuba-diving is (metaphorically) the same as snorkeling.&lt;br&gt;
VR is like scuba diving in that it's fully immersive. You suit your whole body up and plunge into the depths. In non-metaphorical terms, its equipment and package focuses on replacing as much of the real world as possible with its digital environment. If you've ever seen those videos of people running into walls or accidentally punching a friend or family member whilst wearing an Oculus, this, my friend, is VR. &lt;br&gt;
AR, on the other hand, keeps most of the real world and adds a nice tweak here and there, in some ways, it can make the real world a little more immersive. Much like snorkeling, where you use the regular air at your disposal, usually, a part of your body is out of the water, and you get to  experience the beauty of the waters while keeping your link to the land. AR &lt;em&gt;augments&lt;/em&gt; a real environment and overlays it with digital elements. A good example of this  is, well, an elephant in the room. Or a &lt;em&gt;Picachu&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fn44zigmlil4wco3nt9vq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fn44zigmlil4wco3nt9vq.png" alt="Image description" width="704" height="345"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The beginnings of AR were not as whimsical as catchin' them all. AR all started (heavily debatably) in 1992, when Louis Rosenburg's Virtual Fixtures were developed as digitally prehistoric flight simulators to aid USAF pilots. It sounds (and admittedly looks) like VR, but it's not. They did, however, require a full upper-body exoskeleton. As visuals are concerned, you can see the AR in it: binocular magnifiers that interacted with virtual &lt;strong&gt;overlays&lt;/strong&gt; to place robotic arms where the pilots arms actually were&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fxvc02c5s325qkm0pzo60.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fxvc02c5s325qkm0pzo60.png" alt="Image description" width="800" height="607"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AR started to take more of the real world spotlight over the next few years. In 1994, AR was used in the theatre production, &lt;em&gt;Dancing in Cyberspace&lt;/em&gt;, and, in 1998, history was made again when SportsVision developed and displayed their virtual 1st and Ten systems for the NFL. On-screen sports entertainment has never been the same since:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fu5rfyodq8ugzqhf72hu0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fu5rfyodq8ugzqhf72hu0.png" alt="Image description" width="690" height="461"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From there, the technology built more behind the scenes, making a triumphant return in 2016 with the spectacularly viral and afore-alluded-to Pokemon Go.&lt;br&gt;
This mobile game took advantage of the advanced displays and tracking technology in our now every day phones, and set them to work creating a world where a player can catch pokemon and battle with then in real life environments. Since then, AR has been used from everything furniture placement to surgery assistance and training, and to classes around the world to facilitate immersive learning! But that's enough about what AR is, let's talk a little about how AR works:&lt;/p&gt;

&lt;h2&gt;
  
  
  Lights
&lt;/h2&gt;

&lt;p&gt;Or, in this case, I suppose I mean markers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cameras
&lt;/h2&gt;

&lt;p&gt;Now that we have the environment set up(or we have what we need to continuously set it up), we need something to Capture the images coming into the screen. We can't have an overlay without the underlying world to... lay it over, so AR requires the use of a camera object to render on top of. That's becoming increasingly easy to provide in an immersive fashion, though. Of course, we have our phones, but now there are many wearable technologies that could provide the optical assistance we need.. speaking of optical assistance, Glasses for one! There are a good few smart glasses being implemented by Rayban, Apple, and Reydar.&lt;/p&gt;

&lt;p&gt;references:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://codeit.us/blog/how-to-create-an-augmented-reality-app" rel="noopener noreferrer"&gt;https://codeit.us/blog/how-to-create-an-augmented-reality-app&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.apple.com/design/human-interface-guidelines/augmented-reality" rel="noopener noreferrer"&gt;https://developer.apple.com/design/human-interface-guidelines/augmented-reality&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.reydar.com/ultimate-guide-what-is-augmented-reality-ar/#what-is-augmented-reality" rel="noopener noreferrer"&gt;https://www.reydar.com/ultimate-guide-what-is-augmented-reality-ar/#what-is-augmented-reality&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Grind a little deeper: more Java, please!</title>
      <dc:creator>steviepee</dc:creator>
      <pubDate>Mon, 31 Mar 2025 13:55:31 +0000</pubDate>
      <link>https://dev.to/steviepee/grind-a-little-deeper-more-java-please-4mf9</link>
      <guid>https://dev.to/steviepee/grind-a-little-deeper-more-java-please-4mf9</guid>
      <description>&lt;p&gt;Last time, we took in a little hit of Java, just to see if we liked the taste. We checked out the basics and got a sniff of what the Hello World under Java had to offer. I don't know about you, but I could go for another taste! So, if you're up for it, let's grind a bit deeper, get under the grounds, and get into more of what makes Java, Java.&lt;/p&gt;

&lt;h2&gt;
  
  
  Recap
&lt;/h2&gt;

&lt;p&gt;In the last entry, we went through the basics and came out with a simple "Hello World" in the Java language:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SayHello&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="c1"&gt;//I'm using println instead of print so we move to the next line after&lt;/span&gt;
    &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello World!"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This solidified the mainstays of Java for us: The making of classes, object specification, class types, datatypes, one special function-return type, and the world Java navigates to log (or, in this case, print out) a simple phrase. All of this is very important. It's the java of Java, but having a cup of Joe is more than just the Joe. In true Java fashion, we need to take all parts into consideration. In coffee terms, the first question could be, &lt;em&gt;"Now that I've made the coffee, how can I bring it to the table?"&lt;/em&gt; It's a simple and often overlooked question for most, and, if we're used to interpretive languages like JavaScript, it's the kind of question we'd tend to ignore altogether. It's a very important quandary, though, and one that Java keeps in mind with each creation. The answer, of course, is a cup. As Java goes, this "cup" is referred to as a compiler&lt;/p&gt;

&lt;h2&gt;
  
  
  Compiling
&lt;/h2&gt;

&lt;p&gt;We've said previously that Java converts its code into a form called &lt;em&gt;java bytecode&lt;/em&gt; so that any computer with a JVM can interpret and run it. To do this, we must take the natural java form and pour, or, in this case &lt;strong&gt;compile&lt;/strong&gt; it for transport. Here with Java, we do the compiling manually  from the command shell. To start, we, from the shell, call the &lt;em&gt;Java compiler&lt;/em&gt;, give it the path to our class, or the &lt;em&gt;classpath&lt;/em&gt; so the compiler can find it, and finish it all with a .java&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;javac SayHello.java
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That simple (so far)! the &lt;em&gt;javac&lt;/em&gt; command calls the java compiler, then we steer it where it needs to go. We should remember though, that the Java compiler needs a door to walk through. That door is a door we've already built in our previous Java code: the &lt;em&gt;main&lt;/em&gt; function. The compiler will always begin its work in the main function of the class it is pointed towards (in our case, the SayHello class). The flow of code compiling in Java will flow like so:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Ffnawx99ckp2zs0ocxza1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Ffnawx99ckp2zs0ocxza1.png" alt="Image description" width="703" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;note&lt;/strong&gt;: The Java compiler is checking your code while it transforms. If your code doesn't pass the series of checks, the cup will refuse you.&lt;/p&gt;

&lt;p&gt;When the in-built compiler finishes a successful compilation, it creates a .class file. In our above case, the file would be called "SayHello.class", but you'll hardly ever refer to it this way when running it. The program makes it a bit easier for us instead, assuming we mean class and allowing us to simply type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;java SayHello
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In order to get to the class file in question. If we follow these steps correctly, it would go something like this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We create a class holding an object holding a function that prints to the equivalent of a console.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SayHello&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="c1"&gt;//I'm using println instead of print so we move to the next line after&lt;/span&gt;
    &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello World!"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;We then move into the compiler in the shell, calling the compiler to come byte up this class.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;javac SayHello.java
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;At this point, there are two SayHello files&lt;/em&gt;. One file class is SayHello.java, the other, SayHello.class. This is something you can check on your own with the shell's list command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ls
SayHello.class  SayHello.java
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The .class file represents the compiled class, while .java represents the original. To implement the compiled class file in the compiler we don't need to use &lt;em&gt;.class&lt;/em&gt;, though.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;java SayHello

Hello World!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And there you have it! One complete cup of "SayHello" styled Java to take wherever we need it to be.&lt;/p&gt;

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

&lt;p&gt;Today, we've taken the juicy Java we created previously and given it a cozy compiled cup to rest in before it finds its new home wherever it goes. The versatility of Java takes attention to detail and flexibility that is optimized in its compilation program. Next, we'll move even further into the Java process and maybe even following it all the way to this new home and beyond. Stay tuned, and happy coding.&lt;/p&gt;

&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.scaler.com/topics/how-to-compile-java-program/" rel="noopener noreferrer"&gt;https://www.scaler.com/topics/how-to-compile-java-program/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.oracle.com/java/technologies/compile.html" rel="noopener noreferrer"&gt;https://www.oracle.com/java/technologies/compile.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.codecademy.com/learn/learn-java" rel="noopener noreferrer"&gt;https://www.codecademy.com/learn/learn-java&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Wake up: Say "Hello World" with Java</title>
      <dc:creator>steviepee</dc:creator>
      <pubDate>Tue, 18 Mar 2025 13:36:23 +0000</pubDate>
      <link>https://dev.to/steviepee/wake-up-say-hello-world-with-java-1215</link>
      <guid>https://dev.to/steviepee/wake-up-say-hello-world-with-java-1215</guid>
      <description>&lt;p&gt;It feels like you can't go anywhere in the coding world without hearing about Java! Maybe I should stop doing all my coding in coffee shops, but I 'm not sure that would help as much as you'd think. I decided to get to the bottom of this programming language, but to do that, we've got to start at the top! If you've got a few minutes, come take a shot of Java. Yes, of course you can bring your own coffee, we're saying Hello to the World!  &lt;/p&gt;

&lt;h2&gt;
  
  
  What is Java?
&lt;/h2&gt;

&lt;p&gt;Java is a computing platform and a "&lt;em&gt;high-level, general-purpose, memory-safe, object-oriented programming language&lt;/em&gt;. It was designed by James Gosling and first released by Sun Microsystems in May 1995. It's a very popular (third most popular programming language on Earth in 2022, according to &lt;em&gt;GitHub&lt;/em&gt;) programming powerhouse, run under the mantra &lt;em&gt;Write Once, Run Anywhere&lt;/em&gt;(we'll get to that in a bit). Java is used by platforms like LinkedIn, Amazon, and Netflix, coded in games like Minecraft, Runescape, and Angry Birds, and used by over 3 billion devices around the world. &lt;em&gt;Run Anywhere&lt;/em&gt;, indeed. Okay, that's enough about &lt;strong&gt;where&lt;/strong&gt; Java is run, now it's time to talk about &lt;strong&gt;how&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;

&lt;p&gt;Java syntax is largely influenced by C and C++, but any JavaScript programmer is bound to see a few similarities (note: though they sound like it, Java and JavaScript actually have no direct relation to each other. Further, Java is a compiled language, as JavaScript is interpreted). The comment/pseudocode structure is the same in both languages, and the basics seem pretty intuitive when coming from a JavaScript background, with a few caveats.  Let's take a look at how Java makes a standard &lt;em&gt;Hello World&lt;/em&gt; statement.&lt;/p&gt;

&lt;h3&gt;
  
  
  Hello World!
&lt;/h3&gt;

&lt;p&gt;I know I said JavaScript programmers would feel somewhat at home, but there are big differences. Take logging "Hello World" into a console for instance.&lt;/p&gt;

&lt;p&gt;Doing this in JavaScript is pretty straight forward:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello World&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;See? Nice and succinct, straight forward (and built in). With Java, we have a few more steps to work through. &lt;br&gt;
-&lt;strong&gt;Have some class&lt;/strong&gt;&lt;br&gt;
First off, as was said earlier, Java is an &lt;strong&gt;object-oriented language&lt;/strong&gt;, meaning, especially in the case of Java, that every data item is an object. Still, in the Java structure, an object item will live inside of a class, and all code is written inside of a class. With that in mind, before we do anything, we'll need to specify a class. Java does this like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SayHello&lt;/span&gt;&lt;span class="o"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To specify a class, Java must designate what sort of class it is. Public is the most permissive sort, and any other class can access a public class. Other classes include, but are not limited to: final, static, abstract and concrete.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Choose an&lt;/strong&gt; &lt;em&gt;object&lt;/em&gt; &lt;strong&gt;-ive&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now that we have and understand our class, we need to add an object to it. &lt;br&gt;
Remember, every data item is an object, so we must specify what kind of object it is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(){}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;there are a couple of things to mention here about this specification, and specifications of this in the future:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Public:&lt;/strong&gt; This is the same as the class designation above, and 
 signifies public access &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Static:&lt;/strong&gt; Static signifies that this method belongs to this class 
 itself, and not a particular instance of it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;main:&lt;/strong&gt; The name of the method. The runtime sees main as the starting point of the program.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;With these three things, we have our object, and we should add it to the class. There's still a couple of things missing here before we can finally move on to the actual command..&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;opening arguments&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We should allow the potential for other things to be passed into this method. To do that, we must specify the datatype of the arguments, or &lt;em&gt;args&lt;/em&gt;. The reason for this is that, in Java, we need to tell the runtime what datatype to expect on its way to read the methods, or really anything, for that matter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SayHello&lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/*did I mention variables capitalize every word, instead of leaving the first word lower-cased*/&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;){}&lt;/span&gt; 
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;what's your type&lt;/strong&gt;
Here, we've designated the type of arguments to be an array of strings, so now we should be good to... wait a minute. Didn't I say we needed to tell the runtime what datatype to expect for "really anything"? What should we tell it about what to expect to come out of this function? Well, like the console log in our javaScript example, we don't really expect anything to come out of the other side of this method. So do we really need to tell the runtime to expect nothing?
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SayHello&lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Yes, in fact we do. and the void keyword does just that. Now that the runtime knows what to expect, and the class, object and arguments are well  typed and defined, we can move on to the actual method.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Take a byte&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the JavaScript example, we simply invoked a console function to get our iconic phrase, why is that? Because JavaScript runs on web applications, and thus, can expect there to &lt;strong&gt;be&lt;/strong&gt; a console. Java doesn't make these sorts of expectations. As Java goes with its &lt;strong&gt;WORA&lt;/strong&gt; mantra, it can't really expect what system it will be run in. No matter the code here, when we're done and compiled, Java will convert it all into a form called &lt;em&gt;Java bytecode&lt;/em&gt;. This preps it for its eventual journey through its VM (virtual machine) and into whatever kind of web environment, game system, or anything in the vast &lt;em&gt;internet of things&lt;/em&gt; we've created in the world. So how do we print to the console with no console... well, maybe no console.. Where are we anyway? What's a "code"??.. Sorry, got lost in the vastness. The answer is we don't need to call a console to tell our program to print, we can just do it directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;print&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello, World!"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt; &lt;strong&gt;All together now&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;See what we did here? We simply called the system, whatever system it may be (System) to use its output(out) equivalent of a console to &lt;em&gt;print&lt;/em&gt; our key phrase. As complicated as it has to be, given the staggering amount of environments Java can potentially find itself in, but pretty simple when it's broken down. Let's put it all together and see what we get:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SayHello&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="c1"&gt;//I'm using println instead of print so we move to the next line after&lt;/span&gt;
    &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello World"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And there we have it! A good 'ol "Hello World" from the wonderful land of Java.&lt;/p&gt;

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

&lt;p&gt;Java is an amazingly versatile programming language that deftly uses specifics and expectations to work itself  into any environment in which it may find itself. Thanks for coming by to say hello, and I hope you come away with more understanding than you got here with. Till we code again!!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PS:&lt;/strong&gt; Funny coincidence, it turns out that the release-candidate for the absolute newest build of Java (24) just came out... &lt;strong&gt;TODAY!&lt;/strong&gt; If you're up to take a stroll on the cutting edge, I've left a link to the Build download below. Happy Coding!&lt;/p&gt;

&lt;h4&gt;
  
  
  Resources:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.java.com/en/download/help/whatis_java.html" rel="noopener noreferrer"&gt;https://www.java.com/en/download/help/whatis_java.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/Java_(programming_language)" rel="noopener noreferrer"&gt;https://en.wikipedia.org/wiki/Java_(programming_language)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.geeksforgeeks.org/types-of-classes-in-java/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/types-of-classes-in-java/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.geeksforgeeks.org/java/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/java/&lt;/a&gt;
####Get the latest Release-Candidate Build for Java 24!&lt;/li&gt;
&lt;li&gt;&lt;a href="https://jdk.java.net/24/" rel="noopener noreferrer"&gt;https://jdk.java.net/24/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>LET'S GET REGULARexpressions!!</title>
      <dc:creator>steviepee</dc:creator>
      <pubDate>Mon, 03 Feb 2025 19:42:47 +0000</pubDate>
      <link>https://dev.to/steviepee/lets-get-regularexpressions-354k</link>
      <guid>https://dev.to/steviepee/lets-get-regularexpressions-354k</guid>
      <description>&lt;h2&gt;
  
  
  In many circles of the coding realm, regex lurks as a mystery behind the scenes, cloaked in shadows until it shows it's Lovecraftian face to us and we lose our digital minds to the madness that is the Regular expression. I've endeavored to change that, if only a bit, so come with us as we explore a first look at the real face of Regex
&lt;/h2&gt;

&lt;h2&gt;
  
  
  REGEX
&lt;/h2&gt;

&lt;p&gt;Regular expressions, or Regex, originated in 1951, when mathematician Stephen Cole Kleene described regular languages using his mathematical notation called regular events.&lt;br&gt;
Its first appearance was a program setting in Ken Thompson's version of the QED text editor in the mid 1960's, and,since then, it has been used in pattern recognition software all over the coding world. So what exactly are Regexes, or a Regex, and how can we learn more about them&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A regular expression is a sequence of characters that define a search pattern.&lt;/strong&gt; It sounds simple... And that's because it IS simple! It's essentially a simplification of possible occurrences for the sole purpose of recognizing those occurrences any time (or just once or so when) they happen to arrive.&lt;br&gt;
definition, use cases, mention it as a matcher talk about simpler parts of it and how it's not the same in every place it's used. Maybe find an example of different versions of the same regex&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fz3fkk983zwhbrd9oh4vh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fz3fkk983zwhbrd9oh4vh.png" alt="Image description" width="800" height="61"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  But why
&lt;/h2&gt;

&lt;p&gt;Regex is used in a wide variety of text processing tasks, from serving as the language of lexers in parsing, to data validation, data scraping, wrangling and more. It is very heavily utilized for its simplicity in describing and searching for patterns in as few characters as possible. Let's take, for example, the above regex. What does it refer to? Well, by the end of this post, I'm hoping we can figure it out together. But first, lets look at the tools in the regex toolbox&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fm4lxyl4jhtcc5iz5dv9o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fm4lxyl4jhtcc5iz5dv9o.png" alt="Image description" width="426" height="259"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Tools
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;quantifier- Regex quantifiers check to see how many times you should search for a character.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here some examples of quantifiers:&lt;br&gt;
? – Zero or one&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;– one or more&lt;/li&gt;
&lt;li&gt;– zero or more
{N} – Exactly N number of times (where N is a number)
{N,} – N or more number of times (where N is a number)
{N,M} – Between N and M number of times (where N and M are numbers and N &amp;lt; M)
*? – Zero or more, but stop after first match&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;regex group- When searching with a regex, it can be helpful to search for more than one matched item at a time. This is where “groups” come into play. Groups allow you to search for more than a single item at a time.
Groups are defined by parentheses; there are two different types of groups–capture groups and non-capturing groups:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;(...) – Group matching any three characters&lt;br&gt;
(?:...) – Non-capturing group matching any three characters&lt;br&gt;
The difference between these two typically comes up in the conversation when “replace” is part of the equation. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;pattern collector- Pattern collections allow you to search for a collection of characters to match against. For example, using the following regex:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;My favorite vowel is [aeiou]&lt;br&gt;
You could match the following strings:&lt;/p&gt;

&lt;p&gt;My favorite vowel is a&lt;br&gt;
My favorite vowel is e&lt;br&gt;
My favorite vowel is i&lt;br&gt;
My favorite vowel is o&lt;br&gt;
My favorite vowel is u&lt;br&gt;
But nothing else.&lt;/p&gt;

&lt;p&gt;Here’s a list of the most common pattern collections:&lt;/p&gt;

&lt;p&gt;[A-Z]– Match any uppercase character from “A” to “Z”&lt;br&gt;
[a-z]– Match any lowercase character from “a” to “z”&lt;br&gt;
[0-9] – Match any number&lt;br&gt;
[opspk]– Match any character that’s either “o”, “p”, “s”, "p", or “k”&lt;br&gt;
[^asdf]– Match any character that’s not any of the following: “a”, “s”, “d”, or “f”&lt;br&gt;
You can combine these to:&lt;/p&gt;

&lt;p&gt;[0-9A-Z]– Match any character that’s either a number or a capital letter from “A” to “Z”&lt;br&gt;
[^a-z] – Match any non-lowercase letter&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;regex tokens- While keys like “a” to “z” make sense to match using regex, what about the newline character?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;. – Any character&lt;br&gt;
\n – Newline character&lt;br&gt;
\t – Tab character&lt;br&gt;
\s– Any whitespace character (including \t, \n and a few others)&lt;br&gt;
\S – Any non-whitespace character&lt;br&gt;
\w– Any word character (Uppercase and lowercase Latin alphabet, numbers 0-9, and _)&lt;br&gt;
\W– Any non-word character (the inverse of the \w token)&lt;br&gt;
\b– Word boundary: The boundaries between \w and \W, but matches in-between characters&lt;br&gt;
\B– Non-word boundary: The inverse of \b&lt;br&gt;
^ – The start of a line&lt;br&gt;
$ – The end of a line &lt;br&gt;
\– The literal character “\”&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;metacharacters &lt;/li&gt;
&lt;li&gt;Repeaters&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The asterisk symbol (*) tells the computer to match the preceding character (or set of characters) for 0 or more times (to forever).1&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;'+'- &lt;strong&gt;The Plus symbol tells the computer to repeat the preceding character (or set of characters) at least one or more times(to forever).1&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;'{' - &lt;strong&gt;The curly braces tell the computer to repeat the preceding character (or set of characters) for as many times as the value inside this bracket.1&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;'^'- &lt;strong&gt;The caret symbol tells the computer that the match must start at the beginning of the string or line.(Example : ^\d{3} will match with patterns like "901" in "901-333-".&lt;br&gt;
)1&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;'$'- &lt;strong&gt;The dollar symbol tells the computer that the match must occur at the end of the string or before \n at the end of the line or string.1&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;'.'- &lt;strong&gt;The dot symbol can take the place of any other symbol, that is why it is called the wildcard character.1&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;'|'-  Regex OR operator: &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;'?'- ** Optional character symbol tells the computer that the preceding character may or may not be present in the string to be matched.1**&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;'()'- &lt;strong&gt;Grouping Characters ( ) &lt;br&gt;
A set of different symbols of a regular expression can be grouped together (within parentheses) to act as a single unit and behave as a block...1&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;'[]'- &lt;strong&gt;[set_of_characters]: Matches any single character in set_of_characters. By default, the match is case-sensitive.1&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;'\'- &lt;strong&gt;The Escape Symbol&lt;br&gt;&lt;br&gt;
**If you want to use any of these characters as a literal in a regex, you need to escape them with a backslash. If you want to match 1+1=2, the correct regex is 1+1=2. Otherwise, the plus sign has (the) special meaning.4&lt;/strong&gt;&lt;br&gt;
Here are some other helpers&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;\number &lt;br&gt;
Backreference: allows a previously matched sub-expression(expression captured or enclosed within circular brackets ) to be identified subsequently in the same regular expression. \n means that group enclosed within the n-th bracket will be repeated at current position.&lt;/p&gt;

&lt;p&gt;Comments:&lt;/p&gt;

&lt;p&gt;Comment ( ?# comment ) &lt;br&gt;
Inline comment: The comment ends at the first closing parenthesis.&lt;/p&gt;

&lt;p&gt;# [to end of line] &lt;br&gt;
X-mode comment. The comment starts at an unescaped # and continues to the end of the line.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;\\d+[\+-x\*]\d+\b#Here, we really match the + sign 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here are some other helpers&lt;/p&gt;

&lt;p&gt;\number &lt;br&gt;
Backreference: allows a previously matched sub-expression(expression captured or enclosed within circular brackets ) to be identified subsequently in the same regular expression. \n means that group enclosed within the n-th bracket will be repeated at current position.&lt;/p&gt;

&lt;p&gt;Comments- In any sort or language of programming, it's important to know just how to leave notes without interfering with the code at large. Here's how to do it in Regex:&lt;br&gt;
Comment ( ?# comment ) &lt;br&gt;
Inline comment: The comment ends at the first closing parenthesis.&lt;/p&gt;

&lt;p&gt;# [to end of line] &lt;br&gt;
X-mode comment. The comment starts at an unescaped # and continues to the end of the line.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;\\d+[\+-x\*]\d+\b#Here, we really match the + sign 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;regex flag- A regex flag is a modifier to an existing regex. These flags are always appended after the last forward slash in a regex definition. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here’s a shortlist of some of the flags available to you.&lt;/p&gt;

&lt;p&gt;g – Global, match as many times as the pattern emerges&lt;br&gt;
m – Force $ and ^ to match each newline individually&lt;br&gt;
i – Make the regex case insensitive&lt;br&gt;
s - Match new lines.&lt;br&gt;
x - allow spaces and comments.&lt;br&gt;
J - Allow duplicate group names&lt;br&gt;
U - Ungreedy match&lt;/p&gt;
&lt;h2&gt;
  
  
  Breakdown:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F3hit0ahvtf49pi1efs5j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F3hit0ahvtf49pi1efs5j.png" alt="Image description" width="800" height="61"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, what does this mean in the first place? Let's break it down:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[w._%+-] #the w tag refers to characters/numbers, then essentially anything goes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;+@ # match as many times as possible, then match the @ symbol directly
+\. #this '.' is escaped, so match it exactly
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[a-zA-Z] # then any letter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{2,4} # at least two times, but no more than 4.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Put them together and what do you get?? It's a checker for an email address!(regu$&lt;a href="mailto:ala9@gmail.com"&gt;ala9@gmail.com&lt;/a&gt;) See? not so bad!&lt;/p&gt;

&lt;h2&gt;
  
  
  conclusion
&lt;/h2&gt;

&lt;p&gt;Today we've peered into the bewildering abyss that is the regular expression and come out with our sanity. Jokes aside, the regular expression is an extremely useful and interesting tool for data-matching and parsers all over the world use them as a default. Once the grammar and groove of what these symbols hold are understood, there can be a whole new world of pattern matching ahead of us. I hope it's a bit easier for you to take a few steps into that wilderness after today. Happy coding!&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://www.geeksforgeeks.org/write-regular-expressions/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/write-regular-expressions/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://coderpad.io/blog/development/the-complete-guide-to-regular-expressions-regex/#what-does-a-regex-look-like" rel="noopener noreferrer"&gt;https://coderpad.io/blog/development/the-complete-guide-to-regular-expressions-regex/#what-does-a-regex-look-like&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.computerhope.com/jargon/r/regex.htm" rel="noopener noreferrer"&gt;https://www.computerhope.com/jargon/r/regex.htm&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.regular-expressions.info/tutorial.html" rel="noopener noreferrer"&gt;https://www.regular-expressions.info/tutorial.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/Regular_expression" rel="noopener noreferrer"&gt;https://en.wikipedia.org/wiki/Regular_expression&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
    </item>
    <item>
      <title>What's up with Markdown? A parsing glance</title>
      <dc:creator>steviepee</dc:creator>
      <pubDate>Mon, 27 Jan 2025 14:01:18 +0000</pubDate>
      <link>https://dev.to/steviepee/whats-up-with-markdown-a-parsing-glance-3fem</link>
      <guid>https://dev.to/steviepee/whats-up-with-markdown-a-parsing-glance-3fem</guid>
      <description>&lt;h2&gt;
  
  
  In the Beginning:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Falo0tpbca7v7jh5m1m5u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Falo0tpbca7v7jh5m1m5u.png" alt="Image description" width="249" height="314"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In 1991, Tim Berners-Lee (pictured above), a CERN physicist, developed the first version of his Hypertext Markup Language, or HTML. This fledgling version only sported 18 tags, whereas today, this cornerstone language boasts over 120!! This is great for HTML, but, somewhere around 87 or so, things start to be a little hard to keep up with for a good many of us. In addition HTML's 3.0 version tended to slow browsers&lt;/p&gt;

&lt;h3&gt;
  
  
  There's got to be a better way!
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Frjmddhpmhr65fsbpzgyh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Frjmddhpmhr65fsbpzgyh.png" alt="Image description" width="460" height="611"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;em&gt;A statue of Aaron Swartz in his natural habitat&lt;/em&gt;
&lt;/h5&gt;

&lt;p&gt;In 2004, John Gruber and Aaron Swartz, motivated by a dream to set a markup language  meant to be "as easy-to-read and easy-to-write as it is feasible", created Markdown.&lt;br&gt;
In many ways, it seems like they'd succeeded at their goal. Their plain-text markup was widely embraced and accepted over the years. How-ToGeek, in 2022, wrote of the language:&lt;br&gt;
&lt;em&gt;In short, Markdown makes it easier to format text for web pages because its tags are simpler than HTML, and they convert to HTML automatically. This means you don't have to know HTML to write something for a web page because Markdown translates your tags into HTML for you.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Since its inception, Markdown has been adopted and utilized by well-known sites like Slack, Reddit, GitHub, Stack Overflow, Medium and, of course, Dev.to. Let's take a look at why.&lt;/p&gt;

&lt;h4&gt;
  
  
  Comparisons:
&lt;/h4&gt;

&lt;p&gt;Here are a few examples of Markdown and HTML producing the same outputs&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Paragraphs&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HTML
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h2&amp;gt;This is a heading tag 2&amp;lt;/h2&amp;gt;
&amp;lt;p&amp;gt;A paragraph is essentially a welcome space to add text to your page.&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;## This is a heading tag 2
A paragraph is essentially a welcome space to add text to your page.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These will both look like this on the web page:&lt;/p&gt;

&lt;h2&gt;
  
  
  This is a heading tag 2
&lt;/h2&gt;

&lt;p&gt;A paragraph is essentially a welcome space to add text to your page.&lt;br&gt;
&lt;strong&gt;Emphasis&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HTML
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;p&amp;gt;this is a simple statement. 
&amp;lt;i&amp;gt;This one is italicized.&amp;lt;/i&amp;gt;
&amp;lt;b&amp;gt;And this statement is bold&amp;lt;/b&amp;gt;
&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;this is a simple statement.
*This one is italicized.*
**And this statement is bold**
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Will render like so:&lt;br&gt;
this is a simple statement.&lt;br&gt;
&lt;em&gt;This one is italicized.&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;And this statement is bold&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lists&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HTML
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;ul&amp;gt;
&amp;lt;li&amp;gt;one&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;two&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;three&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;

&amp;lt;ol&amp;gt;
&amp;lt;li&amp;gt;one&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;two&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;three&amp;lt;/li&amp;gt;
&amp;lt;/ol&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;* one
- two
+ three
// any of these symbols signal an unordered list

1. one
1. two
1. three 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;one&lt;/li&gt;
&lt;li&gt;two&lt;/li&gt;
&lt;li&gt;three&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;one&lt;/li&gt;
&lt;li&gt;two&lt;/li&gt;
&lt;li&gt;three &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Markdown cuts the tags and makes for a more plain text approach, so it's easy to see why text-heavy sites would opt to include it in their code. You may be wondering, if it's so simple, why don't we all just use Markdown and get rid of HTML altogether? Well, that's the funny thing:&lt;br&gt;
Markdown &lt;em&gt;IS&lt;/em&gt; HTML!&lt;/p&gt;

&lt;h2&gt;
  
  
  Parsers
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Parsing, syntax analysis, or syntactic analysis is the process of analyzing a string of symbols, either in natural language, computer languages or data structures, conforming to the rules of a formal grammar.&lt;/em&gt; A &lt;strong&gt;parser&lt;/strong&gt; takes input data and builds a data structure. In this case, our parser will take in the plain text Markdown as data and build HTML. That's the simple version: The more fun version involves 3 parts, if you count the tree. Just stay with me, we'll get there soon enough.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fuw551f9sdg1j161jcjhu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fuw551f9sdg1j161jcjhu.png" alt="Image description" width="800" height="599"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Lexer:
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;lexer&lt;/strong&gt; is the first stage of parsing, or the first parsing, depending on how you think of it. A lexer will take in the input data, in this case, Markdown plain text, and search for specific patterns. The lexer is set specifically to find just the patterns needed(hashtags, asterisks, spaces..). So the lexer will search through the document and make tokens based on the exact pattern its calibrated to. I keep saying exact because of things like this. See, we're in Markdown right now, and I've already shown how to make a numbered list, so let's use that as an example of patterning. "Exact" is why this happens:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;No problems here for a numbered list, but that space after the number is extremely important for pattern recognition. Without it,
1.this is just another number 1, and the lexer doesn't set this bit as a part of the list at all.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So, the lexer takes in the information, converts it into a series of tokens, then brings all of the &lt;strong&gt;tokens&lt;/strong&gt; to the parser proper. Then it's the &lt;strong&gt;parser&lt;/strong&gt; that interprets the necessary Grammar  to turn that starting information into... An Abstract Syntax Tree&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Ffbhxzka90rjp63fs5nm4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Ffbhxzka90rjp63fs5nm4.png" alt="Image description" width="575" height="662"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;An Abstract Syntax Tree, or AST, is &lt;em&gt;a data structure used in computer science to represent the structure of a program or code snippet.&lt;/em&gt; It represents the text structure in an abstract manner, so it doesn't quite represent every exact detail, but just the structural ones. Once the AST is generated by the parser during the source code translation and compiling process, it is then sent to the interpreter for further processing, such as contextual analysis, optimization, and code generation.&lt;/p&gt;

&lt;p&gt;Then the Interpreter, in this case, returns the HTML. Wild ride to shed a few tags, right?&lt;/p&gt;

&lt;h2&gt;
  
  
  Downloadable parsers
&lt;/h2&gt;

&lt;p&gt;If you'd like to get a look at this structure working at its best before your eyes, there are plenty Markdown Parsers all over the digital world for you to choose from.&lt;br&gt;
Here are just a few:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Marked: One of the most popular for javascript, also available as a CLI tool.&lt;/li&gt;
&lt;li&gt;markdown-it: written in javascript and compatible with node.js. "fast, easy to extend, and safe by default"&lt;/li&gt;
&lt;li&gt;MDX and react-markdown: MDX allows use of JSX, and react-markdown is a react component that renders the conversion for you&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;Today, we've gone through a long and interesting (I hope) journey through information interpretation. only to end up right back where we started. Right here in Dev.to, right here in Markdown. But I'm hoping that you, like our input, have come back changed. Happy coding, and thanks for giving this article a parsing glance.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://daringfireball.net/projects/markdown/" rel="noopener noreferrer"&gt;https://daringfireball.net/projects/markdown/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://byby.dev/js-markdown-libs" rel="noopener noreferrer"&gt;https://byby.dev/js-markdown-libs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.howtogeek.com/448323/what-is-markdown-and-how-do-you-use-it/https://www.bu.edu/lernet/artemis/years/2020/projects/FinalPresentations/HTML/historyofhtml.html" rel="noopener noreferrer"&gt;https://www.howtogeek.com/448323/what-is-markdown-and-how-do-you-use-it/https://www.bu.edu/lernet/artemis/years/2020/projects/FinalPresentations/HTML/historyofhtml.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/Parsing" rel="noopener noreferrer"&gt;https://en.wikipedia.org/wiki/Parsing&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
    </item>
    <item>
      <title>Observer Pattern: a quick peek</title>
      <dc:creator>steviepee</dc:creator>
      <pubDate>Mon, 20 Jan 2025 03:13:27 +0000</pubDate>
      <link>https://dev.to/steviepee/observer-design-a-quick-peek-59ik</link>
      <guid>https://dev.to/steviepee/observer-design-a-quick-peek-59ik</guid>
      <description>&lt;p&gt;If you're a person of the code, you've without a doubt encountered many&lt;br&gt;
forms of software design. From constructor, to factory, to Prototype, to Module and Mediator, Memento.. Okay, maybe I'm getting carried away. The point is that there are so many different designer patterns to choose from. It's an ocean of potential code patterns, and here's a chance to dip your feet in, for just a bit.&lt;br&gt;
Let's start by talking about just one pattern. The Observer Pattern&lt;/p&gt;
&lt;h2&gt;
  
  
  What is Observer Pattern
&lt;/h2&gt;

&lt;p&gt;According to Wikipedia, the Observer Pattern is a behavioral pattern &lt;strong&gt;... in which an object, named the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods.1&lt;/strong&gt;  Think of it as if the subject is a Parent that can't wait to call up all its children when something cool happens. Or, to put it into more stern terms, the Observer Pattern &lt;strong&gt;...lets you define a subscription mechanism to notify multiple objects about any events that happen to the object they’re observing.2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Within this pattern, the purpose of the observer is simply to take changed subject state information and inform all of its "subscribers". I say subscribers here, because the Observer pattern is only used &lt;strong&gt;when there is one-to-many relationship between objects2&lt;/strong&gt;. Here's an example of how a Subject relates to its observers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;//let's start with the subject(observable)&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;Subject&lt;/span&gt; &lt;span class="o"&gt;=&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="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="na"&gt;_state&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="c1"&gt;// ^^represents what the observers are... observing, and checking for changes&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;_observers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="c1"&gt;//An array to hold the list of subscribers to inform of changes&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="c1"&gt;// now we need a function that adds an observer to the list. Let's give it a simple push&lt;/span&gt;
  &lt;span class="nl"&gt;subscribe&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_observers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="c1"&gt;// and a function that takes a target observer out of the list&lt;/span&gt;
  &lt;span class="na"&gt;unsubscribe&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;targetObserver&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_observers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;sub&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="nx"&gt;targetObserver&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="c1"&gt;// also, a function that returns the current state wherever's necessary&lt;/span&gt;
  &lt;span class="na"&gt;getState&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_state&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;setState&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&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;_observers&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;observer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&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="c1"&gt;// We'll set signal as an observer method&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="c1"&gt;// And now, the observer&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;Observer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;update&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;subject&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;currentValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;subject&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getState&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;currentValue&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How is Observer Pattern?
&lt;/h2&gt;

&lt;p&gt;As was said earlier, the Observer Pattern defines a one-to-many relationship between a subject and its observers. Now that we know &lt;strong&gt;what&lt;/strong&gt; it does, let's take a little look at just &lt;strong&gt;how&lt;/strong&gt; that relationship is realized.&lt;/p&gt;

&lt;h3&gt;
  
  
  Two Paths diverge
&lt;/h3&gt;

&lt;p&gt;There are essentially two ways the Subject and its Observers can communicate, or &lt;em&gt;interact&lt;/em&gt;, with each other. In one model, the Observers query for and take in the information they seek. In the other, the Subject simply sends its specific bits of state information to each of its subscribers. Because of their modes of action, these models of interaction have simply been dubbed &lt;em&gt;pull&lt;/em&gt; and &lt;em&gt;push&lt;/em&gt;. We'll explore these models through one of the simplest info blocks I can think of: a coin toss.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fhxveulezaxuk8kb3yb4s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fhxveulezaxuk8kb3yb4s.png" alt="Image description" width="240" height="328"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Pull
&lt;/h4&gt;

&lt;p&gt;  In a &lt;em&gt;pull&lt;/em&gt; interaction model, &lt;strong&gt;Observers register themselves with the Subject as they are created. Whenever the Subject changes, it broadcasts to all registered Observers that it has changed, and each Observer queries the Subject for that subset of the Subject's state that it is responsible for monitoring.3&lt;/strong&gt;&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;let&lt;/span&gt; &lt;span class="nx"&gt;Subject&lt;/span&gt; &lt;span class="o"&gt;=&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="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;_state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;heads&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="na"&gt;tails&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="na"&gt;edge&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="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_observers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="cm"&gt;/* here, getState is an object, holding each state value  
 individually, waiting for an observer to choose which value it needs */&lt;/span&gt;
    &lt;span class="na"&gt;getState&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="na"&gt;heads&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;heads&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="na"&gt;tails&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tails&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="na"&gt;edge&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;edge&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="nx"&gt;setState&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&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;_observers&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;observer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&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="p"&gt;})&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;Observer&lt;/span&gt; &lt;span class="o"&gt;=&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;result&lt;/span&gt;&lt;span class="p"&gt;)&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="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="c1"&gt;// each observer will now use its update method to pull its designated value from the _state when informed&lt;/span&gt;
      &lt;span class="na"&gt;update&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;subject&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;currentValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;subject&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getState&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="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="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;currentValue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;return&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="p"&gt;];&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;flipTally&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Subject&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;headCheck&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;Observer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;heads&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;tailCheck&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;Observer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tails&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;edgeCheck&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;Observer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;edge&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.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%2F5o0h4bvgniz1i7h4lew4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F5o0h4bvgniz1i7h4lew4.png" alt="Image description" width="800" height="505"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h6&gt;
  
  
  possible depiction of the pull method in action(picture by Refactoring Guru(4).)
&lt;/h6&gt;

&lt;h3&gt;
  
  
  Push
&lt;/h3&gt;

&lt;p&gt;In the &lt;em&gt;push&lt;/em&gt; interaction model, *&lt;em&gt;The subjects send detailed information about the change to the observer whether it uses it or not. *&lt;/em&gt; In this case, the observers will essentially sift through the given information for the bit each one needs.&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;let&lt;/span&gt; &lt;span class="nx"&gt;Subject&lt;/span&gt; &lt;span class="o"&gt;=&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="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;_state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="na"&gt;heads&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="na"&gt;tails&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="na"&gt;edge&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="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_observers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
       &lt;span class="cm"&gt;/* in this example, getState is a function that will return the entire _state object to each observer, no matter what they're on the look out for...*/&lt;/span&gt;
      &lt;span class="na"&gt;getState&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_state&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="na"&gt;setState&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&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;_observers&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;observer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="nx"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&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="p"&gt;})&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;Observer&lt;/span&gt; &lt;span class="o"&gt;=&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;result&lt;/span&gt;&lt;span class="p"&gt;)&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="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tempState&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="c1"&gt;// ^^set a temporary state to hold the info given by getState&lt;/span&gt;
        &lt;span class="na"&gt;update&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;subject&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="c1"&gt;// here, the observer sets a variable to receive the _state object&lt;/span&gt;
          &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;currentValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;subject&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getState&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
          &lt;span class="c1"&gt;// then, place that value as its own tempState &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;tempState&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;currentValue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
          &lt;span class="cm"&gt;/*after that, an observer will take the value it is searching for
and return only that specified information*/&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="p"&gt;]&lt;/span&gt; &lt;span class="o"&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;tempState&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="k"&gt;return&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="p"&gt;]&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;flipTally&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Subject&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;headCheck&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;Observer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;heads&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;tailCheck&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;Observer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tails&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;edgeCheck&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;Observer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;edge&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.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%2Fzo30j0vlpmklukwree9k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fzo30j0vlpmklukwree9k.png" alt="Image description" width="393" height="381"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Choose your destiny
&lt;/h3&gt;

&lt;p&gt;The coding world certainly is fraught with tradeoffs. It is up to the programmer(you) to choose which model would work best for your needs. In the "pull" model, the observer makes a query after being notified by the subject, adding to complexity and providing a space for inaccuracy in cases where a new change can occur between these moments of communication... &lt;strong&gt;If changes are made in the subject state after the observer is notified, it will be refreshed with an old state.5&lt;/strong&gt;. In the push model, the subject could possibly send mountains of unnecessary data to each observer upon each change, requiring more direct coupling for a more tailored passing of data, which makes using the model for observers that need different information more problematic. In short, &lt;strong&gt;the "push" model compromises reuse, while the "pull" model is less efficient.3&lt;/strong&gt; It's up to you to decide which path is better for your particular program.&lt;/p&gt;

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

&lt;p&gt;Today, we've taken a closer look at one of many design patterns we use every day in our programs. And I must say, as I've said before, that the coding world is fraught with tradeoffs. There is always a decision to make about what is best for your system, and what can help your program excel at its intended purpose. There are so many more designs and so many more decisions to make, and this is the reason why our programs feel so alive and real, reacting to our every choice in measurable ways. The beauty of change in action, demonstrated here with a dip in the ever-changing waters of the code. Thanks for taking a dip with me. Maybe next time, we can make it a dive. Until then, happy coding.&lt;/p&gt;

&lt;p&gt;1.&lt;a href="https://en.wikipedia.org/wiki/Observer_pattern" rel="noopener noreferrer"&gt;https://en.wikipedia.org/wiki/Observer_pattern&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2.&lt;a href="https://www.tutorialspoint.com/design_pattern/observer_pattern.htm" rel="noopener noreferrer"&gt;https://www.tutorialspoint.com/design_pattern/observer_pattern.htm&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3.&lt;a href="https://sourcemaking.com/design_patterns/observer" rel="noopener noreferrer"&gt;https://sourcemaking.com/design_patterns/observer&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;4.&lt;a href="https://refactoring.guru/design-patterns/observer" rel="noopener noreferrer"&gt;https://refactoring.guru/design-patterns/observer&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;5.&lt;a href="https://www.oodesign.com/observer-pattern/" rel="noopener noreferrer"&gt;https://www.oodesign.com/observer-pattern/&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Python: Explained in javascript</title>
      <dc:creator>steviepee</dc:creator>
      <pubDate>Mon, 02 Dec 2024 15:03:09 +0000</pubDate>
      <link>https://dev.to/steviepee/python-explained-in-javascript-29nd</link>
      <guid>https://dev.to/steviepee/python-explained-in-javascript-29nd</guid>
      <description>&lt;p&gt;We see it all the time. Check job listings for programmers and very soon, you'll see the word: Python. If you, like me, started your digital journey in the wilds of javascript, and you'd really like to know what this new language has to offer, then you're in luck. I'll try to explain it as javascriptually as I can. Let's begin! &lt;/p&gt;

&lt;h2&gt;
  
  
  Why Python at all
&lt;/h2&gt;

&lt;p&gt;The first question on this javascripters mind is: Why python? Why not just stick with javascript? Well, the thing is, Python is &lt;strong&gt;a general-purpose programming language that can accommodate a variety of programming paradigms. Data science, artificial intelligence, machine learning, computer science education, computer vision, image processing, medicine, biology, and even astronomy all use it.1&lt;/strong&gt;&lt;br&gt;
   In addition to being widely used, it's mentally ergonomic. &lt;strong&gt;Python is a simple to use interpreter-based high-level programming language. It's also very simple to understand a Python program.1&lt;/strong&gt;&lt;br&gt;
It's also heavily utilized in back-end programming, and more and more often heavily utilized in general. A poll by StackOverflow points out that the popularity of Python as it goes with programming language is extremely high! Second only to HTML and, of course, good ol' javascript.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fv7ad4z0pj9q1ln7w4nm3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fv7ad4z0pj9q1ln7w4nm3.png" alt="Image description" width="800" height="380"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, Python is certainly here to stay, being utilized by tech giants like Instagram, Spotify, Reddit, and YouTube, this snake will come to bite you at many different angles. Now, before we really jump in, lets see &lt;br&gt;
which benefits each language provides&lt;/p&gt;

&lt;h2&gt;
  
  
  Python pros/cons
&lt;/h2&gt;

&lt;p&gt;*&lt;em&gt;Python is a widely used general-purpose, high-level programming language. It was initially designed by Guido van Rossum in 1991 and developed by Python Software Foundation *6&lt;/em&gt;  *&lt;em&gt;(he got the name from *Monty&lt;/em&gt;).&lt;br&gt;
&lt;em&gt;Python has been an inspiration for many other coding languages such as  Ruby  , Cobra, Boo, CoffeeScript ECMAScript, Groovy, Swift, Go, OCaml,  Julia  , etc.6&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Here are some pros to Python:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Easy to learn and read: Python's code looks a bit like English, which 
makes it easier to get what it's doing. This helps a lot when you're 
trying to find and fix mistakes.&lt;/li&gt;
&lt;li&gt; Interpreted execution: Unlike some languages that need to be fully 
built before you can see if they work, Python lets you try things out 
one step at a time. This is great for making changes and seeing results 
quickly.&lt;/li&gt;
&lt;li&gt; Dynamic typing: You don't have to tell Python what type of data (like 
numbers or text) you're using upfront. It figures it out as you go, 
making things more flexible.&lt;/li&gt;
&lt;li&gt; Vast libraries and frameworks: Python has a big collection of extra 
tools for different jobs - from making websites with Django or Flask 
to handling data with NumPy and Pandas, or even doing machine learning 
with TensorFlow.&lt;/li&gt;
&lt;li&gt; Cross-platform portability: Python works on different computers like 
Windows, Linux, and macOS without needing changes. This makes sharing 
your work easier.&lt;/li&gt;
&lt;li&gt; Supports multiple programming paradigms: Python lets you write code in 
different styles, whether it's focusing on actions, objects, or rules. 
This means you can pick the best way to solve a problem.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And some Cons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Python can be slower than languages that are built all at once before 
running. This might matter for tasks that need lots of computing 
power.&lt;/li&gt;
&lt;li&gt; If you're into making websites, knowing JavaScript is key because it's 
the main language for creating interactive web pages. Python is more 
for the behind-the-scenes stuff.&lt;/li&gt;
&lt;li&gt; Python isn't the go-to for making apps on phones compared to other 
languages specifically for Android or iOS.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Javascript pros/cons:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt; Everywhere in web dev: JavaScript is a must-know for anyone making 
websites.&lt;/li&gt;
&lt;li&gt; See results fast: When you change something, you can see the effect 
right away, which is great for learning.&lt;/li&gt;
&lt;li&gt; Do more than just websites: With Node.js, you can work on servers and 
more, not just web pages.&lt;/li&gt;
&lt;li&gt; Lots of help available: Being so popular, there's a ton of guides and 
communities to help you out.&lt;/li&gt;
&lt;li&gt; Skills that transfer: What you learn in JavaScript, like how to use 
functions and store data, helps with other languages too.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But also:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Handling many things at once: The way JavaScript does multiple tasks 
at the same time can be confusing.&lt;/li&gt;
&lt;li&gt; Old habits die hard: Some outdated JavaScript ways are still around 
and can be puzzling.&lt;/li&gt;
&lt;li&gt; Too many choices: With so many tools and frameworks, it's hard to know 
where to start.&lt;/li&gt;
&lt;li&gt; Not great for math stuff: JavaScript doesn't have as many built-in 
tools for math or data science as Python.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Variables
&lt;/h2&gt;

&lt;p&gt;Case-sensitive&lt;br&gt;
python underscore practices&lt;/p&gt;

&lt;h2&gt;
  
  
  Datatypes
&lt;/h2&gt;

&lt;p&gt;"strings" or text&lt;br&gt;
numbers or integers&lt;br&gt;
Boolean  True, False&lt;/p&gt;

&lt;p&gt;in operator(.includes, .contains, .hasOwnProperty)&lt;br&gt;
and = &amp;amp;&amp;amp;&lt;br&gt;
or = ||&lt;br&gt;
not (kinda like) !&lt;br&gt;
Functions&lt;br&gt;
indentation&lt;br&gt;
len()&lt;br&gt;
input() always returns a string&lt;br&gt;
if/elif/else&lt;br&gt;
 print()&lt;br&gt;
int()/str()&lt;br&gt;
upper()/lower()&lt;br&gt;
find()&lt;br&gt;
.replace()&lt;br&gt;
float()&lt;br&gt;
loops&lt;br&gt;
for item in numbers:&lt;br&gt;
    print(item)&lt;br&gt;
i = 0&lt;br&gt;
while i &amp;lt; len(numbers):&lt;br&gt;
    print(numbers[i])&lt;/p&gt;

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

&lt;p&gt;We've looked at some facets of Python and Javascript and how they compare to each other, but the real judge is you at the end of the day.&lt;br&gt;
Code on, and prosper!!&lt;/p&gt;

&lt;h2&gt;
  
  
  References:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://www.simplilearn.com/tutorials/programming-tutorial/javascript-vs-python" rel="noopener noreferrer"&gt;https://www.simplilearn.com/tutorials/programming-tutorial/javascript-vs-python&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;2.&lt;a href="https://blog.finxter.com/python-cheat-sheet/" rel="noopener noreferrer"&gt;https://blog.finxter.com/python-cheat-sheet/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3.&lt;a href="https://daily.dev/blog/python-and-javascript-choosing-your-first-language" rel="noopener noreferrer"&gt;https://daily.dev/blog/python-and-javascript-choosing-your-first-language&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;4.&lt;a href="https://radixweb.com/blog/python-vs-javascript" rel="noopener noreferrer"&gt;https://radixweb.com/blog/python-vs-javascript&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;5.&lt;a href="https://inveritasoft.com/article-python-vs-javascript:-what-to-choose-in-2021" rel="noopener noreferrer"&gt;https://inveritasoft.com/article-python-vs-javascript:-what-to-choose-in-2021&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://www.geeksforgeeks.org/history-of-python/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/history-of-python/&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Test and test can be two different variables&lt;br&gt;
booleans are written as True and False&lt;br&gt;
typescript-ish, as you can add type annotations optionally&lt;br&gt;
these do not change the code, but they help to remember if you only want a certain type for a variable...&lt;br&gt;
e.g.  name: str = "Roy"sg&lt;/p&gt;

</description>
    </item>
    <item>
      <title>I.A.M., But Who Are You?? Authentication and Authorization on the internet</title>
      <dc:creator>steviepee</dc:creator>
      <pubDate>Tue, 19 Nov 2024 00:29:41 +0000</pubDate>
      <link>https://dev.to/steviepee/iam-but-who-are-you-authentication-and-authorization-on-the-internet-1i03</link>
      <guid>https://dev.to/steviepee/iam-but-who-are-you-authentication-and-authorization-on-the-internet-1i03</guid>
      <description>&lt;p&gt;Picture this: You're invited to a party at a posh, exclusive club.&lt;br&gt;
 You spend hours getting ready and preparing just to make sure you make the right impression. You get an Uber, and they say your name to make sure it's you. You make it to the club, you see a loong line, but it's okay: You were invited. There's got to be some perks that come along with that. You walk right up to the front of the line and tell the doorman, "Hey, I'm supposed to be here." He looks you up and down, and the next few moments will be a real-life version of what servers do millions of times a day, all over the internet. I.A.M.&lt;/p&gt;

&lt;h1&gt;
  
  
  What is IAM?
&lt;/h1&gt;

&lt;p&gt;I.A.M stands for &lt;strong&gt;I&lt;/strong&gt;dentity and &lt;strong&gt;A&lt;/strong&gt;ccess &lt;strong&gt;M&lt;/strong&gt;anagement, and this is precisely what our bouncer/server is about to practice with you. First, he'll either ask for your name, or an ID. This is known as &lt;strong&gt;Authentication&lt;/strong&gt;. Let's break down what that would mean in our digital world.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F6l8ef3d3qwo1q9abdl0p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F6l8ef3d3qwo1q9abdl0p.png" alt="Image description" width="675" height="456"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Website Authentication
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Website authentication is the security process that allows users to verify their identities in order to gain access to their personal accounts on a website2.&lt;/strong&gt; Authentication, as swoopnow states, is a*huge component involved in keeping user accounts safe and accessible2.* It's a very important factor in maintaining security on websites. Back to the bouncer, what kind of club would it be if he just took everybody's word for it and let them in if they said what you did? Authentication normally takes the form of &lt;strong&gt;Matching someone’s login information like their username and password with their identity in the database,1&lt;/strong&gt; essentially checking your ID. There are other methods, of course. Different websites have contrasting needs depending on what the site accesses and what the user will tolerate. &lt;strong&gt;There are two key factors to consider when creating or updating your website authentication systems— user experience (or UX) and security2.&lt;/strong&gt;  And, based on that delicate dance, there are a few methods of authentication you'll see all over our digital landscape.&lt;/p&gt;

&lt;h2&gt;
  
  
  Username/password:
&lt;/h2&gt;

&lt;p&gt;Of course, the most prominent form of authentication to date is the Username/password combination. It's an extra boost for security to have both a name you've made for yourself and a password of your choice to access your information, however, &lt;strong&gt;oftentimes a username is replaced by the user’s email address, such as in the example to the right. This is often more convenient for the user, although not as secure.&lt;/strong&gt; It's not too difficult to track down a user's email address, but it is quite easy for you to remember yours, so it means less of a hassle to get you to your information. It's more like the Uber driver that checked your name before getting you where you needed to go. Easy for you, but relatively easy for others.&lt;/p&gt;

&lt;h2&gt;
  
  
  Multi-factor authentication
&lt;/h2&gt;

&lt;p&gt;There are, of course other ways to prove yourself. Some sites opt to use Multi-factor authorization. Multi-factor authorization will oftentimes ask for the customary username/password combo, but they'll also want another piece of information.&lt;strong&gt;This “piece of information” can be anything from a one-time passcode to a physical token that acts as a second confirmation to verify users are who they say they are.4&lt;/strong&gt;&lt;br&gt;
 It's more secure, but more of a hassle. Speaking as someone who needed to get into their email after my phone was stolen, it can sometimes be difficult to make up for that second factor. Which is a good thing, when it works. Kind of like the bouncer who asks for your name, then checks your ID. It's a great idea-- kind of bad for you if you forgot your ID at home, though.&lt;/p&gt;

&lt;h2&gt;
  
  
  Inheritance
&lt;/h2&gt;

&lt;p&gt;The third form of authentication we'll discuss is called inheritance authentication. &lt;strong&gt;Inheritance factors are often referred to as biometric factors, which allow the user to verify their identity using physical characteristics that are unique to each individual. Popular methods include fingerprint scanning or facial recognition.&lt;/strong&gt;This is a great improvement over the last issue we just spoke about, as you're not too likely to forget your thumb at home, but everything has pros and cons.&lt;br&gt;
According to Swooop, &lt;em&gt;some cybercriminals have found ways to get around these factors using a “master fingerprint” or a high-quality image. And in the case that someone else does get a hold of your biometric markers, that method will never be secure again. You can’t just change your fingerprint!2&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Authorization
&lt;/h1&gt;

&lt;p&gt;We've now talked about a few forms of confirming identity, but there's another part to verification, both on the internet and in real life. Take our example from above. There are many ways that bouncer could have confirmed our identity, but there's still one more thing to do: Check the list for your name!&lt;/p&gt;

&lt;h1&gt;
  
  
  Yes, you're you, but should you be here?
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Authorization should be used whenever you want to control viewer access of certain pages.1&lt;/strong&gt; If we didn't have that, either no one would have access, or everyone would.. equally frightening concepts.  Though authorization is much more cut and dry than authentication issues, it's no less important, and often, they're arm-in-arm. &lt;em&gt;Authentication and Authorization are often used together. For example, students at Boston University are required to authenticate before accessing the Student Link. The authentication they provide determines what data they are authorized to see. The authorization step prevents students from seeing data of other students.1&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Come on in!
&lt;/h2&gt;

&lt;p&gt;Once your identity and your credentials have been verified, you're free to head to the party safe in the knowledge that all or most guests there have been properly vetted, and that's really what's at the heart and soul of IAM. Of course, there are many other things we can discuss when it comes to the wide wide world of verity, like tokens, and cookies (cookies are like when you leave the club for a minute and they just let you right back in), but we'll save these for another time. Party safe, and I'll see you next time. Don't forget your ID!  &lt;/p&gt;

&lt;p&gt;references:&lt;/p&gt;

&lt;p&gt;1   &lt;a href="https://www.bu.edu/tech/about/security-resources/bestpractice/auth/" rel="noopener noreferrer"&gt;https://www.bu.edu/tech/about/security-resources/bestpractice/auth/&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://swoopnow.com/website-authentication/" rel="noopener noreferrer"&gt;https://swoopnow.com/website-authentication/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.microsoft.com/en-us/security/business/security-101/what-is-identity-access-management-iam" rel="noopener noreferrer"&gt;https://www.microsoft.com/en-us/security/business/security-101/what-is-identity-access-management-iam&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://swoopnow.com/two-factor-authentication-guide/" rel="noopener noreferrer"&gt;https://swoopnow.com/two-factor-authentication-guide/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
    </item>
    <item>
      <title>React Components: The Cycle of Life</title>
      <dc:creator>steviepee</dc:creator>
      <pubDate>Tue, 12 Nov 2024 15:43:18 +0000</pubDate>
      <link>https://dev.to/steviepee/react-components-the-cycle-of-life-44a1</link>
      <guid>https://dev.to/steviepee/react-components-the-cycle-of-life-44a1</guid>
      <description>&lt;p&gt;What is React? React is &lt;strong&gt;an open-source, component-based front end library responsible for the view layer of (an) application.1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;What are components? React dev itself defies components as &lt;strong&gt;the base class for the React components defined as JavaScript classes.4&lt;/strong&gt; A more human definition, though, could be that they are all the little pieces that make up a web page&lt;/p&gt;

&lt;p&gt;component life cycle: A component's &lt;strong&gt;Lifecycle is defined as the series of methods that are invoked in different stages of the component’s existence2&lt;/strong&gt; Most developers would say that a React component's life cycle has four stages (which is technically true, the best &lt;strong&gt;kind&lt;/strong&gt; of true), but if you boil it down, each component pretty much lives life much like we do: They're born, they learn, they die.&lt;br&gt;
[&lt;em&gt;Note&lt;/em&gt;: There are two ways to syntactically refer to React components, those being &lt;em&gt;class-based&lt;/em&gt; and &lt;em&gt;functional&lt;/em&gt; components. Current good practices, and React itself for that matter, would &lt;strong&gt;recommend defining components as functions instead of classes4&lt;/strong&gt;, but many legacy systems refer to components as classes. Further, the class structure more directly refers to the component's status and life cycle stages, so we'll be opting for class structure. Just for now.] &lt;/p&gt;

&lt;h2&gt;
  
  
  They're Born:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Ftg7k8nrdell9vix7groj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Ftg7k8nrdell9vix7groj.png" alt="static defaultProps()" width="698" height="372"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  1.initialization phase.
&lt;/h3&gt;

&lt;p&gt;According to javatpoint.com, this phase*&lt;em&gt;is the birth phase of the &lt;br&gt;
  lifecycle of a ReactJS component.1&lt;/em&gt;&lt;em&gt;, but it works like more of a pre- &lt;br&gt;
  natal phase, as this is the phase where *&lt;/em&gt;... a component contains the &lt;br&gt;
  default Props and initial State1**, gaining traits in-digital-utero &lt;br&gt;
  that will be used after its birth into the DOM. &lt;br&gt;
  These are some methods that are utilized at this stage of life:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;static defaultProps():&lt;em&gt;previously getDefaultProps()es5&lt;/em&gt;
It is used to specify the default value of this.props. It is invoked 
before the creation of the component or any props from the parent is 
passed into it.(1)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;class MyComponent extends React.Component {&lt;br&gt;
  static defaultProps = {&lt;br&gt;
    name: 'Jack',&lt;br&gt;
    age: 35&lt;br&gt;
  };&lt;/p&gt;

&lt;p&gt;&lt;em&gt;initialState(): *previously getInitialState()es5&lt;/em&gt;&lt;br&gt;
It is used to specify the default value of this.state. It is invoked before the creation of the component.(1) We may also use the ES6 class Constructor() method in the component's creation, much like any other class instantiation.&lt;/p&gt;

&lt;p&gt;class Clock extends React.Component { &lt;br&gt;
    constructor(props) &lt;br&gt;
    { &lt;br&gt;
        // Calling the constructor of &lt;br&gt;
        // Parent Class React.Component &lt;br&gt;
        super(props); &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    this.state = { date : new Date()/*initial state*/ }; 
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;} &lt;/p&gt;

&lt;p&gt;&lt;a href="https://imgflip.com/i/9a3dfp" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgflip.com%2F9a3dfp.jpg" title="made at imgflip.com" width="800" height="442"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;a href="https://imgflip.com/memegenerator" rel="noopener noreferrer"&gt;from Imgflip Meme Generator&lt;/a&gt;
&lt;h3&gt;
  
  
  2.mounting phase.
&lt;/h3&gt;

&lt;p&gt;Now, here's where the real life begins! This is the phase when the component is rendered for the first time, added to the DOM, and ready to see the world. At this point of the life cycle, we tend to use methods like, of course, render(), which &lt;strong&gt;is invoked to examine this.props and this.state and return one of the following types: React elements, Arrays and fragments, Booleans or null, String and Number.&lt;/strong&gt; and &lt;strong&gt;may (be) call(ed) at any moment&lt;/strong&gt; and many moments, not just at mounting time. Also, we can use componentDidMount(), which sounds a little like a first birthday, but is really a method ** invoked after the initial mounting of the component in the DOM tree. It's a great place to call API endpoints and to do network requests.3**. Here is the method in action, curtesy of tutorialspoint.com:&lt;/p&gt;

&lt;p&gt;componentDidMount() { &lt;br&gt;
   this.timeFn = setInterval( () =&amp;gt; this.setTime(), 1000); &lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;In this example, the component(a clock, in this case,) is set to update its time every second right after it is first rendered. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fh9ikt970f0hr2y58g0b3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fh9ikt970f0hr2y58g0b3.png" alt="Image description" width="536" height="316"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  They Learn:
&lt;/h2&gt;

&lt;p&gt;From here on in, they'll live a life kind of like ours: Lauding their achievements, questioning their decisions, remembering their past, and re-rendering as many times as their environment requires. This may sound poetic, but React seems to have that way about it. You see, &lt;strong&gt;React follows a default procedure in the Naming Conventions of these predefined functions where the functions containing “Will” represents before some specific phase and “Did” represents after the completion of that phase2&lt;/strong&gt;, not to mention "Should", usually before a life-rendering change is at hand. GeeksforGeeks depicts a great snippet of the component life cycle, with these Conventions presenting throughout:&lt;/p&gt;

&lt;p&gt;import React from "react";&lt;br&gt;
import ReactDOM from "react-dom/client";&lt;/p&gt;

&lt;p&gt;class Test extends React.Component {&lt;br&gt;
    constructor(props) {&lt;br&gt;
        super(props);&lt;br&gt;
        this.state = { hello: "World!" };&lt;br&gt;
    }&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;componentDidMount() {
    console.log("componentDidMount()");
}

changeState() {/*sets a new state for the component*/
    this.setState({ hello: "Geek!" });
}

render() {
    return (
        &amp;lt;div&amp;gt;
            &amp;lt;h1&amp;gt;
                GeeksForGeeks.org, Hello
                {this.state.hello}
            &amp;lt;/h1&amp;gt;
            &amp;lt;h2&amp;gt;
                &amp;lt;a
                    onClick={this.changeState.bind(
                        this
                    )}
                &amp;gt;
                    Press Here!
                &amp;lt;/a&amp;gt;
            &amp;lt;/h2&amp;gt;
        &amp;lt;/div&amp;gt;
    );
}

shouldComponentUpdate(nextProps, nextState) {/*checks for a change in props. If there is one, the method will return true and the component will render again with the new information*/
    console.log("shouldComponentUpdate()");
    return true;
}

componentDidUpdate() {
    console.log("componentDidUpdate()");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;const root = ReactDOM.createRoot(&lt;br&gt;
    document.getElementById("root")&lt;br&gt;
);&lt;br&gt;
root.render();&lt;/p&gt;

&lt;p&gt;As you can see, React facilitates a component life cycle with the potential for many dynamic changes based on environment and needs in a cogent and understandable phrasing structure. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://imgflip.com/i/9a3lh6" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgflip.com%2F9a3lh6.jpg" title="made at imgflip.com" width="612" height="408"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;a href="https://imgflip.com/memegenerator" rel="noopener noreferrer"&gt;from Imgflip Meme Generator&lt;/a&gt;
&lt;h2&gt;
  
  
  They Die:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;A component's death and its birth have one thing in common: they can only happen once. Once a component is unmounted, it cannot be re-mounted. Because of this, React includes some clean-up procedures to get the component's house in order before its final moments. The &lt;strong&gt;componentWillUnmount()&lt;/strong&gt; method is good for performing cleanup tasks before a component is unmounted. Its duties include: Canceling network requests, clearing timers, removing event listeners, an cleaning up subscriptions.
this is a highly recommended option in order to avoid side effects, bugs, and memory leaks.Note: this should be done &lt;em&gt;after&lt;/em&gt; the &lt;strong&gt;componentDidMount()&lt;/strong&gt; method and mirror it, and invoked just before &lt;strong&gt;unmountComponentFromNode()&lt;/strong&gt;. Kind of like writing a will, it sets up cleanup for anything the component gains control of in life.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Moving through the path of a component's life cycle is a very useful way to get into seeing the ins and outs of how React works. I hope that likening the lives of these components to our own has aided in your understanding of the environment React provides, as well as an appreciation for the Great Cycle of Life. Until we mount again!&lt;/p&gt;

&lt;p&gt;References:&lt;br&gt;
1.&lt;a href="https://www.javatpoint.com/react-component-life-cycle" rel="noopener noreferrer"&gt;https://www.javatpoint.com/react-component-life-cycle&lt;/a&gt; &lt;br&gt;
2.&lt;a href="https://www.geeksforgeeks.org/reactjs-lifecycle-components/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/reactjs-lifecycle-components/&lt;/a&gt;&lt;br&gt;
3.&lt;a href="https://www.tutorialspoint.com/reactjs/reactjs_component_life_cycle.htm" rel="noopener noreferrer"&gt;https://www.tutorialspoint.com/reactjs/reactjs_component_life_cycle.htm&lt;/a&gt;&lt;br&gt;
4.&lt;a href="https://react.dev/reference/react/Component" rel="noopener noreferrer"&gt;https://react.dev/reference/react/Component&lt;/a&gt;&lt;br&gt;
5.&lt;a href="https://projects.wojtekmaj.pl/react-lifecycle-methods-diagram/" rel="noopener noreferrer"&gt;https://projects.wojtekmaj.pl/react-lifecycle-methods-diagram/&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Operators</title>
      <dc:creator>steviepee</dc:creator>
      <pubDate>Wed, 09 Oct 2024 15:44:57 +0000</pubDate>
      <link>https://dev.to/steviepee/operators-1b84</link>
      <guid>https://dev.to/steviepee/operators-1b84</guid>
      <description>&lt;p&gt;Okay, so we've got variables, we've got values of all sorts, and we've got our good, good programmatical intentions, but how do we refer and compare our values and variables to each other (and themselves) to make our digital dreams come true?? The answer, my friend, is simple, yet complex. &lt;strong&gt;Operators!!&lt;/strong&gt; Welcome to their wonderful and comparative world!! Don't feel overwhelmed, though. We're gonna take it by the numbers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prelude: Operands
&lt;/h2&gt;

&lt;p&gt;We don't really mention operands too often, but that doesn't mean they're not &lt;strong&gt;super important&lt;/strong&gt;! &lt;em&gt;An operand is the data that is being operated on. The operand combined with the operator makes an operation(1)&lt;/em&gt;, and without that information, there's no program at all. This is true whether we're referring to many bits of data, or just one. &lt;/p&gt;

&lt;h2&gt;
  
  
  1- The unary
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;These operators require only&lt;/em&gt; &lt;strong&gt;one&lt;/strong&gt; &lt;em&gt;operand for operation.(1).&lt;/em&gt; This means we'll start by organizing, contemplating, morphing, and/or comparing data to &lt;strong&gt;itself.&lt;/strong&gt; In &lt;em&gt;Javascript&lt;/em&gt;, we can do a good few things with a single operand to deal with. Most of these things have to do with the &lt;a href="https://dev.to/steviepee/whats-in-the-box-variables-2b9h"&gt;types of variable&lt;/a&gt; we're dealing with. Check out these examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;+: &lt;em&gt;The unary&lt;/em&gt; &lt;strong&gt;plus (+)&lt;/strong&gt; &lt;em&gt;converts an operand into a number, if possible. It is commonly used to ensure numerical operations on variables that may contain numeric strings(2).*If the operand is a string that represents a valid number, it will be converted to a n
umber(2).&lt;/em&gt; If it can't be converted, it returns &lt;em&gt;NaN&lt;/em&gt; (not-a-number).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fn3ah178llfqa4h7mnech.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fn3ah178llfqa4h7mnech.png" alt="Image description" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;-: (2)&lt;em&gt;The Unary&lt;/em&gt; &lt;strong&gt;Negation (-)&lt;/strong&gt; &lt;em&gt;operator is used to convert its operand to a negative number if it isn’t already a negative number.&lt;/em&gt; &lt;em&gt;The unary negation operator *(first)&lt;/em&gt; converts its operand to a number(2).*
If it can't convert, it'll still return Nan(there's no -NaN).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fq2hp91fv5r8mc0doihvb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fq2hp91fv5r8mc0doihvb.png" alt="Image description" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;++: &lt;em&gt;The unary&lt;/em&gt; &lt;strong&gt;increment operator (++)&lt;/strong&gt; &lt;em&gt;adds&lt;/em&gt; &lt;strong&gt;1&lt;/strong&gt; &lt;em&gt;to its operand’s value and evaluates to the updated value(2).&lt;/em&gt; It can activate before or after an expression, depending on whether it is placed &lt;em&gt;as a postfix or prefix operator(2).&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;(2)&lt;em&gt;Postfix: In postfix, the current value of the variable is used in the expression, and then the variable’s value is incremented by 1.(2)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fpxxtpxzn64jq6fvknfg7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fpxxtpxzn64jq6fvknfg7.png" alt="Image description" width="326" height="168"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Prefix: In prefix, the variable’s value is first incremented by 1, and then the updated value is used in the expression.(2)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fyac4fnsrgyvlr62urzul.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fyac4fnsrgyvlr62urzul.png" alt="Image description" width="382" height="161"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;--: &lt;em&gt;The unary&lt;/em&gt; &lt;strong&gt;decrement operator (–)&lt;/strong&gt; &lt;em&gt;subtracts&lt;/em&gt; &lt;strong&gt;1&lt;/strong&gt; &lt;em&gt;from its operand’s value and evaluates it to the updated value.&lt;/em&gt; Like &lt;strong&gt;increment&lt;/strong&gt;, this can also be used &lt;em&gt;as a postfix or prefix operator(2).&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Postfix: In postfix form, the current value of the variable is used in the expression, and then the variable’s value is decremented by 1(2).&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Ffnvbpjxye9l44lz6maze.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Ffnvbpjxye9l44lz6maze.png" alt="Image description" width="322" height="149"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Prefix: In prefix form, the variable’s value is first decremented by 1, and then the updated value is used in the expression (2).&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F3x5wdk0aubt311axj1yn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F3x5wdk0aubt311axj1yn.png" alt="Image description" width="402" height="188"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;!: &lt;em&gt;The logical&lt;/em&gt; &lt;strong&gt;NOT (!)&lt;/strong&gt;(a.k.a. the "BANG" operator) *negates the Boolean value of an operand, converting true to false and false to true(2).*This is mostly used in "if" statements and other truth-based operations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Foj3oqrwtdw96z6wyut4g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Foj3oqrwtdw96z6wyut4g.png" alt="Image description" width="502" height="132"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;typeof: (2)&lt;em&gt;The JavaScript typeof operator returns the data type of its operand in the form of a string. The operand can be any object, function, or variable.&lt;/em&gt;(NOTE: the &lt;em&gt;typeof&lt;/em&gt; operator sees arrays([]) and objects({}) as objects, and will resolve "object" in both cases. Be cautious when this is the answer.)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F0jb2k4bv6749rz7u0a9q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F0jb2k4bv6749rz7u0a9q.png" alt="Image description" width="726" height="245"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;delete: (2)&lt;em&gt;The delete operator in JavaScript removes a property from an&lt;/em&gt; &lt;strong&gt;object&lt;/strong&gt;. &lt;em&gt;If no other references exist, the property’s memory is automatically released.&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fvudn7zbmusto3arz4h41.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fvudn7zbmusto3arz4h41.png" alt="Image description" width="449" height="161"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;void: &lt;em&gt;The void operator evaluates the given expression and then returns undefined.&lt;/em&gt; It is often used to ensure that an expression has no return value.(2)*&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Flf7cg1w3iuvjz3ci8b3z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Flf7cg1w3iuvjz3ci8b3z.png" alt="Image description" width="445" height="89"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2- Binary:
&lt;/h2&gt;

&lt;p&gt;Ah, programming languages, operating in the binary since &lt;strong&gt;'01&lt;/strong&gt;. Jokes aside, &lt;br&gt;
&lt;strong&gt;binary&lt;/strong&gt; operators are the ones that &lt;em&gt;require two operands for operation(1).&lt;/em&gt; Most of our operations are done using these operators, since most of our more complicated operations distill down to one-on-one comparisons &lt;em&gt;(those that I've seen, so far)&lt;/em&gt;. Binary operators come in many shades, so, as to save you a bit of time, I whipped up a few tables.&lt;/p&gt;

&lt;p&gt;Let's begin with the binary operators you're already familiar with:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Arithmetic Operators&lt;/strong&gt;: &lt;em&gt;Arithmetic operators are binary operators(1)&lt;/em&gt; that work pretty much the same as you likely learned them in grade school. As such, they're normally used with &lt;strong&gt;numbers&lt;/strong&gt;, though there are some exceptions.&lt;em&gt;The first operand is on the left of the operator, and the second operand is on the right.&lt;/em&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;th&gt;Operator&lt;/th&gt;
&lt;th&gt;Usage&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Addition&lt;/td&gt;
&lt;td&gt;+&lt;/td&gt;
&lt;td&gt;adds operands&lt;/td&gt;
&lt;td&gt;4 + 6: &lt;strong&gt;10&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Subtraction&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;td&gt;subtracts operands&lt;/td&gt;
&lt;td&gt;8 - 6: &lt;strong&gt;2&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Multiplication&lt;/td&gt;
&lt;td&gt;*&lt;/td&gt;
&lt;td&gt;multiplies operands&lt;/td&gt;
&lt;td&gt;10 * 2: &lt;strong&gt;20&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Division&lt;/td&gt;
&lt;td&gt;/&lt;/td&gt;
&lt;td&gt;divides operands&lt;/td&gt;
&lt;td&gt;20 / 2: &lt;strong&gt;10&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;%: &lt;strong&gt;Modulo:&lt;/strong&gt; The modulo operand (commonly mis-named "modulus")behaves similar to division, in that it divides, but there's more, I promise! &lt;em&gt;It divides the first operand (the dividend) by the second operand (the divisor) and returns the remainder(5).&lt;/em&gt; Think of it like grouping what's on the left into groups of what's on the right and answering what's left over.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fobnauv7pbwyz5d92xafd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fobnauv7pbwyz5d92xafd.png" alt="Image description" width="347" height="101"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Comparison/Relational Operators: &lt;em&gt;All comparison operators also require two operands(1).&lt;/em&gt; The value of operands with a comparison/relational operator between them will be in the form of a boolean, so I like to think of the operators as asking a question. Here are some examples:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;th&gt;Operator&lt;/th&gt;
&lt;th&gt;Usage&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Less-Than&lt;/td&gt;
&lt;td&gt;&amp;lt;&lt;/td&gt;
&lt;td&gt;is left less than right?&lt;/td&gt;
&lt;td&gt;4 &amp;lt; 6: &lt;strong&gt;true&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Greater-Than&lt;/td&gt;
&lt;td&gt;&amp;gt;&lt;/td&gt;
&lt;td&gt;is left greater than right?&lt;/td&gt;
&lt;td&gt;8 &amp;gt; 6: &lt;strong&gt;true&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Less-Than or equal to&lt;/td&gt;
&lt;td&gt;&amp;lt;=&lt;/td&gt;
&lt;td&gt;is left &amp;lt; or equal to right?&lt;/td&gt;
&lt;td&gt;10 &amp;lt;= 10: &lt;strong&gt;true&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Greater than or equal to&lt;/td&gt;
&lt;td&gt;&amp;gt;=&lt;/td&gt;
&lt;td&gt;is left &amp;gt; or equal to right?&lt;/td&gt;
&lt;td&gt;20 &amp;gt;= 2: &lt;strong&gt;true&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Loosely-equal&lt;/td&gt;
&lt;td&gt;==&lt;/td&gt;
&lt;td&gt;does left have same value as right?&lt;/td&gt;
&lt;td&gt;10 == '10': &lt;strong&gt;true&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Strictly-equal&lt;/td&gt;
&lt;td&gt;===&lt;/td&gt;
&lt;td&gt;does left have same value and type as right?&lt;/td&gt;
&lt;td&gt;10 === "10": &lt;strong&gt;false&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Strictly inequal&lt;/td&gt;
&lt;td&gt;!==&lt;/td&gt;
&lt;td&gt;does left have diff value and/or type as right?&lt;/td&gt;
&lt;td&gt;10 !== "10": &lt;strong&gt;true&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Inequal&lt;/td&gt;
&lt;td&gt;!=&lt;/td&gt;
&lt;td&gt;does left have diff value than right?&lt;/td&gt;
&lt;td&gt;10 != "10": &lt;strong&gt;false&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;=: (1)&lt;em&gt;The assignment operator:&lt;/em&gt; Will not return a boolean. It's the O.G. equals and creates truth wherever it goes. If &lt;strong&gt;a&lt;/strong&gt; didn't = &lt;strong&gt;b&lt;/strong&gt; earlier, it for sure does now &lt;em&gt;(errors aside)&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://imgflip.com/i/965hgm" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgflip.com%2F965hgm.jpg" title="D-BO assigns X" width="500" height="598"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The assignment operator likes to bring all of its math class friends along, re-assigning the countryside in its wake. If your &lt;strong&gt;=&lt;/strong&gt; shows up with a math-y operator &lt;strong&gt;(+, -, *, /, %)&lt;/strong&gt;, when they're done, the left operand will come back changed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://imgflip.com/i/965ijm" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgflip.com%2F965ijm.jpg" title="NEO sees the truth of zero" width="643" height="388"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In each of the exercises in the following table, each operation is assumed to follow (let x = 10);&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;th&gt;Operator&lt;/th&gt;
&lt;th&gt;Usage&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Plus-equal&lt;/td&gt;
&lt;td&gt;+=&lt;/td&gt;
&lt;td&gt;Left = its previous value + right&lt;/td&gt;
&lt;td&gt;x += 7: &lt;strong&gt;x = 17&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Minus-equal&lt;/td&gt;
&lt;td&gt;-=&lt;/td&gt;
&lt;td&gt;Left = its previous value - right&lt;/td&gt;
&lt;td&gt;x -= 6: &lt;strong&gt;x = 4&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Divide-equal&lt;/td&gt;
&lt;td&gt;/=&lt;/td&gt;
&lt;td&gt;Left = its previous value - right&lt;/td&gt;
&lt;td&gt;x /= 2: ** x = 5**&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Multiply-equal&lt;/td&gt;
&lt;td&gt;*=&lt;/td&gt;
&lt;td&gt;Left = its previous value * right&lt;/td&gt;
&lt;td&gt;x &lt;em&gt;= 10: **x = 100&lt;/em&gt;*&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;modulo-equal&lt;/td&gt;
&lt;td&gt;%=&lt;/td&gt;
&lt;td&gt;Left = its previous value % right&lt;/td&gt;
&lt;td&gt;x %= 4: &lt;strong&gt;x = 2&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h1&gt;
  
  
  Logical Operators:
&lt;/h1&gt;

&lt;p&gt;Sometimes, when we're setting conditions, we want to add more conditions to save time and expensive mental energy. In these cases, logical operators are the. . . &lt;em&gt;ahem&lt;/em&gt;. . . &lt;strong&gt;logical&lt;/strong&gt; solution.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&amp;amp;&amp;amp;:&lt;/strong&gt; The &lt;strong&gt;AND&lt;/strong&gt; operator is placed after an operand. &lt;strong&gt;AND&lt;/strong&gt; &lt;em&gt;returns true if both operands are truthy and false otherwise:(6)&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Flj9z6e588m96909zulub.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Flj9z6e588m96909zulub.png" alt="Image description" width="335" height="193"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;||:&lt;/strong&gt; Want to add a condition to an operand, but either one is good enough for you? &lt;strong&gt;OR&lt;/strong&gt; is the perfect solution! Add a || to your statement, then your additional stipulation(s). then, &lt;em&gt;if any of its arguments are true, it returns true, otherwise it returns false:(6)&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fnvnhah2419rqn1tdlkws.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fnvnhah2419rqn1tdlkws.png" alt="Image description" width="381" height="166"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;??:&lt;/strong&gt; &lt;em&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.(7)&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fs522fyjdsgtig45axoqx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fs522fyjdsgtig45axoqx.png" alt="Image description" width="649" height="160"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3- Ternary:
&lt;/h2&gt;

&lt;h3&gt;
  
  
  * The Ternary:
&lt;/h3&gt;

&lt;p&gt;There's only one ternary operator in Javascript, used as shorthand for [if statements]. It's pretty simple, and tends to look like this: &lt;em&gt;conditionalExpression ? truthyValue : falsyValue(4)&lt;/em&gt;&lt;br&gt;
Here, I'll show you how it works:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F9323lxj01qquvi6y6t78.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F9323lxj01qquvi6y6t78.png" alt="Image description" width="541" height="236"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  ~- And More!
&lt;/h2&gt;

&lt;p&gt;There are so many ways to refer to our bits and pieces of data to give them just the right relevance in just the things we happen to need them for when we write and implement code. I may have only shared the ones and twos (and a three) with you, but with this, as with coding in general, the sky's the limit! No, scratch that: the sky's too small. Even the stars are a stopping point to the edge, so don't be afraid to reach out. Buckle up, intrepid coders, we're heading &lt;strong&gt;To Infinity, and BEYOND!!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://imgflip.com/i/965j5l" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgflip.com%2F965j5l.jpg" title="Buzz Lightyear going beyond" width="750" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(1). &lt;a href="https://www.freecodecamp.org/news/unary-binary-ternary-operators-" rel="noopener noreferrer"&gt;https://www.freecodecamp.org/news/unary-binary-ternary-operators-&lt;/a&gt; &lt;br&gt;
   javascript/&lt;br&gt;
(2). &lt;a href="https://www.geeksforgeeks.org/javascript-unary-operators/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/javascript-unary-operators/&lt;/a&gt;&lt;br&gt;
(3). &lt;a href="https://stackoverflow.com/questions/12122293/list-of-all-binary-" rel="noopener noreferrer"&gt;https://stackoverflow.com/questions/12122293/list-of-all-binary-&lt;/a&gt; &lt;br&gt;
   operators-in-javascript&lt;br&gt;
(4). &lt;a href="https://www.freecodecamp.org/news/javascript-ternary-operator-" rel="noopener noreferrer"&gt;https://www.freecodecamp.org/news/javascript-ternary-operator-&lt;/a&gt; &lt;br&gt;
   explained/&lt;br&gt;
(5). &lt;a href="https://www.freecodecamp.org/news/javascript-modulo-operator-how-to-" rel="noopener noreferrer"&gt;https://www.freecodecamp.org/news/javascript-modulo-operator-how-to-&lt;/a&gt; &lt;br&gt;
   use-the-modulus-in-js/&lt;br&gt;
(6). &lt;a href="https://javascript.info/logical-operators" rel="noopener noreferrer"&gt;https://javascript.info/logical-operators&lt;/a&gt;&lt;br&gt;
(7). &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>coding</category>
      <category>learning</category>
      <category>operations</category>
    </item>
    <item>
      <title>What's In The BOX?!: Variables</title>
      <dc:creator>steviepee</dc:creator>
      <pubDate>Sat, 10 Aug 2024 00:45:01 +0000</pubDate>
      <link>https://dev.to/steviepee/whats-in-the-box-variables-2b9h</link>
      <guid>https://dev.to/steviepee/whats-in-the-box-variables-2b9h</guid>
      <description>&lt;h2&gt;
  
  
  Little Boxes
&lt;/h2&gt;




&lt;p&gt;What is a variable? Most (&lt;em&gt;especially mozilla web docs&lt;/em&gt;(&lt;em&gt;MDN&lt;/em&gt;)) would describe it as "a container for a value". A named code that refers to a program of any kind from simple values to functions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var foo = "I pity the...";
const group =['Rhonda', 'Jamey', 'Kori', 'Greg'];
let greed = function (root) {
console.log("of all evil");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F25z7iok0dr8omdlthcgb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F25z7iok0dr8omdlthcgb.png" alt="Variable boxes" width="800" height="331"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h6&gt;
  
  
  Picture by MDN
&lt;/h6&gt;

&lt;p&gt;It's common practice to describe a variable "&lt;em&gt;being like little cardboard boxes that you can store things in.&lt;/em&gt;(&lt;em&gt;MDN&lt;/em&gt;)" Without those boxes, our values would shrivel and die in the heat of the code, ceasing to exist soon after implementation. As said in the tome &lt;strong&gt;Eloquent JavaScript&lt;/strong&gt;(&lt;em&gt;EJS&lt;/em&gt;), the variables would need to  "&lt;em&gt;...be used immediately or (they) will dissipate&lt;/em&gt;" and there are two ways to create these containers for lasting expressions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Declaration: Means just what it sounds like. Declaring a variable confirms its existence and name, but little else. The box isn't open, so we can't see it's &lt;em&gt;contents&lt;/em&gt;, or &lt;strong&gt;value&lt;/strong&gt;. Because the box is closed, but we expect something to be inside,(&lt;em&gt;Schrodinger vibes, anyone?&lt;/em&gt;) we give these boxes the justly named value &lt;strong&gt;undefined&lt;/strong&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var question;
let box;
const cat;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Initialization: Initialization is the JavaScript way to say "&lt;em&gt;There's a box here, and this is what's inside.&lt;/em&gt;" This box is brought into existence wide open, and we can easily see its contents.
"&lt;strong&gt;The = operator&lt;/strong&gt;"(&lt;em&gt;EJS&lt;/em&gt;) is used to denote what's inside the box. Which could be anything, really. Or nothing.. To say "&lt;em&gt;This box is open, but there's definitely nothing in it&lt;/em&gt;" we use the term &lt;strong&gt;null&lt;/strong&gt;. Here are some examples of initialization:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var question = true;
let box = null;
const cat = 4 + 3;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The reading of = will always give what's on the left of it the value of what's on the right. That's how we know that there's nothing in &lt;strong&gt;box&lt;/strong&gt;&lt;br&gt;
Now, like any open box, its contents can shift at just about any time you like. "* The = operator can be used at any time on existing (variables) to disconnect them from their current value and have them point to a new one:*"(EJS)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let greenLight = false;
//*the greenLight box contains the false value*
greenLight = true;
//*greenLight is now set to the value true*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;em&gt;false&lt;/em&gt; value used to inhabit this box, but with one simple change, there's a whole new value inside. It's just that easy!&lt;br&gt;
  Okay, it feels like we've thoroughly explored and internalized the &lt;em&gt;container, box&lt;/em&gt; concept. Now let's explore why it's wrong.&lt;/p&gt;
&lt;h2&gt;
  
  
  Learn the box. Forget the box.
&lt;/h2&gt;

&lt;p&gt;The "container" philosophy for variables is pretty good for a lot of things, as you may have seen. Still, at some point, boxes start to get complicated:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let a = 5;
let b = a;
a = 7;
console.log(b);// 5

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If box b has box a inside it, and box b is filled with a new value, isn't the same true for a? I mean, two boxes put together tend have the same contents inside when filled, right? &lt;strong&gt;Wrong.&lt;/strong&gt; The box concept of variables becomes confusing when you think about these kinds of things, because often, variables don't really behave like boxes at all.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Bindings and tentacles
&lt;/h2&gt;

&lt;p&gt;Really, in this case, it would be better to think of the data as having been there all along. In essence, a variable just kind of makes that piece of data important and accessible. The programs are floating in the vast reaches of techSpace, and it's up to our variables to "&lt;em&gt;catch and hold (them)&lt;/em&gt;"(&lt;em&gt;EJS&lt;/em&gt;). It's a little strange at first, but it makes a lot of sense when you think about it. Eloquent JavaScript describes it like this:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"&lt;em&gt;You should imagine bindings as tentacles rather than boxes. They do not contain values; they grasp them—two bindings can refer to the same value. A program can access only the values to which it still has a reference. When you need to remember something, you either grow a tentacle to hold on to it or reattach one of your existing tentacles to it.&lt;/em&gt;"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now, attach is a little deceiving here, since these "tentacles" only "grasp" at values that are small enough to hold (&lt;strong&gt;64 bits&lt;/strong&gt;). These values are called "simple dataTypes"(EJS) and include Numbers, Strings, and booleans. If a value is simple, our tentacle will wrap around and hold on to it.. Kind of.. An act we call &lt;strong&gt;Pass by value&lt;/strong&gt;(GFG). I say kind of because if a value our tentacle looks for is simple enough, it won't bother holding on to the same one, it'll just make a copy and hold it for itself:&lt;/p&gt;

&lt;p&gt;In the above example, our b tentacle didn't bother grasping the same 5 that a had, so when a changed its stripes and that 5 disappeared into space, b was still left with the copy of 5 it was originally holding. Now lets try something a little different:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var a = [13, 40, 27];

var b = a;
b.push(5, 1)//push is a method that moves these values into the end an array

console.log(a);//[13, 40, 27, 5, 1];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This example is a bit more &lt;strong&gt;complex&lt;/strong&gt;.  Our &lt;strong&gt;complex dataTypes&lt;/strong&gt;(arrays, objects, functions) are much to big to go around making copies of them to wrap our tentacles around, so what we do is simply point to the original. An act we like to call &lt;strong&gt;Pass by reference&lt;/strong&gt;(GFG). In this example, b can't hold on to its own array, so when it goes through a change, the original array it points to feels that change pass through it.&lt;/p&gt;

&lt;p&gt;This was a small introduction to how we name, grasp, point to, and otherwise utilize data for our own brilliant purposes. It's easy to overlook, but without variables, we would all be lost in a sea of code, digital waters all around us, grasping away as digital water falls right through our fingers. Variables are the boats that carry us all to our destination, and I, for one, appreciate the ride.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;References by initial&lt;/strong&gt;&lt;br&gt;
(MDN)&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/Variables" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/Variables&lt;/a&gt;&lt;br&gt;
(EJS)&lt;br&gt;
&lt;a href="https://eloquentjavascript.net/02_program_structure.html" rel="noopener noreferrer"&gt;https://eloquentjavascript.net/02_program_structure.html&lt;/a&gt;&lt;br&gt;
(GFG)&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/pass-by-value-and-pass-by-reference-in-javascript/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/pass-by-value-and-pass-by-reference-in-javascript/&lt;/a&gt;&lt;/p&gt;

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