<?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: Deepak Gupta</title>
    <description>The latest articles on DEV Community by Deepak Gupta (@dg92).</description>
    <link>https://dev.to/dg92</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%2F71374%2Fc386c0bc-232b-458e-a161-3ba004c723b9.jpeg</url>
      <title>DEV Community: Deepak Gupta</title>
      <link>https://dev.to/dg92</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dg92"/>
    <language>en</language>
    <item>
      <title>Smart Contracts &amp; Their Limitations</title>
      <dc:creator>Deepak Gupta</dc:creator>
      <pubDate>Wed, 16 Nov 2022 10:11:54 +0000</pubDate>
      <link>https://dev.to/dg92/smart-contracts-their-limitations-3gad</link>
      <guid>https://dev.to/dg92/smart-contracts-their-limitations-3gad</guid>
      <description>&lt;p&gt;In recent years, the use of blockchain technology has exploded. An innovation that drove the large-scale adoption of blockchain is Smart contracts and the Ethereum virtual machine. Let’s dive into what smart contracts are in general.&lt;/p&gt;

&lt;p&gt;A smart contract is code distributed and stored across a peer-to-peer network that can be called to execute logic and store information. The term &lt;code&gt;smart contracts&lt;/code&gt; was coined because of their nature; they are public, immutable, self-enforceable, self-verifying, and any actors interacting with the contracts are agreeing to the outcomes.&lt;/p&gt;

&lt;p&gt;Although the concept of smart contracts is quite old, it wasn’t until Ethereum’s virtual machine that smart contracts as they are known today sprung to fruition.&lt;/p&gt;

&lt;p&gt;The introduction of smart contracts has revolutionized what is possible beyond a simple ledger on the blockchain: derivatives, automated market makers, NFTs, identity security, GameFi, and more.&lt;/p&gt;

&lt;p&gt;Improved forks of the EVM (Ethereum Virtual Machine) have been developed over time, but the core functionality of smart contracts has relatively stayed the same. This is great for composability across various chains and networks, but the limitations of smart contracts are also apparent throughout the web 3 space.&lt;/p&gt;

&lt;h2&gt;
  
  
  Smart Contract Limitations
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Deprecated Logic
&lt;/h3&gt;

&lt;p&gt;It is possible to use existing logic on the chain via delegation and libraries, meaning existing logic does not have to be redeployed on the chain. This is an amazing feature of the EVM and reduces development costs. However, breaking version changes, changing standard implementations, and gas-efficiency improvements frequently render old libraries obsolete. Since different chains don’t generally share the same state, logic must be deployed on each chain that an actor wants to interact with. More than 60% of smart contracts never see any real use.&lt;/p&gt;

&lt;h3&gt;
  
  
  Gas and Size Restrictions
&lt;/h3&gt;

&lt;p&gt;Ideally more and more complex logic can be added to the chain over time, building a diverse support network; yet progress has been disappointingly slow. Some logic is also not viable to store on chain due to the sheer file size of the solution.&lt;/p&gt;

&lt;p&gt;This is a problem both for the actor that deploys or uploads the contract, as they must effectively pay for the nodes to store the code forever; and whenever the contract is interacted with, as more complex code requires more opcodes which also accrues gas costs. Gas prices and the cost of the chain’s underlying denomination make deploying logic to the blockchain expensive and reliance on low-level calls can be greatly impacted by chain congestion.&lt;/p&gt;

&lt;h3&gt;
  
  
  Automation
&lt;/h3&gt;

&lt;p&gt;Another big limitation of smart contracts is their lack of autonomy: all events on the blockchain are triggered by an externally owned account (EOA). Contracts can interact with other contracts but typically need explicit integration logic in their code and can only do so when instructed to by an EOA.&lt;/p&gt;

&lt;h3&gt;
  
  
  Data
&lt;/h3&gt;

&lt;p&gt;Lastly, Data is another limitation of smart contracts. Any information on the network (if public) is reliable and inexpensive, but all other data can only be introduced by an EOA which introduces a host of security issues.&lt;/p&gt;

&lt;p&gt;Stay tuned for the next article where we will learn how various protocols are tackling these problems and working to provide solutions.&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>web3</category>
      <category>smartcontract</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Javascript features you might not know in 2019-2020</title>
      <dc:creator>Deepak Gupta</dc:creator>
      <pubDate>Wed, 25 Sep 2019 14:01:22 +0000</pubDate>
      <link>https://dev.to/dg92/javascript-feature-you-might-not-know-in-2019-2020-4p5d</link>
      <guid>https://dev.to/dg92/javascript-feature-you-might-not-know-in-2019-2020-4p5d</guid>
      <description>&lt;h1&gt;
  
  
  Private Class field👇
&lt;/h1&gt;

