<?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: Parth Patil</title>
    <description>The latest articles on DEV Community by Parth Patil (@parth2412).</description>
    <link>https://dev.to/parth2412</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%2F675677%2F9f20670c-8db2-42e0-86a9-a11b1dc81ff6.jpg</url>
      <title>DEV Community: Parth Patil</title>
      <link>https://dev.to/parth2412</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/parth2412"/>
    <language>en</language>
    <item>
      <title>Understanding modern cryptography</title>
      <dc:creator>Parth Patil</dc:creator>
      <pubDate>Sun, 03 Oct 2021 09:00:53 +0000</pubDate>
      <link>https://dev.to/parth2412/understanding-modern-cryptography-4gpd</link>
      <guid>https://dev.to/parth2412/understanding-modern-cryptography-4gpd</guid>
      <description>&lt;p&gt;Humans have always been concerned when it comes to trusting others. One of the most troubling trust concern for humans is the secure and uninterrupted passing of messages from one person to another. "What if my message was intercepted and read by someone", "What if my message was intercepted and modified by someone" are just a couple of questions that come to mind.&lt;/p&gt;

&lt;p&gt;We have been coming up with ways to secure our messages from ancient times and we have finally achieved a high standard of security for sending messages. This high standard of security doesn't seem hackable in the near future. And thus this article focuses on explaining this standard which we call &lt;strong&gt;Modern cryptography&lt;/strong&gt; or &lt;strong&gt;Public key cryptography&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In most of the examples you will come across while studying cryptography, you will find these 2 names "Alice" and "Bob".  Alice and Bob are fictional characters who are often used as placeholders for real people in discussions and examples about cryptography. Alice and Bob are 2 people trying to securely communicate with each other, while let's say another person "Darth" is trying to intercept and read/modify their communication. We will be using these 3 characters, Alice, Bob and Darth for the examples in this article as well.&lt;/p&gt;

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

&lt;p&gt;Cryptography is the study of techniques for secure communication. These techniques are based on mathematical theorems and proof, but don't worry you don't need to have a background in maths at all for this article and nor am I going to be explaining those boring theorems.&lt;/p&gt;

&lt;p&gt;In cryptography, a &lt;strong&gt;key&lt;/strong&gt; is a piece of information (a number or a string) used for scrambling data so that it appears random&lt;/p&gt;

&lt;p&gt;Modern cryptography tries to solve 2 problems:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Making sure that the message isn't read by someone in the middle. Let's call this "someone", the middleman&lt;/li&gt;
&lt;li&gt;Making sure that the message isn't modified by a middleman.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Basic cryptography, a brief introduction
&lt;/h2&gt;

&lt;p&gt;The most basic and one of the oldest forms of cryptography was the &lt;em&gt;Caesar Cipher,&lt;/em&gt; named due to being used by the Roman ruler, Julius Caesar to communicate confidential messages to his generals.&lt;/p&gt;

&lt;p&gt;It is a type of substitution cipher (think of a cipher as a crypto algorithm) in which each letter in the plaintext is 'shifted' a certain number of places down the alphabet. This &lt;em&gt;certain number&lt;/em&gt; is known as the &lt;em&gt;key.&lt;/em&gt; For example, with a key of 1, A would be replaced by B, B would become C, M would become N, Z would become A and so on.&lt;/p&gt;

&lt;p&gt;If the key is 1, the message &lt;code&gt;abc&lt;/code&gt; would be encrypted to &lt;code&gt;bcd&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;For the message &lt;code&gt;retreat&lt;/code&gt; and for the key 1, the encrypted message would be &lt;code&gt;sfusfbu&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For the key 2 the encrypted message for &lt;code&gt;retreat&lt;/code&gt; would be &lt;code&gt;tgvtgcv&lt;/code&gt; and so on.&lt;/p&gt;

&lt;p&gt;You can play around with the Caesar cipher at &lt;a href="https://cryptii.com/pipes/caesar-cipher" rel="noopener noreferrer"&gt;this&lt;/a&gt; link.&lt;/p&gt;