&lt;p&gt;Until ES6, we were not able to declare private properties directly. Yes there were ways like underscore convention (_propertyName), &lt;a href="https://curiosity-driven.org/private-properties-in-javascript" rel="noopener noreferrer"&gt;closures, symbols, or WeakMaps.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But now private class fields use a hash # prefix. Let’s learn it by an example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Test&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;          &lt;span class="c1"&gt;// .a is public&lt;/span&gt;
  &lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;         &lt;span class="c1"&gt;// .#b is private&lt;/span&gt;
  &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="nx"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// .#c is private and static&lt;/span&gt;
  &lt;span class="nf"&gt;incB&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="err"&gt;#&lt;/span&gt;&lt;span class="nx"&gt;b&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="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;testInstance&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;Test&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;// runs OK&lt;/span&gt;
&lt;span class="nx"&gt;testInstance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;incB&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;// error - private property cannot be modified outside class&lt;/span&gt;
&lt;span class="nx"&gt;testInstance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="nx"&gt;b&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Note: There’s no way to define the private function as of now, although a &lt;a href="https://github.com/tc39/proposal-private-methods" rel="noopener noreferrer"&gt;TC39 stage 3: draft proposal&lt;/a&gt; suggests using a hash # prefix on names. 🤞&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  String.matchAll()👇
&lt;/h1&gt;

&lt;p&gt;If I have a string, with a global regular expression which has many capturing groups, I often want to iterate through all groups. Currently, my options are the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;String.prototype.match() with /g&lt;/strong&gt;— If we use .match() with a regular expression whose flag /g is set, you get all full matches for it in an Array.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;String.prototype.split()&lt;/strong&gt; — If we use a split string and regular expression to specify the separator and if it contains at least one capture group then .split() returns an Array in which the substrings are interleaved.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The issues with the above approach are that they only work if /g is set on regular expression and the property .lastIndex of a regular expression is changed each time a match happens. This makes using the same regular expression at multiple locations risky.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;matchAll()&lt;/strong&gt; help resolve all above. Let’s check out the definition and usage&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Given a string and a regular expression, .matchAll() returns all results matching a string against a regular expression, including capturing groups.&lt;/em&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;regexp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sr"&gt;/t&lt;/span&gt;&lt;span class="se"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;e&lt;/span&gt;&lt;span class="se"&gt;)(&lt;/span&gt;&lt;span class="sr"&gt;st&lt;/span&gt;&lt;span class="se"&gt;(\d?))&lt;/span&gt;&lt;span class="sr"&gt;/g&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;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;test1test2&lt;/span&gt;&lt;span class="dl"&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;array&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;str&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;matchAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;regexp&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;array&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;// expected output: Array ["test1", "e", "st1", "1"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Note: .matchAll() returns an iterator, not a true restartable iterable. That is, once the result is exhausted, you need to call the method again and create a new iterator.&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Numeric Separators👇
&lt;/h1&gt;

&lt;p&gt;If you have struggled to read a long sequence of number, this is where your search end.&lt;/p&gt;

&lt;p&gt;Numeric Separators allow the human eye to parse quickly, especially when there are lots of repeating digits:&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="mi"&gt;1000000000000&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="nx"&gt;_000_000_000_000&lt;/span&gt;
&lt;span class="mf"&gt;1019436871.42&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="nx"&gt;_019_436_871&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now it’s easier to tell that the first number is a trillion, and the second number is in the order of 1 billion.&lt;/p&gt;

&lt;p&gt;It also works on other bases, for example:&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;const&lt;/span&gt; &lt;span class="nx"&gt;fileSystemPermission&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mb"&gt;0b111_111_000&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;bytes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mb"&gt;0b1111_10101011_11110000_00001101&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;words&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;0xFAB&lt;/span&gt;&lt;span class="nx"&gt;_F00D&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also use the separator in the fractions and exponents:&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;const&lt;/span&gt; &lt;span class="nx"&gt;massOfElectronInKg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;9.109&lt;/span&gt;&lt;span class="nx"&gt;_383_56e&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;31&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;trillionInShortScale&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="nx"&gt;e1_2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Note: Parsing the _ separated integer can be tricky as Number('123_456') gives NAN whereas parseInt('123_456') gives 123.&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  BigInt’s👇
&lt;/h1&gt;

&lt;p&gt;BigInts are a new numeric primitive in JavaScript that can represent integers with precision larger than 2⁵³–1. With BigInts, you can safely store and operate on large integers even beyond the safe integer limit for Numbers.&lt;/p&gt;

&lt;p&gt;BigInts correctly perform integer arithmetic without overflowing. Let’s understand by an example:-&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;const&lt;/span&gt; &lt;span class="nx"&gt;max&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;MAX_SAFE_INTEGER&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// 9007199254740991&lt;/span&gt;
&lt;span class="nx"&gt;max&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// 9007199254740992&lt;/span&gt;
&lt;span class="nx"&gt;max&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// 9007199254740991&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can see that max + 1 produces the same result as max + 2 .&lt;/p&gt;

&lt;p&gt;Any calculation on integers outside the safe integer range (i.e. from Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER) potentially loses precision. For this reason, we can only rely on numeric integer values within the safe range.&lt;/p&gt;

&lt;p&gt;Therefore, BigInts came to existence, BigInts can be created by adding the n suffix to any integer literal. For example, 123 becomes 123n or the global BigInt(number) function can be used to convert a Number into a BigInts.&lt;/p&gt;

&lt;p&gt;Let’s revisit the above example with BigInts&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="nc"&gt;BigInt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;MAX_SAFE_INTEGER&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// 9007199254740993n&lt;/span&gt;
&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="mi"&gt;123&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;
&lt;span class="c1"&gt;// "bigint2"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Note: Numeric separators are especially helpful with BigInts, for eg:&lt;/em&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;const&lt;/span&gt; &lt;span class="nx"&gt;massOfEarthInKg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="nx"&gt;_000_000_000_000_000_000_000_000n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;BigInts support the most common operators. Binary +, -, &lt;em&gt;, and *&lt;/em&gt; all work as expected. / and % work, and round towards zero as needed.&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="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// → 1&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// → 1n&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Note: One gotcha is that it’s not allowed to mix operations between BigInts and Numbers&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Locale String with BigInt👇
&lt;/h1&gt;

&lt;p&gt;The toLocaleString() method returns a string with a language-sensitive representation of the BigInt.&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;bigint&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;123456789123456789&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// German uses period for thousands&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;bigint&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLocaleString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;de-DE&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="c1"&gt;// → 123.456.789.123.456.789&lt;/span&gt;

&lt;span class="c1"&gt;// Arabic in most Arabic speaking countries uses Eastern Arabic digits&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;bigint&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLocaleString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ar-EG&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="c1"&gt;// → ١٢٣٬٤٥٦٬٧٨٩٬١٢٣٬٤٥٦٬٧٨٩&lt;/span&gt;

&lt;span class="c1"&gt;// India uses thousands/lakh/crore separators&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;bigint&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLocaleString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;en-IN&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="c1"&gt;// → 1,23,45,67,89,12,34,56,789&lt;/span&gt;

&lt;span class="c1"&gt;// the nu extension key requests a numbering system, e.g. Chinese decimal&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;bigint&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLocaleString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;zh-Hans-CN-u-nu-hanidec&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="c1"&gt;// → 一二三,四五六,七八九,一二三,四五六,七八九&lt;/span&gt;

&lt;span class="c1"&gt;// when requesting a language that may not be supported, such as&lt;/span&gt;
&lt;span class="c1"&gt;// Balinese, include a fallback language, in this case Indonesian&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;bigint&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLocaleString&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ban&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;id&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]));&lt;/span&gt;
&lt;span class="c1"&gt;// → 123.456.789.123.456.789&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  GlobalThis Keyword👇
&lt;/h1&gt;

&lt;p&gt;JavaScript’s variable scopes are nested and form a tree whose root is the global scope and the value of this keyword is a reference to the object that “owns” the currently executing code or the function where its looked at.&lt;/p&gt;

&lt;p&gt;To read more about this keyword and global scope read my below articles&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://overflowjs.com/posts/Scopes-in-Javascript-2019.html" rel="noopener noreferrer"&gt;Scopes in Javascript&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://overflowjs.com/posts/This-keyword-In-Javascript-2019-Javascript-Context.html" rel="noopener noreferrer"&gt;Understanding Javascript ‘this’ keyword (Context)&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Usually to figure out the global this we use a function like&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;const&lt;/span&gt; &lt;span class="nx"&gt;getGlobalThis&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="c1"&gt;// in webworker or service worker&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;undefined&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// in browser &lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;undefined&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// in Node.js&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nb"&gt;global&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;undefined&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;global&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// Standalone javascript shell&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;undefined&lt;/span&gt;&lt;span class="dl"&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="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Unable to locate global object&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;theGlobalThis&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;getGlobalThis&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above function does not cover all cases when we need global this value.&lt;/p&gt;

&lt;p&gt;In the case of use strict the value of this is undefined.&lt;/p&gt;

&lt;p&gt;When we form a bundle in the javascript it usually wraps under some code that might differ the global this.&lt;/p&gt;

&lt;p&gt;In Standalone javascript engine shell environment, the above code will not work.&lt;/p&gt;

&lt;p&gt;To solve the above problem globalThis keyword is introduced which returns global this object in any environment at any time.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: The global object is now considered a mistake that JavaScript can’t get rid of, due to backward compatibility. It affects performance negatively and is generally confusing.&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Promise.allSettled()👇
&lt;/h1&gt;

&lt;p&gt;If you are wondering what’s promise is in javascript then check out this — &lt;a href="https://developers.google.com/web/fundamentals/primers/promises" rel="noopener noreferrer"&gt;JavaScript Promises: an Introduction.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A little gist, a promise is JavaScript’s way of promising you that work will be done (or might fail if the work could not be completed).&lt;/p&gt;

&lt;p&gt;The new method returns a promise that resolves after all of the given promises have settled i.e either resolved or rejected, with an array of objects that each describe the outcome of each promise.&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;const&lt;/span&gt; &lt;span class="nx"&gt;promise1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&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;promise2&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;Promise&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;reject&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;reject&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;foo&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;promises&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;promise1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;promise2&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;allSettled&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;promises&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;
  &lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;results&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;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;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;status&lt;/span&gt;&lt;span class="p"&gt;)));&lt;/span&gt;