&lt;p&gt;Obviously, this method of cryptography is not the most secure way of communication. &lt;/p&gt;

&lt;h3&gt;
  
  
  Cons of the Caesar Cipher
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;You will need to share the key between your "generals" securely without anyone else knowing about that key because anyone with that key and an understanding of the cipher can easily decrypt the message.&lt;/li&gt;
&lt;li&gt;A key can only be a number from 1 to 25 since there are only 26 letters in the alphabet. If you think about it a key of 27 is nothing but a key of 1, a key of 28 is actually a key of 2 and so on. Thus a hacker can easily decrypt the message with a combination of guessing, luck and trial and error.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Below is an image of the Caesar cipher in action, with a key of &lt;em&gt;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%2Fgi7bxo5p8qjniuokf87f.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%2Fgi7bxo5p8qjniuokf87f.png" alt="https://media.geeksforgeeks.org/wp-content/uploads/ceaserCipher.png" width="600" height="251"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Caesar cipher is a form of symmetric key cryptography. &lt;/p&gt;

&lt;p&gt;In symmetric key cryptography, the same key is used to encrypt and decrypt a message. This key is kept a secret. By using symmetric key cryptography algorithms, data is converted to a form that cannot be understood by anyone who does not possess the secret key to decrypt it. &lt;/p&gt;