&lt;span class="c1"&gt;// expected output:&lt;/span&gt;
&lt;span class="c1"&gt;// "fulfilled"&lt;/span&gt;
&lt;span class="c1"&gt;// "rejected"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is different from the Promise.all as it rejects as soon as a promise within the iterable object rejected.&lt;/p&gt;

&lt;p&gt;Below is the comparison of current supported promises method&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fzm5kfhu1dxaeacmnpgkj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fzm5kfhu1dxaeacmnpgkj.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Dynamic Import 👇
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F1wpoe7wmuqiul5ufqzxu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F1wpoe7wmuqiul5ufqzxu.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This one is crazy before we dive into it, let’s first see what static import is.&lt;/p&gt;

&lt;p&gt;Static import only accepts a string literal as the module specifier and introduces bindings into the local scope via a pre-runtime “linking” process.&lt;/p&gt;

&lt;p&gt;The static import syntax can only be used at the top-level of the file.&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="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;module&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./utils.mjs&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;A static import enables important use cases such as static analysis, bundling tools, and tree-shaking.&lt;/p&gt;

&lt;p&gt;But what about&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;import a module on-demand (or conditionally)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;compute the module specifier at runtime&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;import a module from within a regular script (as opposed to a module)&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This was not possible until dynamic imports — import(moduleSpecifier) returns a promise for the module namespace object of the requested module, which is created after fetching, instantiating, and evaluating all of the module’s dependencies, as well as the module itself.&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;script&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;module&lt;/span&gt;&lt;span class="dl"&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;async &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;const&lt;/span&gt; &lt;span class="nx"&gt;moduleSpecifier&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./utils.mjs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;module&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;moduleSpecifier&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="c1"&gt;// → logs 'Hi from the default export!'&lt;/span&gt;
    &lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;doStuff&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="c1"&gt;// → logs 'Doing stuff…'&lt;/span&gt;
  &lt;span class="p"&gt;})();&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/script&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Note: Use static imports for initial paint dependencies, especially for above-the-fold content. In other cases, consider loading dependencies on-demand with dynamic import().&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Stable Sorting — (Consistent and reliable result now)👇
&lt;/h1&gt;

&lt;p&gt;By Stable in the algorithmic sense means: does it preserve the order or otherwise “equal” items?&lt;/p&gt;

&lt;p&gt;Let’s understand by an example&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;const&lt;/span&gt; &lt;span class="nx"&gt;people&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Gary&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Ann&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Bob&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;17&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Sue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;21&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Sam&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;17&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="c1"&gt;// Sort people by name&lt;/span&gt;
&lt;span class="nx"&gt;people&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;p1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;p2&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;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;p1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;p2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;p1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;p2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&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;people&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="c1"&gt;// ['Ann', 'Bob', 'Gary', 'Sam', 'Sue']&lt;/span&gt;
&lt;span class="c1"&gt;// Re-sort people by age&lt;/span&gt;

&lt;span class="nx"&gt;people&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;p1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;p2&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;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;p1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;p2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;p1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;p2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&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;people&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="c1"&gt;// We're expecting people sorted by age, then by name within age group:&lt;/span&gt;
&lt;span class="c1"&gt;// ['Bob', 'Sam', 'Ann', 'Gary', 'Sue']&lt;/span&gt;
&lt;span class="c1"&gt;// But we might get any of these instead, depending on the browser:&lt;/span&gt;
&lt;span class="c1"&gt;// ['Sam', 'Bob', 'Ann', 'Gary', 'Sue']&lt;/span&gt;
&lt;span class="c1"&gt;// ['Bob', 'Sam', 'Gary', 'Ann', 'Sue']&lt;/span&gt;
&lt;span class="c1"&gt;// ['Sam', 'Bob', 'Gary', 'Ann', 'Sue']&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you’re getting one of the last three results, then you’re probably using Google Chrome, or maybe one of an assortment of browsers that do not implement Array.sort() as a “stable” algorithm.&lt;/p&gt;

&lt;p&gt;This is because different JS engines (across different browsers) taking different routes to implementing sort, Also, some javascript engine use stable sort for short array but for long array uses unstable sort.&lt;/p&gt;

&lt;p&gt;This lead to inconsistent in sort stability behavior and a lot of confusion. This is why in the development environment everything related to sort seems to work but in the production environment, we start to see something else due to the varying size of array the sort was tested on.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: There are 3rd party libraries, I heartily recommend &lt;a href="https://lodash.com/" rel="noopener noreferrer"&gt;Lodash&lt;/a&gt;, which has stable sort&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;But this has been resolved now, we have a stable sort on most of the browsers. The syntax remains the same.&lt;/p&gt;