&lt;p&gt;New methods of symmetric encryption have been discovered which are far more secure than the Caesar cipher &lt;strong&gt;but the problem of safeguarding the common key still remains.&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Note that Caesar Cipher can only use numbers as keys but modern symmetric cryptographic techniques can use any string of characters as a key. This immediately makes it more secure than the Caesar Cipher since we can chose a key from an infinite range of keys, instead of just 26 numbers. (Infinite because a key doesn't have to be of a fixed length)&lt;/p&gt;

&lt;p&gt;The following can be used as keys&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;dhdfhf&lt;/li&gt;
&lt;li&gt;djf776f&lt;/li&gt;
&lt;li&gt;5757&lt;/li&gt;
&lt;li&gt;cxjd^&amp;amp;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A simple analogy of symmetric cryptography&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Imagine a trunk with a lock that Bob and Alice, use to ship documents back and forth. A typical lock has only two states: locked and unlocked. Anyone with a copy of the key can unlock the trunk if it's locked, and vice versa. When Bob locks the trunk and sends it to Alice, he knows that Alice can use her copy of the key to unlock the trunk. This is essentially how what's known as symmetric cryptography works: one secret key is used for both encrypting and decrypting, and both sides of a conversation use the same key.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Example taken from: &lt;a href="https://www.cloudflare.com/en-gb/learning/ssl/how-does-public-key-encryption-work/" rel="noopener noreferrer"&gt;https://www.cloudflare.com/en-gb/learning/ssl/how-does-public-key-encryption-work/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can play around with modern symmetric key cryptography using &lt;a href="https://aesencryption.net/" rel="noopener noreferrer"&gt;this&lt;/a&gt; link.&lt;/p&gt;

&lt;p&gt;Here's how a conversation between Alice and Bob would work with &lt;strong&gt;symmetric&lt;/strong&gt; key cryptography&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Alice and Bob decide upon a key beforehand. Let's say the key is &lt;code&gt;test123&lt;/code&gt;. They keep this key to themselves&lt;/li&gt;
&lt;li&gt;Alice wants to send a message &lt;code&gt;Hi&lt;/code&gt; to Bob&lt;/li&gt;
&lt;li&gt;Alice encrypts the message &lt;code&gt;Hi&lt;/code&gt; with the key &lt;code&gt;test123&lt;/code&gt; which gives an output of &lt;code&gt;my+looOXzJkrnYs/RCK9nA==&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Alice send the encrypted message &lt;code&gt;my+looOXzJkrnYs/RCK9nA==&lt;/code&gt; to Bob.&lt;/li&gt;
&lt;li&gt;Bob uses the key &lt;code&gt;test123&lt;/code&gt; to decrypt the encrypted message &lt;code&gt;my+looOXzJkrnYs/RCK9nA==&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The decryption gives an output of &lt;code&gt;Hi&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This way we make sure that the conversation between Alice and Bob is &lt;strong&gt;mildly&lt;/strong&gt; private.&lt;/p&gt;

&lt;p&gt;Why &lt;strong&gt;mildly&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If Alice and Bob can't meet physically they would have to share the key &lt;code&gt;test123&lt;/code&gt; to each other, over the internet, which again can be intercepted by a middleman.&lt;/li&gt;
&lt;li&gt;This makes symmetric key cryptography not really helpful for private conversations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Modern cryptography solves this problem by using &lt;strong&gt;asymmetric&lt;/strong&gt; encryption/decryption&lt;/p&gt;

&lt;h1&gt;
  
  
  Asymmetric key cryptography or Public Key Cryptography
&lt;/h1&gt;

&lt;p&gt;In asymmetric key cryptography, one key is used to encrypt a message while a different key is used to decrypt that message. How that works: You will have to look at something called the &lt;code&gt;Extended Euclidian Algorithm&lt;/code&gt;, which I won't be covering in this article. &lt;/p&gt;

&lt;p&gt;In asymmetric key cryptography, each participant in the conversation has a pair of keys: public key and a private key. &lt;/p&gt;

&lt;p&gt;And as they sound a public key is something which you share with others freely without fear of your conversation being hacked. While a private key is something you keep to yourself. You can compare public key/private key to username/password. &lt;/p&gt;

&lt;p&gt;A public key and private key are 2 really large numbers (about a 100 digits) mathematically related to each other. But it's really really hard to derive the private key from the public key and vice-versa.&lt;/p&gt;

&lt;p&gt;It will take hundreds of years to derive a private key from a public key even with many supercomputers. But it's not hard to create a pair of public and private keys and that's the beauty of it.&lt;/p&gt;

&lt;p&gt;Here's a sample table of the pair of keys (public and private) which Bob and Alice have&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%2Fqjioclnn4zqxlh9tji3a.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%2Fqjioclnn4zqxlh9tji3a.png" alt="Alt Text" width="800" height="250"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;According to the above table, Alice's public key is &lt;code&gt;public_key1&lt;/code&gt; which we will abbreviate to &lt;code&gt;PB1&lt;/code&gt; and her private key is &lt;code&gt;private_key1&lt;/code&gt; which we will abbreviate to &lt;code&gt;PV1&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Whereas Bob's public key is &lt;code&gt;public_key2&lt;/code&gt; which we will abbreviate to &lt;code&gt;PB2&lt;/code&gt; and his private key is &lt;code&gt;private_key2&lt;/code&gt; which we will abbreviate to &lt;code&gt;PV2&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A message encrypted with a public key can only be decrypted with the corresponding private key and vice versa.&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Example: only Bob's private key can decrypt a message encrypted with Bob's public key. Only Alice's private key can decrypt a message encrypted with Alice's public key. &lt;/p&gt;

&lt;p&gt;This opens up a whole new world in software. Let's see how.&lt;/p&gt;

&lt;p&gt;Here's how a conversation between Alice and Bob would go with &lt;strong&gt;asymmetric&lt;/strong&gt; key cryptography&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Alice and Bob share their respective public keys, &lt;code&gt;PB1&lt;/code&gt; and &lt;code&gt;PB2&lt;/code&gt; with each other. This is usually done with a common database. &lt;/li&gt;
&lt;li&gt;Alice wants to send a message &lt;code&gt;Hi&lt;/code&gt; to Bob.&lt;/li&gt;
&lt;li&gt;Alice encrypts the message &lt;code&gt;Hi&lt;/code&gt; with Bob's &lt;strong&gt;public&lt;/strong&gt; key &lt;code&gt;PB2&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Alice sends the encrypted message to Bob&lt;/li&gt;
&lt;li&gt;Since only Bob's &lt;strong&gt;private&lt;/strong&gt; key &lt;code&gt;PV2&lt;/code&gt; can decrypt the encrypted message as specified earlier, Alice can be sure that no one but Bob can read the message&lt;/li&gt;
&lt;li&gt;Bob receives the encrypted message&lt;/li&gt;
&lt;li&gt;He decrypts it with his &lt;strong&gt;private&lt;/strong&gt; key &lt;code&gt;PV2&lt;/code&gt; and reads it.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Great! So one problem solved. But a middleman can still intercept the message, write a new one on top of it, encrypt the new message with Bob's public key &lt;code&gt;PB2&lt;/code&gt; and pass it on to Bob. This reminds us of the other problem we are supposed to solve. How does Bob know that the message is really from Alice. &lt;/p&gt;

&lt;p&gt;Now remember, &lt;code&gt;A message encrypted with a public key can only be decrypted with the corresponding private key and vice versa.&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;Here's what Alice can do now so that Bob can know if a message is really from Alice:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Alice can encrypt the message with her private key. &lt;code&gt;PV1&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;So the message can only be decrypted by using Alice's public key &lt;code&gt;PB1&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Alice sends the encrypted message to Bob&lt;/li&gt;
&lt;li&gt;Bob tries to decrypt the message with Alice's public key &lt;code&gt;PB1&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;If the message is successfully decrypted, then Bob knows the message was encrypted by Alice's private key which implies that the message was really sent by Alice since only Alice knows her private key.&lt;/li&gt;
&lt;li&gt;If the message can't be successfully decrypted then Bob knows that the message is not from Alice&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;But we are faced with the first problem again. Since Alice's public key is known to everyone, anyone can decrypt the message and see the content inside. So it's a loop of problems. We either make sure that the message isn't read by anyone or we make sure that the message isn't altered by anyone.&lt;/p&gt;

&lt;p&gt;Fortunately there is a work around for this&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Alice can first encrypt a message with Bob's public key &lt;code&gt;PB2&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Alice can then encrypt the &lt;strong&gt;encrypted&lt;/strong&gt; message with her private key. &lt;code&gt;PV1&lt;/code&gt;. This step is known as &lt;strong&gt;signing&lt;/strong&gt; the message.&lt;/li&gt;
&lt;li&gt;This way even if anyone tries to decrypt the message with Alice's public key, all they will see is another encrypted message which only Bob can decrypt using his private key.&lt;/li&gt;
&lt;li&gt;Alice then sends the message to Bob&lt;/li&gt;
&lt;li&gt;Bob will first decrypt the encrypted message with Alice's public key &lt;code&gt;PB1&lt;/code&gt;which will return another encrypted message&lt;/li&gt;
&lt;li&gt;Bob will then decrypt this "another' encrypted message with his private key &lt;code&gt;PV2&lt;/code&gt; and read the message&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This way we can be sure that no one can listen in on the conversation and no one can alter the conversation. Note that this is only applicable when the private key is kept secret by the person it belongs to.&lt;/p&gt;

&lt;p&gt;This is how modern cryptography works and this is the core which powers the revolutionary tech like blockchain and cryptocurrency. I hope this article was helpful to you. Stay tuned for more articles in the &lt;strong&gt;Blockchain for the average web developer&lt;/strong&gt; series.&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>cryptography</category>
    </item>
    <item>
      <title>Manage dynamic and custom subdomains in React</title>
      <dc:creator>Parth Patil</dc:creator>
      <pubDate>Mon, 23 Aug 2021 15:43:03 +0000</pubDate>
      <link>https://dev.to/parth2412/manage-dynamic-and-custom-subdomains-in-react-3071</link>
      <guid>https://dev.to/parth2412/manage-dynamic-and-custom-subdomains-in-react-3071</guid>
      <description>&lt;p&gt;How do websites such as hashnode.com, give a separate and custom domain for every user? for example &lt;a href="https://parth2412.hashnode.dev/" rel="noopener noreferrer"&gt;https://parth2412.hashnode.dev&lt;/a&gt;. This question has always dazzled me.  The way they do it seems like magic. Or at least that's what I thought. This article guides you through managing dynamic and custom subdomains in a react app.&lt;/p&gt;

&lt;p&gt;In this article we will build a simple and minimalistic react app in which each user would have a custom subdomain based on their username and going to that subdomain would show the profile of the user, which will include the user's age, name and hobbies. And going to the main domain will show the links to all the user's subdomains. &lt;/p&gt;

&lt;p&gt;For example, if a user has a username of &lt;em&gt;john&lt;/em&gt; , age &lt;em&gt;15&lt;/em&gt; and hobbies of &lt;em&gt;Football and Cricket,&lt;/em&gt; then going to the url &lt;code&gt;john.domain.com&lt;/code&gt; will show the name ("john"), age (15) and hobbies (Football and Cricket) of the user "john", where &lt;code&gt;domain.com&lt;/code&gt; is assumed to be the primary domain of our app.&lt;/p&gt;

&lt;p&gt;The data for the users would be dummy data and not from the database. &lt;/p&gt;

&lt;h2&gt;
  
  
  What is a subdomain?
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;A subdomain is an add-on to your primary domain name. Essentially, a subdomain is a separate part of your website that operates under the same primary domain name.&lt;/p&gt;

&lt;p&gt;Your primary domain name could be “bestwebdesigner.com,” while you could add a subdomain to that domain called “blog.bestwebdesigner.com.”&lt;/p&gt;

&lt;p&gt;Subdomains give you the freedom of creating an entirely new website, while still using the same domain name. Plus, you can usually create an unlimited number of subdomains for every domain you own.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Source : &lt;a href="https://www.hostgator.com/blog/whats-a-subdomain/" rel="noopener noreferrer"&gt;https://www.hostgator.com/blog/whats-a-subdomain/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Go &lt;a href="https://www.hostgator.com/blog/whats-a-subdomain/" rel="noopener noreferrer"&gt;here&lt;/a&gt; for more information.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;React Basics (Hooks and Functional Components)&lt;/li&gt;
&lt;li&gt;Javascript basics (window object and array functions)&lt;/li&gt;
&lt;li&gt;Basic knowledge about domains and subdomains&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Getting started...
&lt;/h2&gt;

&lt;p&gt;Start by creating a react app.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npx create-react-app dynamic-subdomains&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;&lt;code&gt;cd dynamic-subdomains&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm start&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You can name your app whatever you want.&lt;/p&gt;

&lt;h3&gt;
  
  
  How would you use subdomains on localhost?
&lt;/h3&gt;

&lt;p&gt;I thought using subdomains on &lt;a href="http://localhost" rel="noopener noreferrer"&gt;localhost&lt;/a&gt; would require quite a bit of configuration. But I couldn't be more wrong. For example, if your react app is running on &lt;a href="http://localhost:3000" rel="noopener noreferrer"&gt;localhost:3000&lt;/a&gt; , then going to the url &lt;code&gt;john.localhost:3000&lt;/code&gt; or &lt;code&gt;jane.localhost:3000&lt;/code&gt; or any other subdomain will still show your react app. No configuration needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  How can you show different content based on the subdomain in react?
&lt;/h2&gt;

&lt;p&gt;The following code is how we access the subdomain from the full domain using &lt;strong&gt;pure javascript&lt;/strong&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%2Fjvbutojljc1vgb8em8dh.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%2Fjvbutojljc1vgb8em8dh.png" alt="carbon.png" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's see what's happening here&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We get the full domain of the app using &lt;code&gt;window.location.host&lt;/code&gt; (Only the domain not the full url). &lt;/li&gt;
&lt;li&gt;Suppose the url is &lt;a href="https://javascript.plainenglish.io/dear-developer-this-is-how-you-center-a-div-e526e7cfcc9d" rel="noopener noreferrer"&gt;https://javascript.plainenglish.io/dear-developer-this-is-how-you-center-a-div-e526e7cfcc9d&lt;/a&gt; then the host will be &lt;code&gt;javascript.plainenglish.io&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;We split the domain into an array wherever we find a &lt;code&gt;.&lt;/code&gt; . The resulting array would be &lt;code&gt;["javascript", "plainenglish" , "io"]&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;If the primary domain is &lt;strong&gt;not localhost&lt;/strong&gt;, we remove the last 2 elements of the obtained array. The last element is the suffix of the domain such as .org, .com, .net, .io, etc. The 2nd last element of the obtained array would be the main (primary) domain of the app.&lt;/li&gt;
&lt;li&gt; In the example, the last element of the array is the suffix &lt;code&gt;io&lt;/code&gt;. The second last element is the primary domain &lt;code&gt;plainenglish&lt;/code&gt;.  Thus we are left with the array &lt;code&gt;["javascript"]&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;If the array has 0 elements then there is no subdomain. If not, the subdomain is the first element of the array. Thus the subdomain is &lt;code&gt;javascript&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Another example for development where the primary domain is &lt;code&gt;localhost&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Suppose the host (full domain) is &lt;code&gt;sub.localhost:3000&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;After splitting the domain wherever we find a &lt;code&gt;.&lt;/code&gt;, we get the array &lt;code&gt;["sub", "localhost:3000"]&lt;/code&gt; .&lt;/li&gt;
&lt;li&gt;Since the primary domain is localhost, it means that the domain doesn't have a suffix such as .com or .org . So instead of 2 we just remove 1 element from the end of the array. Thus we are left with the array &lt;code&gt;["sub"]&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;If the array has 0 elements then there is no subdomain. If not, the subdomain is the first element of the array. Thus the subdomain is &lt;code&gt;sub&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Note
&lt;/h3&gt;

&lt;p&gt;Subdomains can be nested under many levels too i.e there can be multiple subdomains such as &lt;a href="http://a.b.c.d.example.com" rel="noopener noreferrer"&gt;a.b.c.d.example.com&lt;/a&gt; . But this article will only focus on handling one level of subdomain.&lt;/p&gt;

&lt;p&gt;Getting back to our react app, we will now see how the above code should be written in the react format. &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%2Fkxx5dmjmie4kmnpfa0fe.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%2Fkxx5dmjmie4kmnpfa0fe.png" alt="carbon (1).png" width="800" height="528"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The same thing's happening here but instead of storing the subdomain in a variable we are storing the subdomain in React state, also we are extracting the subdomain in the useEffect callback.&lt;/p&gt;

&lt;p&gt;Let's add the dummy data for the users.&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%2Fg0cbqu32cqrh1hhbmeiq.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%2Fg0cbqu32cqrh1hhbmeiq.png" alt="carbon (3).png" width="800" height="677"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here we have an array of users.&lt;/p&gt;

&lt;p&gt;Each user has a unique username , an age and a list of hobbies.&lt;/p&gt;

&lt;p&gt;So when we go to the url &lt;code&gt;john.localhost:3000&lt;/code&gt; , it will show the name, age and hobbies of the user "john".&lt;/p&gt;

&lt;p&gt;Thus the url &lt;code&gt;jane.localhost:3000&lt;/code&gt; will show the name, age and hobbies of the user "jane".&lt;/p&gt;

&lt;p&gt;Thus in this app, each user will be assigned a subdomain (which will be equal to their username) and going to that subdomain will show the user's name, age and hobbies&lt;/p&gt;

&lt;p&gt;The next and last part is really easy. We just have to use the &lt;code&gt;subdomain&lt;/code&gt; value stored in the state to display the appropriate content.&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%2F87g5504cs9eydvq96mji.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%2F87g5504cs9eydvq96mji.png" alt="carbon (5).png" width="800" height="853"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As simple as that.&lt;/p&gt;

&lt;p&gt;We get the &lt;code&gt;subdomain&lt;/code&gt; and use that to find the user whose &lt;code&gt;username&lt;/code&gt; is the same as the &lt;code&gt;subdomain&lt;/code&gt; and store the user in the &lt;code&gt;requestedUser&lt;/code&gt; variable.&lt;/p&gt;

&lt;p&gt;If there is no user whose username is the same as the subdomain, then we display a text of &lt;em&gt;Not Found&lt;/em&gt; . Else we display the name, age and hobbies of the user. &lt;/p&gt;

&lt;p&gt;Here's how it looks. P.S I am using the port 3001 since port 3000 is already being used&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%2Fkch1uhc8va56uig67fml.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%2Fkch1uhc8va56uig67fml.png" alt="carbon (11).png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's how the website looks when the requestedUser is not found&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%2Fcc9w8myzjrv9ah6r3luw.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%2Fcc9w8myzjrv9ah6r3luw.png" alt="carbon (7).png" width="800" height="500"&gt;&lt;/a&gt;&lt;br&gt;
Let's take it up a notch higher and make it such that there is no subdomain , i.e the when the user who is looking at the website, is on our main domain, then we display a link to all of the user's subdomains.&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%2F7qsyl16e999thqlnlgki.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%2F7qsyl16e999thqlnlgki.png" alt="carbon (8).png" width="800" height="1141"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's whats happening:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We check whether there is a subdomain or not.&lt;/li&gt;
&lt;li&gt;If yes, then the requestedUser's data is shown&lt;/li&gt;
&lt;li&gt;If no, then a list of the links to all the user's subdomains is shown&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here's how it looks on the main domain.&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%2F40pe4vtj6ekuzbem5e8w.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%2F40pe4vtj6ekuzbem5e8w.png" alt="carbon (10).png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Coming Next
&lt;/h2&gt;

&lt;p&gt;How to handle dynamic subdomains in a NextJS app&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuring subdomains for production
&lt;/h2&gt;

&lt;p&gt;Most hosting providers allow to configure dynamic subdomains. And usually dynamic subdomains come free when buying a domain.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Vercel : &lt;a href="https://vercel.com/blog/wildcard-domains" rel="noopener noreferrer"&gt;https://vercel.com/blog/wildcard-domains&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Netlify : &lt;a href="https://docs.netlify.com/domains-https/custom-domains/multiple-domains/#branch-subdomains" rel="noopener noreferrer"&gt;https://docs.netlify.com/domains-https/custom-domains/multiple-domains/#branch-subdomains&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Google cloud : &lt;a href="https://cloud.google.com/appengine/docs/flexible/go/mapping-custom-domains#wildcards" rel="noopener noreferrer"&gt;https://cloud.google.com/appengine/docs/flexible/go/mapping-custom-domains#wildcards&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Github repo : &lt;a href="https://github.com/Parth-2412/Dynamic-Subdomains" rel="noopener noreferrer"&gt;https://github.com/Parth-2412/Dynamic-Subdomains&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>domains</category>
      <category>subdomains</category>
    </item>
    <item>
      <title>Introduction to Generators in JavaScript</title>
      <dc:creator>Parth Patil</dc:creator>
      <pubDate>Thu, 05 Aug 2021 08:37:56 +0000</pubDate>
      <link>https://dev.to/parth2412/introduction-to-generators-in-javascript-5hn8</link>
      <guid>https://dev.to/parth2412/introduction-to-generators-in-javascript-5hn8</guid>
      <description>&lt;p&gt;Generators are an advanced concept in javascript but are quite easy to understand. Generators are special functions in javascript which can return multiple values on demand unlike regular functions which can only return one value. &lt;/p&gt;

&lt;p&gt;Unlike normal functions, the execution of a generator function can be stopped &lt;strong&gt;midway&lt;/strong&gt; and can be resumed. &lt;/p&gt;

&lt;h2&gt;
  
  
  How to create a generator function
&lt;/h2&gt;

&lt;p&gt;There is a special syntax for creating a generation function which is not much different from the normal function syntax.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nf"&gt;generatorFunction&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;The * after the function keyword is what makes this function a generator function. &lt;/p&gt;

&lt;h2&gt;
  
  
  How to use the generator function created above
&lt;/h2&gt;

&lt;p&gt;Another keyword yield is introduced here. You can think of yield as the return keyword but for generator functions. Let's take an example here&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nf"&gt;generatorFunction&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Start&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="mi"&gt;7&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Midway&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="mi"&gt;8&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Stop&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;gen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;generatorFunction&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;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;gen&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;next&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;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// logs 7&lt;/span&gt;
&lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;gen&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;next&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;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// logs 8&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's see what's happening here:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We define a generator function which first yields (returns) the number 7 and then next yields the number 8. We also added a couple of console logs.&lt;/li&gt;
&lt;li&gt;We call the generatorFunction here and store the return value in the variable &lt;code&gt;gen&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Normally when using normal functions you will expect the &lt;code&gt;gen&lt;/code&gt; variable to hold the value 7. &lt;/li&gt;
&lt;li&gt;But that's not the case for generators.  The &lt;code&gt;gen&lt;/code&gt; variable doesn't store the value yielded by the generator, instead it stores a &lt;code&gt;Generator&lt;/code&gt; object returned by &lt;code&gt;generatorFunction&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;gen&lt;/code&gt; object has a method &lt;code&gt;next()&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;The first call of the &lt;code&gt;gen.next()&lt;/code&gt; method starts the execution of the generator function and when it reaches a &lt;code&gt;yield&lt;/code&gt;, it stops the function there and returns an object which has 2 properties &lt;code&gt;value&lt;/code&gt; and &lt;code&gt;done&lt;/code&gt;.   &lt;strong&gt;Value&lt;/strong&gt; is the yielded value and &lt;strong&gt;done&lt;/strong&gt; is a boolean which tells us whether the generator function is done completely executing or not&lt;/li&gt;
&lt;li&gt;So in the above example, when &lt;code&gt;gen.next()&lt;/code&gt; is called for the first time, the generator function starts executing. "Start" is logged to the console and then the generator yields a value of 7. That's when it stops the function and returns an object, which (in this case) will be &lt;code&gt;{ value : 7 , done : false }&lt;/code&gt;. &lt;strong&gt;value&lt;/strong&gt; is the yielded value which is 7. &lt;strong&gt;done&lt;/strong&gt; is &lt;code&gt;false&lt;/code&gt; because the generator is not completely executed yet; there are still some lines of code in the function yet to be executed. "7" is logged to the console.&lt;/li&gt;
&lt;li&gt;The next (second) call of the &lt;code&gt;gen.next()&lt;/code&gt; method resumes the generator function from the point it stopped at before. Thus, "Midway" is logged to the console and then the generator yields a value of 8. It stops the function there and returns  &lt;code&gt;{ value: 8, done: false}&lt;/code&gt; since the yielded value is 8 and the function is still not done executing. "8" is logged to the console.&lt;/li&gt;
&lt;li&gt;"Stop" is never logged to the console since we never call &lt;code&gt;gen.next()&lt;/code&gt; again&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Notes
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;In the above example, if we call &lt;code&gt;gen.next()&lt;/code&gt; for a third time, "Stop" will be logged on the console and the object returned would be &lt;code&gt;{value : undefined, done : true}&lt;/code&gt;. Notice how this time the done property is true? That's because all the code of the generator is done executing. Whereas the value property is undefined? That's because no value has been yielded by the generator. If you keep calling &lt;code&gt;gen.next()&lt;/code&gt; after this, the result will always be &lt;code&gt;{value : undefined, done : true}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A generator object cannot be restarted. Once it's done completely executing, you cannot restart it. If you want to run a generator function again make a new &lt;code&gt;Generator&lt;/code&gt; object by calling &lt;code&gt;generatorFunction&lt;/code&gt; and store it in a new variable. Then you can work with that variable.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Example :&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;newGen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;generatorFunction&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;newResult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;newGen&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;next&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;newResult&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// logs 7&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

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


&lt;/li&gt;

&lt;/ul&gt;

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