&lt;p&gt;Since this article has a lot to digest and try-test features, we will continue with the more new feature in the next one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note: This article was originally published on &lt;a href="https://overflowjs.com/" rel="noopener noreferrer"&gt;overflowjs.com&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Please consider &lt;a href="https://docs.google.com/forms/d/e/1FAIpQLSd51BJWwtMbZlJQwJQ2n59Q6T7aOKqvubzqqPh9eNtuEgXBjg/viewform" rel="noopener noreferrer"&gt;entering your email here&lt;/a&gt;, if you’d like to be added to my email list and follow me on dev.to to read more article on javascript and on &lt;a href="https://github.com/dg92" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; to see my crazy code. &lt;/p&gt;

&lt;p&gt;Thank you !&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Object detection using Tensorflow.js</title>
      <dc:creator>Deepak Gupta</dc:creator>
      <pubDate>Tue, 27 Aug 2019 18:32:08 +0000</pubDate>
      <link>https://dev.to/dg92/object-detection-using-tensorflow-js-2jcn</link>
      <guid>https://dev.to/dg92/object-detection-using-tensorflow-js-2jcn</guid>
      <description>&lt;p&gt;A new article is published on overflowjs.com around detecting an object in an image using tensorflow.js two models &lt;strong&gt;imagenet&lt;/strong&gt; and &lt;strong&gt;coco-ssd&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The first part of the article talks about making the UI with react.js to upload the image and select the model from which the detection should happen.&lt;/p&gt;

&lt;p&gt;The second part of the article makes an endpoint in node.js using tensorflow.js to detect the object in the image passed.&lt;/p&gt;

&lt;p&gt;Read full article - &lt;a href="https://overflowjs.com/posts/Image-Object-Detection-Using-TensorFlowjs.html"&gt;https://overflowjs.com/posts/Image-Object-Detection-Using-TensorFlowjs.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Github code link for UI- &lt;a href="https://github.com/overflowjs-com/image_object_detction_react_ui"&gt;https://github.com/overflowjs-com/image_object_detction_react_ui&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Github code link for Backend- &lt;a href="https://github.com/overflowjs-com/image_object_detection_tensor_api"&gt;https://github.com/overflowjs-com/image_object_detection_tensor_api&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>node</category>
      <category>react</category>
      <category>tensorflow</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Angular 8 - Getting Started In 2019</title>
      <dc:creator>Deepak Gupta</dc:creator>
      <pubDate>Sun, 25 Aug 2019 15:48:53 +0000</pubDate>
      <link>https://dev.to/dg92/angular-8-getting-started-in-2019-17m5</link>
      <guid>https://dev.to/dg92/angular-8-getting-started-in-2019-17m5</guid>
      <description>&lt;p&gt;Just found a nice read on Getting Started With Angular 8 - &lt;a href="https://overflowjs.com/posts/AngularJS-Getting-Started-In-2019-Part-1.html"&gt;https://overflowjs.com/posts/AngularJS-Getting-Started-In-2019-Part-1.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The article explains &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What is Angular 8?&lt;/li&gt;
&lt;li&gt;How it is different from Angular 3.0?&lt;/li&gt;
&lt;li&gt;Help you Setup environment to run Angular?&lt;/li&gt;
&lt;li&gt;Help you make a &lt;code&gt;hello world&lt;/code&gt; app and see on localhost server.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Hope it helps someone starting with it.&lt;/p&gt;

&lt;p&gt;Happy coding&lt;/p&gt;

</description>
      <category>angular</category>
      <category>javascript</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Understanding Architecture of Angular 8</title>
      <dc:creator>Deepak Gupta</dc:creator>
      <pubDate>Wed, 21 Aug 2019 18:41:54 +0000</pubDate>
      <link>https://dev.to/dg92/understanding-architecture-of-angular-8-2ebj</link>
      <guid>https://dev.to/dg92/understanding-architecture-of-angular-8-2ebj</guid>
      <description>&lt;p&gt;Just found a nice read on Understanding Architecture of Angular 8 - &lt;a href="https://overflowjs.com/posts/Angular-Understanding-Architecture-Part-2.html"&gt;https://overflowjs.com/posts/Angular-Understanding-Architecture-Part-2.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The article explains &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Modules&lt;/li&gt;
&lt;li&gt;Components&lt;/li&gt;
&lt;li&gt;Services and Dependency Injection&lt;/li&gt;
&lt;li&gt;Component Communication - Parent to Child Component and  Child to Parent Component&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Hope it helps someone starting with it.&lt;/p&gt;

&lt;p&gt;Happy coding&lt;/p&gt;

</description>
      <category>angular</category>
      <category>javascript</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Javascript - Generator - Yield/Next VS Async-Await</title>
      <dc:creator>Deepak Gupta</dc:creator>
      <pubDate>Tue, 20 Aug 2019 17:07:32 +0000</pubDate>
      <link>https://dev.to/dg92/generator-yield-next-async-await-5a</link>
      <guid>https://dev.to/dg92/generator-yield-next-async-await-5a</guid>
      <description>&lt;h1&gt;
  
  
  Generator (ES6)-
&lt;/h1&gt;

&lt;p&gt;Functions that can return multiple values at a different time interval, as per the user demands and can manage its internal state are generator functions. A function becomes a GeneratorFunction if it uses the function* syntax.&lt;/p&gt;

&lt;p&gt;They are different from the normal function in the sense that normal function run to completion in a single execution whereas generator function can be paused and resumed, so they do run to completion but the trigger remains in our hand. They allow better execution control for asynchronous functionality but that does not mean they cannot be used as synchronous functionality.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: When a generator function is executed it returns a new Generator object.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The pause and resume are done using yield&amp;amp;next. So let's look at what are they and what they do.&lt;/p&gt;

&lt;h1&gt;
  
  
  Yield/Next-
&lt;/h1&gt;

&lt;p&gt;The yield keyword pauses generator function execution and the value of the expression following the yield keyword is returned to the generator's caller. It can be thought of as a generator-based version of the return keyword.&lt;/p&gt;

&lt;p&gt;The yield keyword actually returns an IteratorResult object with two properties, value and done. (Don’t know what are iterators and iterables then read here).&lt;/p&gt;

&lt;p&gt;Once paused on a yield expression, the generator's code execution remains paused until the generator's next() method is called. Each time the generator's next() method is called, the generator resumes execution and returns the iterator result.&lt;/p&gt;

&lt;p&gt;pheww..enough of theory, let's see an example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;UUIDGenerator&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;d&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;[&lt;/span&gt;&lt;span class="sr"&gt;xy&lt;/span&gt;&lt;span class="se"&gt;]&lt;/span&gt;&lt;span class="sr"&gt;/g&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="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;getTime&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;random&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="mi"&gt;16&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="nx"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;d&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;x&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="mh"&gt;0x3&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="mh"&gt;0x8&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nx"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;16&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Here, UUIDGenerator is a generator function which calculates the UUID using current time a random number and returns us a new UUID every time its executed.&lt;/p&gt;

&lt;p&gt;To run the above function we need to create a generator object on which we can call next().&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;UUID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;UUIDGenerator&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;// UUID is our generator object&lt;/span&gt;
&lt;span class="nx"&gt;UUID&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; 
&lt;span class="c1"&gt;// return {value: 'e35834ae-8694-4e16-8352-6d2368b3ccbf', done: false}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;UUID.next() this will return you the new UUID on each UUID.next() undervalue key and done will always be false as we are in an infinite loop.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: We pause above the infinite loop, which is kind of cool and at any “stopping points” in a generator function, not only can they yield values to an external function, but they also can receive values from outside.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;There is a lot of practical implementation of generators as one above and a lot of libraries that heavily use it, co, koa, and redux-saga are some examples.&lt;/p&gt;

&lt;h1&gt;
  
  
  Async/Await (ES7)
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--u7xux-lD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/1400/0%2ALAkE4GiZATgtseM5" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--u7xux-lD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/1400/0%2ALAkE4GiZATgtseM5" alt="Alt async-await"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Traditionally, callbacks were passed and invoked when an asynchronous operation returned with data which are handled using Promise.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Async/Await&lt;/strong&gt; is the special syntax to work with promises in a more comfortable fashion which is surprisingly easy to understand and use.&lt;br&gt;
Async keyword is used to define an asynchronous function, which returns an AsyncFunction object.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Await&lt;/strong&gt; keyword is used to pause async function execution until a Promise is fulfilled, that is resolved or rejected, and to resume execution of the async function after fulfillment. When resumed, the value of the await expression is that of the fulfilled Promise.&lt;/p&gt;
&lt;h1&gt;
  
  
  Key points:
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Await can only be used inside an async function.&lt;/li&gt;
&lt;li&gt;Functions with the async keyword will always return a promise.&lt;/li&gt;
&lt;li&gt;Multiple awaits will always run in sequential order under the same function.&lt;/li&gt;
&lt;li&gt;If a promise resolves normally, then await promise returns the result. But in case of rejection, it throws the error, just if there were a throw statement at that line.&lt;/li&gt;
&lt;li&gt;An async function cannot wait for multiple promises at the same time.&lt;/li&gt;
&lt;li&gt;Performance issues can occur if using await after await as many times one statement doesn’t depend on the previous one.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So far so good, now let's see a simple example:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;asyncFunction&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;promise&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;reject&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;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;i am resolved!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;1000&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;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;promise&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
  &lt;span class="c1"&gt;// wait till the promise resolves (*)&lt;/span&gt;

  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&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="c1"&gt;// "i am resolved!"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;asyncFunction&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The asyncFunction execution “pauses” at the line await promise and resumes when the promise settles, with the result becoming its result. So the code above shows “i am resolved!” in one second.&lt;/p&gt;

&lt;h1&gt;
  
  
  Generator and Async-await — Comparison
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Generator functions/yield and Async functions/await can both be used to write asynchronous code that “waits”, which means code that looks as if it was synchronous, even though it really is asynchronous.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A generator function is executed yield by yield i.e one yield-expression at a time by its iterator (the next method) whereas Async-await, they are executed sequential await by await.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Async/await makes it easier to implement a particular use case of Generators.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The return value of Generator is always {value: X, done: Boolean} whereas for Async function it will always be a promise that will either resolve to the value X or throw an error.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;An async function can be decomposed into Generator and promise implementation which is good to know stuff.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Please consider &lt;a href="https://docs.google.com/forms/d/e/1FAIpQLSd51BJWwtMbZlJQwJQ2n59Q6T7aOKqvubzqqPh9eNtuEgXBjg/viewform"&gt;entering your email here&lt;/a&gt;, if you’d like to be added to my email list and follow me on dev.to to read more article on javascript and on &lt;a href="https://github.com/dg92"&gt;GitHub&lt;/a&gt; to see my crazy code. &lt;/p&gt;

&lt;p&gt;If anything is not clear or you want to point out something, please comment down below.&lt;/p&gt;

&lt;p&gt;Thanks :) &lt;/p&gt;

</description>
      <category>beginners</category>
      <category>webdev</category>
      <category>career</category>
      <category>javascript</category>
    </item>
    <item>
      <title>OpenCV and Node.js - Image processing </title>
      <dc:creator>Deepak Gupta</dc:creator>
      <pubDate>Wed, 14 Aug 2019 18:02:04 +0000</pubDate>
      <link>https://dev.to/dg92/opencv-and-node-js-image-processing-52lc</link>
      <guid>https://dev.to/dg92/opencv-and-node-js-image-processing-52lc</guid>
      <description>&lt;p&gt;A new article is published on overflowjs.com around creating the image filters using Node.js and OpenCV.&lt;/p&gt;

&lt;p&gt;The article discusses creating REST endpoint for below stuff:-&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Smoothing Filters (Some filters and algo’s for it)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Thresholding Filters&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Finding contours in the image&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Read full article - &lt;a href="https://overflowjs.com/posts/Image-Processing-OpenCV-and-Nodejs-Part-3.html"&gt;https://overflowjs.com/posts/Image-Processing-OpenCV-and-Nodejs-Part-3.html&lt;/a&gt; on overflowjs.com&lt;/p&gt;

&lt;p&gt;Github code link - &lt;a href="https://github.com/overflowjs-com/image_app_opencv_api_part3"&gt;https://github.com/overflowjs-com/image_app_opencv_api_part3&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>node</category>
      <category>javascript</category>
      <category>tutorial</category>
      <category>imageprocessing</category>
    </item>
    <item>
      <title>Image Processing - Making Custom Filters - React.js - Part 2</title>
      <dc:creator>Deepak Gupta</dc:creator>
      <pubDate>Tue, 06 Aug 2019 05:45:56 +0000</pubDate>
      <link>https://dev.to/dg92/image-processing-making-custom-filters-react-js-part-2-4386</link>
      <guid>https://dev.to/dg92/image-processing-making-custom-filters-react-js-part-2-4386</guid>
      <description>&lt;p&gt;A new article is published on overflowjs.com around creating a UI for applying filters on images from scratch.&lt;/p&gt;

&lt;p&gt;The article discusses the below points. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Smoothing Filters (Some filters and algo’s for it)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Thresholding Filters&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Finding contours in the image&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Finally, the use of a live camera to capture some images from the webcam and applying filters&lt;/p&gt;

&lt;p&gt;Read full article - &lt;a href="https://overflowjs.com/posts/Image-Processing-Making-Custom-Filters-Reactjs-Part-2.html"&gt;https://overflowjs.com/posts/Image-Processing-Making-Custom-Filters-Reactjs-Part-2.html&lt;/a&gt; article on overflowjs.com&lt;/p&gt;

&lt;p&gt;Here is the live app link of UI (may take time to load for the first time ) - &lt;a href="https://peaceful-reef-69295.herokuapp.com/"&gt;https://peaceful-reef-69295.herokuapp.com/&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Github code link - &lt;a href="https://github.com/overflowjscom/image_app_image_processing_opencvviawebcam_part_2"&gt;https://github.com/overflowjscom/image_app_image_processing_opencvviawebcam_part_2&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>imageprocessing</category>
      <category>react</category>
      <category>ui</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Image Processing In React.js (Part 1)</title>
      <dc:creator>Deepak Gupta</dc:creator>
      <pubDate>Mon, 22 Jul 2019 12:10:57 +0000</pubDate>
      <link>https://dev.to/dg92/image-processing-in-react-js-part-1-4326</link>
      <guid>https://dev.to/dg92/image-processing-in-react-js-part-1-4326</guid>
      <description>&lt;p&gt;Ever wonder how to create a cool filter like Instagram and other app's. &lt;/p&gt;

&lt;p&gt;Check out - &lt;a href="https://overflowjs.com/posts/Image-Processing-In-Reactjs-Part-1.html"&gt;https://overflowjs.com/posts/Image-Processing-In-Reactjs-Part-1.html&lt;/a&gt; article on overflowjs.com and you will have a good start to understand how to create image filters.&lt;/p&gt;

&lt;p&gt;This is the live version of the app created - &lt;a href="https://cryptic-sierra-27182.herokuapp.com/"&gt;https://cryptic-sierra-27182.herokuapp.com/&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>frontend</category>
      <category>images</category>
    </item>
    <item>
      <title>Google India — Phone Call Interview Question (Software Developer)</title>
      <dc:creator>Deepak Gupta</dc:creator>
      <pubDate>Wed, 17 Jul 2019 17:39:03 +0000</pubDate>
      <link>https://dev.to/dg92/google-india-phone-call-interview-question-software-developer-3h7a</link>
      <guid>https://dev.to/dg92/google-india-phone-call-interview-question-software-developer-3h7a</guid>
      <description>&lt;p&gt;Before I tell the question, for which you are here, this interview was for a software developer position and mostly working around javascript.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: I am still in the process of interviews so not sure if I will able to make it to a face to face interview 🤞, Wish me luck.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The interview lasts for 25 min on a phone call out of which 2–3 min were taken by the interview to explain the responsibilities of the role and later she asked around 12 questions which were a mix of my resume, basic data structure, algorithm, and analytics.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: I write articles around javascript concept, Nodejs, React, React-native, GraphQl, System Architecture — @ &lt;a href="http://overflowjs.com"&gt;http://overflowjs.com&lt;/a&gt;&lt;br&gt;
Feel free to check out and improve on your skills or comment to cover any topic of your choice.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So, let’s start 👇&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Tell me about yourself?&lt;/li&gt;
&lt;li&gt;What technologies you have worked on?&lt;/li&gt;
&lt;li&gt;Why I switched so frequently in the past 3 years?&lt;/li&gt;
&lt;li&gt;Have you done any system design from scratch?&lt;/li&gt;
&lt;li&gt;Worst case scenario of quicksort and when will worst case occurs?&lt;/li&gt;
&lt;li&gt;Worst case scenario of merge sort and when it will occur?&lt;/li&gt;
&lt;li&gt;Which is faster quicksort or merge sort, when and why?&lt;/li&gt;
&lt;li&gt;What are Hash tables and how is it different from a dictionary?&lt;/li&gt;
&lt;li&gt;What is a balanced binary search tree? Why they are called balanced?&lt;/li&gt;
&lt;li&gt;In javascript, the resolution is done by value or by reference and why?&lt;/li&gt;
&lt;li&gt;How will you solve or approach to problem 2 raise to power 24?&lt;/li&gt;
&lt;li&gt;Any question for me?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;Note: Comment down below if you want to me write the answer to these question👇&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;At last, she told me to wait for a week as she will pass on the answer to the team and will revert back with the feedback.&lt;/p&gt;

&lt;p&gt;Hope the above question help someone looking out for some idea around the Google phone call interview question.&lt;/p&gt;

&lt;p&gt;Happy Coding ❤️&lt;/p&gt;

</description>
      <category>interview</category>
      <category>career</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Understand Vue.js via making a CRUD App</title>
      <dc:creator>Deepak Gupta</dc:creator>
      <pubDate>Sat, 13 Jul 2019 19:26:08 +0000</pubDate>
      <link>https://dev.to/dg92/understand-vue-js-via-making-a-crud-app-33mc</link>
      <guid>https://dev.to/dg92/understand-vue-js-via-making-a-crud-app-33mc</guid>
      <description>&lt;p&gt;A new article just got published on overflowjs.com regarding making a CRUD app using Vue.js&lt;/p&gt;

&lt;p&gt;Here is the link of the article  - &lt;a href="https://overflowjs.com/posts/Vuejs-Making-CRUD-App-Part-3"&gt;https://overflowjs.com/posts/Vuejs-Making-CRUD-App-Part-3&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The working version of the app is live at - &lt;a href="https://unruffled-goldstine-e8478d.netlify.com/login"&gt;https://unruffled-goldstine-e8478d.netlify.com/login&lt;/a&gt;, feel free to check it out.&lt;/p&gt;

&lt;p&gt;Here is Github repo - &lt;a href="https://github.com/overflowjs-com/blog-frontend-auth"&gt;https://github.com/overflowjs-com/blog-frontend-auth&lt;/a&gt; if you want to check the code.&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;

</description>
      <category>vue</category>
      <category>frontend</category>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Do you know proxy in javascript?</title>
      <dc:creator>Deepak Gupta</dc:creator>
      <pubDate>Tue, 09 Jul 2019 16:13:41 +0000</pubDate>
      <link>https://dev.to/dg92/do-you-know-proxy-in-javascript-53dc</link>
      <guid>https://dev.to/dg92/do-you-know-proxy-in-javascript-53dc</guid>
      <description>&lt;p&gt;Proxy seems to be a less famous javascript feature and but it holds a lot of power if implemented.&lt;/p&gt;

&lt;p&gt;We can use it for validation, value correction, tracing property accesses, warning about unknown properties, negative Array indices, data binding, accessing a restful web service (method calls), revocable references, monitoring async functions, type checking and much more.&lt;/p&gt;

&lt;p&gt;Here is a link of good read - &lt;a href="https://overflowjs.com/posts/Proxy-In-Javascript-2019"&gt;https://overflowjs.com/posts/Proxy-In-Javascript-2019&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have a nice read!&lt;/p&gt;

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