<?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: Kaushal</title>
    <description>The latest articles on DEV Community by Kaushal (@kaushal).</description>
    <link>https://dev.to/kaushal</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%2F279616%2Fe5adf7d9-5bc2-43e3-a732-174cb89b0548.jpeg</url>
      <title>DEV Community: Kaushal</title>
      <link>https://dev.to/kaushal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kaushal"/>
    <language>en</language>
    <item>
      <title>Bring Linux environment to Windows</title>
      <dc:creator>Kaushal</dc:creator>
      <pubDate>Mon, 14 Feb 2022 16:37:50 +0000</pubDate>
      <link>https://dev.to/kaushal/bring-linux-environment-to-windows-3377</link>
      <guid>https://dev.to/kaushal/bring-linux-environment-to-windows-3377</guid>
      <description>&lt;p&gt;Hey there.&lt;br&gt;
When a project is built up for a specific environment and you can't execute it in another, it's a nightmare for a developer. For example, the majority of the projects are configured to run on a Linux environment. As a result, setting up VirtualBox on a Windows machine for Linux is a simple option (Ubuntu). However, this is incredibly slow because it has access to a limited quantity of primary memory, which can hinder our performance.&lt;/p&gt;

&lt;p&gt;I discovered a Windows feature, which is an excellent method for running a Linux environment on Windows, WSL(Windows Subsystem for Linux) is a feature provided by Windows.&lt;/p&gt;

&lt;h5&gt;
  
  
  The steps to do so are outlined below.
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Search for &lt;strong&gt;Turn Windows features on or off&lt;/strong&gt; in your Windows machine, which gives you a screen something like this. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--x7o2Oh7C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2i1g3ycx3wmlunk349q4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--x7o2Oh7C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2i1g3ycx3wmlunk349q4.png" alt="Turn Windows features on or off screen image" width="552" height="492"&gt;&lt;/a&gt; &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the checkbox called &lt;strong&gt;Windows Subsystem for Linux&lt;/strong&gt; and press &lt;em&gt;OK&lt;/em&gt;. This will restart your computer so that WSL can be installed. There is another way to do it, that uses the command line, but this one is easiest.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install Ubuntu from the Microsoft store so WSL can assess the subsystem(it require an environment to run the WSL). I would recommend the latest version of Ubuntu(20.04), which you can install from this &lt;a href="https://www.microsoft.com/store/productId/9N6SVWS3RX71"&gt;link&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After the Ubuntu installation is complete, please open it and complete the basic setup process, such as setting up a username and password. At the end of the process you will see a screen like below. Close the Ubuntu window.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nxaNNvbD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7coe01lmq45xu7nfc3lo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nxaNNvbD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7coe01lmq45xu7nfc3lo.png" alt="ubuntu" width="880" height="509"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;There are multiple ways of accessing the linux subsystem from terminal but I like using it with Windows Terminals &lt;a href="https://www.microsoft.com/store/productId/9N0DX20HK701"&gt;download link&lt;/a&gt; for Windows Terminals from the Microsoft Store.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;By default, when you open Windows Terminal after installation, it will launch Windows PowerShell. By clicking the chevron symbol, you may see all of the available terminals on your system.&lt;br&gt;
Choose the &lt;strong&gt;third&lt;/strong&gt; option to open unbuntu terminal.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ne2ocb81--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hppmym9z1ve5klxqlc2k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ne2ocb81--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hppmym9z1ve5klxqlc2k.png" alt="windows terminal" width="880" height="466"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you run the command &lt;code&gt;ls&lt;/code&gt;, you will see your Windows files and folders from the Ubuntu terminal and can access them. In my case, &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HnZUQ2BA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fcwdwuohfg4y5gkbxofk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HnZUQ2BA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fcwdwuohfg4y5gkbxofk.png" alt="ls command output" width="880" height="466"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hurry, we set up the WSL successfully!&lt;/p&gt;

&lt;h4&gt;
  
  
  WSL includes several ridiculous features:
&lt;/h4&gt;

&lt;p&gt;If your local server is running on Ubuntu, you can access it from localhost; you can browse the React.js project from localhost even though the server is running on Ubuntu terminal vice versa, for example. Similarly, If you have a database server(MongoDB, MySQL, etc.) running on Windows, your backend server can access that DB server from the Ubuntu environment.&lt;/p&gt;

&lt;p&gt;A tip to open your Vistual Studio Code using Ubuntu host. Install &lt;strong&gt;Remote - WSL&lt;/strong&gt; extention on your VS Code.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dLjj6GFD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6cv7gzwhsv7d0jwexb9s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dLjj6GFD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6cv7gzwhsv7d0jwexb9s.png" alt="Remote - WSL" width="880" height="153"&gt;&lt;/a&gt;Now, navigate to the directory you wish to access in VS Code and type the command 'code .' if you run this program for the first time on Ubuntu, it will install a few packages that allow you to open VS Code.&lt;/p&gt;

</description>
      <category>windows</category>
      <category>linux</category>
      <category>wsl</category>
    </item>
    <item>
      <title>Number in JavaScript</title>
      <dc:creator>Kaushal</dc:creator>
      <pubDate>Fri, 17 Jul 2020 14:46:24 +0000</pubDate>
      <link>https://dev.to/kaushal/methods-of-number-in-javascript-1312</link>
      <guid>https://dev.to/kaushal/methods-of-number-in-javascript-1312</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Number&lt;/code&gt; is a primitive wrapper object used to represent and manipulate numbers like 12 or -3.34.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;Number&lt;/code&gt; constructor contains constants and methods which are useful for working numbers.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Number()&lt;/code&gt; function is used for converting any other type of value into numbers.&lt;/li&gt;
&lt;li&gt;JavaScript &lt;code&gt;Number&lt;/code&gt; type is a double-precision 64-bit binary format IEEE 754 value.&lt;/li&gt;
&lt;li&gt;JavaScript &lt;code&gt;Number&lt;/code&gt; can represent fractional values. But, with limitations. It can only keep about 17 decimal places of precision.&lt;/li&gt;
&lt;li&gt;A number literal like &lt;code&gt;12&lt;/code&gt; in JavaScript code is still floating-point value, not an integer. JavaScript has now &lt;code&gt;BigInt&lt;/code&gt; type, but it was not designed to replace the &lt;code&gt;Number&lt;/code&gt; but for safely store and operate on large integer even beyond the safe integer limit for &lt;code&gt;Number&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;When you use as a function, &lt;code&gt;Number(value)&lt;/code&gt; converts a string or any other value to the &lt;code&gt;Number&lt;/code&gt; type. If the value can't be converted, it returns NaN.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Constructor in Number
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Using &lt;code&gt;Number()&lt;/code&gt; you can create a new &lt;code&gt;Number&lt;/code&gt; value.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Static properties of Number
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;Number.EPSILON&lt;/code&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The smallest interval between two representable numbers.&lt;/li&gt;
&lt;li&gt;It uses to represent the difference between 1 and the smallest floating-point number greater than 1.&lt;/li&gt;
&lt;li&gt;It return the smallest positive number approaching zero.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;Number.MAX_SAFE_INTEGER&lt;/code&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The maximum safe integer in JavaScript (2&lt;sup&gt;53&lt;/sup&gt; - 1).&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;Number.MAX_VALUE&lt;/code&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The largest positive representable number.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;Number.MIN_SAFE_INTEGER&lt;/code&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The minimum safe integer in JavaScript (-(2&lt;sup&gt;53&lt;/sup&gt; - 1)).&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;Number.MIN_VALUE&lt;/code&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The smallest positive representable number—that is, the positive number closest to zero (without actually being zero).&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;Number.NaN&lt;/code&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Special "&lt;strong&gt;N&lt;/strong&gt;ot &lt;strong&gt;a&lt;/strong&gt; &lt;strong&gt;N&lt;/strong&gt;umber" value.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;Number.NEGATIVE_INFINITY&lt;/code&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Special value representing negative infinity. Returned on overflow.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;Number.POSITIVE_INFINITY&lt;/code&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Special value representing infinity. Returned on overflow.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;Number.prototype&lt;/code&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Allows the addition of properties to the Number object.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Number.EPSILON           // 2.220446049250313e-16
Number.MAX_SAFE_INTEGER  // 9007199254740991
Number.MAX_VALUE         // 1.7976931348623157e+308
Number.MIN_SAFE_INTEGER  // -9007199254740991
Number.MIN_VALUE         // 5e-324
Number.NaN               // NaN
Number.NEGATIVE_INFINITY // -Infinity
Number.POSITIVE_INFINITY // Infinity
Number.prototype         // Number {...}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Static methods of Number
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;Number.isNaN()&lt;/code&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Determine whether the passed value is NaN.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;Number.isFinite()&lt;/code&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Determine whether the passed value is a finite number.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;Number.isInteger()&lt;/code&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Determine whether the passed value is an integer.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;Number.isSafeInteger()&lt;/code&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Determine whether the passed value is a safe integer (number between -(2&lt;sup&gt;53&lt;/sup&gt; - 1) and (2&lt;sup&gt;53&lt;/sup&gt; - 1)).&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;Number.parseFloat(string)&lt;/code&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;This is the same as the global parseFloat() function.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;Number.parseInt(string, [radix])&lt;/code&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;This is the same as the global parseInt() function.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Number.isNaN(NaN)         // true
Number.isFinite(12)       // true
Number.isInteger(-32)     // true
Number.isSafeInteger(23)  // true
Number.parseFloat('50')   // 50
Number.parseInt('string') // NaN
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Instance methods of Number
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;Number.prototype.toExponential(fractionDigits)&lt;/code&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Returns a string representing the number in exponential notation.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;toExponential()&lt;/code&gt; argument must be between 0 and 100.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;Number.prototype.toFixed(digits)&lt;/code&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Returns a string representing the number in fixed-point notation.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;toFixed()&lt;/code&gt; argument must be between 0 and 100.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;Number.prototype.toLocaleString([locales [, options]])&lt;/code&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Returns a string with a language sensitive representation of this number. Overrides the Object.prototype.toLocaleString() method.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;Number.prototype.toPrecision(precision)&lt;/code&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Returns a string representing the number to a specified precision in fixed-point or exponential notation.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;toPrecision()&lt;/code&gt; argument must be between 0 and 100.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;Number.prototype.toString([radix])&lt;/code&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Returns a string representing the specified object in the specified radix ("base"). Overrides the Object.prototype.toString() method.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;toString()&lt;/code&gt; radix argument must be between 2 and 36.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;Number.prototype.valueOf()&lt;/code&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Returns the primitive value of the specified object. Overrides the Object.prototype.valueOf() method.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var x = 10;
x.toExponential(4) // 1.0000e+1
x.toFixed(2)       // 10.00
x.toLocaleString() // 10
x.toPrecision(7)   // 10.00000
x.toString(2)      // 1010
x.valueOf()        // 10
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Number(new Date('January 03, 2005 04:34:56'))   // 1104707096000
Number('123')                                   // 123
Number('12.3')                                  // 12.3
Number('12.00')                                 // 12
Number('123e-1')                                // 12.3
Number('')                                      // 0
Number(null)                                    // 0
Number('0x11')                                  // 17
Number('0b11')                                  // 3
Number('0o11')                                  // 9
Number('foo')                                   // NaN
Number('100a')                                  // NaN
Number('-Infinity')                             //-Infinity
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
    </item>
    <item>
      <title>JavaScript data-types</title>
      <dc:creator>Kaushal</dc:creator>
      <pubDate>Tue, 30 Jun 2020 14:47:05 +0000</pubDate>
      <link>https://dev.to/kaushal/javascript-data-types-5580</link>
      <guid>https://dev.to/kaushal/javascript-data-types-5580</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Inside the computer’s world, there is only data which define in bits.&lt;/li&gt;
&lt;li&gt;All this data is stored as long sequences of bits and is thus fundamentally alike.&lt;/li&gt;
&lt;li&gt;Bits are any kind of two-valued things, usually described as zeros and ones.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;For example&lt;/em&gt;, we can express the number 13 in bits. It works the same way as a decimal number, but instead of 10 different digits, you have only 2, and the weight of each increases by a factor of 2 from right to left. Here are the bits that make up the number 13, with the weights of the digits shown below them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;128 64 32 16 8 4 2 1
  0  0  0  0 1 1 0 1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;So that’s the binary number &lt;code&gt;00001101&lt;/code&gt;. Its non-zero digits stand for 8, 4, and 1, and add up to 13.&lt;/p&gt;

&lt;h3&gt;
  
  
  Dynamic typing
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;JavaScript is a loosely typed and dynamic language.&lt;/li&gt;
&lt;li&gt;Variables in JavaScript are not directly associated with any particular value type, and any variable can be assigned (and re-assigned) values of all types:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let foo = 42;    // foo is a number
foo     = 'bar'; // foo is now a string
foo     = true;  // foo is now a boolean
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;primitive (or primary):
These types are called “primitive” because their values can contain only a single thing (be it a string or a number or whatever).

&lt;ul&gt;
&lt;li&gt;String&lt;/li&gt;
&lt;li&gt;Number&lt;/li&gt;
&lt;li&gt;BigInt&lt;/li&gt;
&lt;li&gt;Boolean&lt;/li&gt;
&lt;li&gt;Undefined&lt;/li&gt;
&lt;li&gt;Null&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;composite (or reference)

&lt;ul&gt;
&lt;li&gt;Object&lt;/li&gt;
&lt;li&gt;Function&lt;/li&gt;
&lt;/ul&gt;


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

&lt;h3&gt;
  
  
  Primitive
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;String, Number, and Boolean are primitive data types.&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  String
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;JavaScript's String type is used to represent textual data. It is a set of "elements" of 16-bit unsigned integer values. Each element in the String occupies a position in the String. The first element is at index 0, the next at index 1, and so on. The length of a String is the number of elements in it.&lt;/li&gt;
&lt;li&gt;We can use single quotes, double quotes, or backticks to mark strings, as long as the quotes at the start and the end of the string match.&lt;/li&gt;
&lt;li&gt;For instance,
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var a = "Welcome to Devkode";
var b = 'LEARN | DEVELOP | DEPLOY';
var c = `KEEP LEARNING KEEP SHARING`;

console.log(a); // Welcome to Devkode
console.log(b); // LEARN | DEVELOP | DEPLOY
console.log(c); // KEEP LEARNING KEEP SHARING
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Unlike &lt;code&gt;C&lt;/code&gt; language JavaScript's strings are immutable. This means a string created, it is not possible to modify it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Number
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;JavaScript automatically takes data-type on what value are you assigning.&lt;/li&gt;
&lt;li&gt;For instance,
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var a = 10;
console.log(a) // 10
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;JavaScript store value between -(2&lt;sup&gt;53&lt;/sup&gt; − 1) and 2&lt;sup&gt;53&lt;/sup&gt; − 1).&lt;/li&gt;
&lt;li&gt;The number typehas three symbolic value &lt;code&gt;+Infinity&lt;/code&gt;, &lt;code&gt;-Infinity&lt;/code&gt;, and &lt;code&gt;NaN&lt;/code&gt; ("&lt;strong&gt;N&lt;/strong&gt;ot a &lt;strong&gt;N&lt;/strong&gt;umber").&lt;/li&gt;
&lt;li&gt;We can also check minmum value and maximum value within &lt;code&gt;±Infinity&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(Number.MAX_VALUE); // 1.7976931348623157e+308
console.log(Number.MIN_VALUE); // 5e-324
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;In ECMAScript2015, we can albe to check the number is in the double-precision floating-point number range using &lt;code&gt;Number.isSafeInteger()&lt;/code&gt;. We can get the rang of &lt;code&gt;SafeInteger&lt;/code&gt; using &lt;code&gt;Number.MAX_SAFE_INTEGER&lt;/code&gt; and &lt;code&gt;Number.MIN_SAFE_INTEGER&lt;/code&gt;. Beyond this range, interget is not safe in JavaScript&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  BigInt
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The BigInt type is a numeric primitive in JavaScript that can represent integers with arbitrary precision.&lt;/li&gt;
&lt;li&gt;For assign BigInt value to variable, we have to use &lt;code&gt;n&lt;/code&gt; character followed by integer value.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var a = 5n;
console.log(a); // 5n
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;With the &lt;code&gt;BigInt&lt;/code&gt;, we can store a value beyond the safe number limit for &lt;code&gt;Number&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;BigInt&lt;/code&gt; is not strictly equal to a &lt;code&gt;Number&lt;/code&gt;, but it is loosely so.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Boolean
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;It is often useful to have a value that distinguishes between only two possibilities, like &lt;strong&gt;yes&lt;/strong&gt; and &lt;strong&gt;no&lt;/strong&gt; or &lt;strong&gt;on&lt;/strong&gt; and &lt;strong&gt;off&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Boolean has just two values, &lt;code&gt;true&lt;/code&gt; and &lt;code&gt;false&lt;/code&gt;, which are writtern as word.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var a = false;
var b = true;
console.log(a) // false
console.log(b) // true
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Null
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The special null value does not belong to any of the types described above.&lt;/li&gt;
&lt;li&gt;In JavaScript, &lt;code&gt;null&lt;/code&gt; is not a “reference to a non-existing object” or a “null pointer” like in some other languages.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var a = null;
console.log(a) // null
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Undefined
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The special value &lt;code&gt;undefined&lt;/code&gt; also stands apart. It makes a type of its own, just like null.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The meaning of &lt;code&gt;undefined&lt;/code&gt; is “value is not assigned” to specified variable.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var a;
console.log(a); // undefined
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Composite
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Object, Array, and Function (which are all types of objects) are composite data types.&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Object
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Objects allow us to group values—including other objects—to build more complex structures.&lt;/li&gt;
&lt;li&gt;Objects are used to store collections of data and more complex entities.&lt;/li&gt;
&lt;li&gt;An object comes with a pair of keys and values.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var a = { name: 'value' };
console.log(a); // {name: "value"}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;We can also create an object instance with the help of a new keyword. This way we can create an object instance of a class
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var str = new String();
var bool = new Boolean();
var num = new Number();
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Function
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Functions are regular objects with the additional capability of being callable.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(console.log) // ƒ log() { [native code] }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Special
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Symbols are new to JavaScript in ECMAScript 2015.&lt;/li&gt;
&lt;li&gt;A Symbol is a unique and immutable primitive value and may be used as the key of an Object property.&lt;/li&gt;
&lt;li&gt;In some programming languages, Symbols are called "atoms".&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;typeof&lt;/code&gt; operator returns the type of the argument. It’s useful when we want to process values of different types differently or just want to do a quick check.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;typeof 0 // "number"
typeof 10n // "bigint"
typeof "foo" // "string"
typeof true // "boolean"
typeof null // "object"
typeof undefined // "undefined"
typeof Math // "object"
typeof Symbol("id") // "symbol"
typeof alert // "function"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;number&lt;/code&gt; for any kind of numbers of any kind: integer or floating-point, integers are limited by ±253.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;bigint&lt;/code&gt; is for integer numbers of arbitrary length.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;string&lt;/code&gt; for strings. A string may have zero or more characters.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;boolean&lt;/code&gt; for true/false.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;null&lt;/code&gt; for unknown values.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;undefined&lt;/code&gt; for unassigned values.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;object&lt;/code&gt; for more complex data structures.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;symbol&lt;/code&gt; for unique identifiers.&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>this keyword in JavaScript</title>
      <dc:creator>Kaushal</dc:creator>
      <pubDate>Sun, 28 Jun 2020 18:24:39 +0000</pubDate>
      <link>https://dev.to/kaushal/this-keyword-in-javascript-49il</link>
      <guid>https://dev.to/kaushal/this-keyword-in-javascript-49il</guid>
      <description>&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;A function's &lt;strong&gt;this&lt;/strong&gt; behave is a little bit different in JavaScript, unlike other languages.&lt;br&gt;
it also work diffrently with the use of &lt;code&gt;strict&lt;/code&gt; mode and &lt;code&gt;non-strict&lt;/code&gt; mode.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fHFRFozG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/rzyk6v6dirtsvb842t8y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fHFRFozG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/rzyk6v6dirtsvb842t8y.png" alt="code"&gt;&lt;/a&gt;&lt;br&gt;
In &lt;code&gt;non-strict&lt;/code&gt; both functions calls' &lt;strong&gt;this&lt;/strong&gt; point to &lt;code&gt;window/object&lt;/code&gt; and return true.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;this&lt;/strong&gt; in function context.
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MhNLAZaA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/wu66g15lk0mcsf3qzz1l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MhNLAZaA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/wu66g15lk0mcsf3qzz1l.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;this&lt;/strong&gt; and object conversion
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--A7EAutTj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/3syyctt3l6nlsoehww1o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--A7EAutTj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/3syyctt3l6nlsoehww1o.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  with &lt;code&gt;bind&lt;/code&gt; method
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UZZTIU2i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/n169zq00fy17t12zniat.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UZZTIU2i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/n169zq00fy17t12zniat.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  this work differently in both Arrow and Normal function
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--j74gI0ui--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zbctkjy59yqbetd2cmh9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--j74gI0ui--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zbctkjy59yqbetd2cmh9.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Difference between Arrow and Normal functions.</title>
      <dc:creator>Kaushal</dc:creator>
      <pubDate>Sun, 28 Jun 2020 14:12:32 +0000</pubDate>
      <link>https://dev.to/kaushal/difference-between-arrow-and-normal-functions-38pb</link>
      <guid>https://dev.to/kaushal/difference-between-arrow-and-normal-functions-38pb</guid>
      <description>&lt;h3&gt;
  
  
  Arrow function
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The arrow functions are work same as with normal functions. It was introduce in ES6.&lt;/li&gt;
&lt;li&gt;Syntax
const variable = () =&amp;gt; {}&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ex &lt;br&gt;
var foo = _ =&amp;gt; 'Hii';&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It's same as&lt;br&gt;
function name(params) {&lt;br&gt;
return 'Hii';&lt;br&gt;
}&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;These arrow functions are make eassy our work and readablity.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Normal function&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;var foo = function(name) {
return function(age) {
    return function(city) {
        return &lt;code&gt;${name} ${age} ${city}&lt;/code&gt;
    }
}&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

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


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

&lt;p&gt;Arrow function&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;var foo = (name) =&amp;gt; (age) =&amp;gt; (city) =&amp;gt; &lt;code&gt;${name} ${age} ${city}&lt;/code&gt;;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


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

&lt;h4&gt;
  
  
  Difference between normal and arrow functions.
&lt;/h4&gt;

&lt;pre&gt;
    var name = "Mike";
    var obj = {
        name: "Tom",
        foo: function() {
            console.log(this);
            var bar1 = function() {
                console.log(this.name); // Point to Window(Parent)
            }
            var bar2 = () =&amp;gt; {
                console.log(this.name); // Point to current Object
            }
            bar1();
            bar2();
        }
    }
    obj.foo();
    // If we not use var it point to parent
    var bar = () =&amp;gt; {
        var x= "sad";
        let y= "sasa";
        console.log(this.x); // Window // undefined
        console.log(this.y); // sasa
    }
    bar();
&lt;/pre&gt;

&lt;h4&gt;
  
  
  Why we need Arrow function.
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Arrow functions cannot called with Constructer. &lt;/li&gt;
&lt;li&gt;Arrow functions are not having their own &lt;strong&gt;this&lt;/strong&gt;. So, we cannot update using &lt;strong&gt;this&lt;/strong&gt;.

&lt;ul&gt;
&lt;li&gt;Whenever we use &lt;strong&gt;this&lt;/strong&gt; inside the arrow function it will check parent, until not find parent.&lt;/li&gt;
&lt;li&gt;Arrow alway have lasical scope.&lt;/li&gt;
&lt;/ul&gt;


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

&lt;h4&gt;
  
  
  When use it.
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Use arrow function only when you have to use parent's &lt;strong&gt;this&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Use only when we need it, according to requirenment.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Not use.
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;It has not thier own &lt;strong&gt;this&lt;/strong&gt; so we can not call it as a &lt;strong&gt;Constructor&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Node.js</title>
      <dc:creator>Kaushal</dc:creator>
      <pubDate>Mon, 15 Jun 2020 14:19:28 +0000</pubDate>
      <link>https://dev.to/kaushal/node-js-1odl</link>
      <guid>https://dev.to/kaushal/node-js-1odl</guid>
      <description>&lt;h1&gt;
  
  
  Core things in Node.js
&lt;/h1&gt;

&lt;h2&gt;
  
  
  proceses object
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In the process object, there is an &lt;strong&gt;argv&lt;/strong&gt; property. Which gives us arguments, those we have passed via console.
&lt;pre&gt;
console.log(process.argv);
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZfY4T7F4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/q5datytzg145whuy1ss6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZfY4T7F4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/q5datytzg145whuy1ss6.png" alt="process object"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We can pass any number of arguments as we want, and access it into the script.
&lt;pre&gt;
var index = process.argv.indexOf("Hello");
console.log(process.argv[index]);
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hjpTxdVW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/q04g90quavtnxizmsbo8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hjpTxdVW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/q04g90quavtnxizmsbo8.png" alt="process object"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We can also pass arguments as a flag.
&lt;pre&gt;
var index = process.argv.indexOf("--words") + 1;
console.log(process.argv[index]);
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7rTzS3M3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/78fy9i6eveeeilprk27d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7rTzS3M3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/78fy9i6eveeeilprk27d.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Write on the console using &lt;strong&gt;process object&lt;/strong&gt;.
&lt;pre&gt;
process.stdout.write("Hello");
process.stdout.write("World\n\n");
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KjgfmppJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/eeoaglp8pg7w7kipbp8q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KjgfmppJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/eeoaglp8pg7w7kipbp8q.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Take input from console using &lt;strong&gt;process object&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;But in this case program execution will never stop.&lt;/li&gt;
&lt;li&gt;We have to stop it manually.
&lt;pre&gt;
process.stdin.on("data", (data) =&amp;gt; {
process.stdout.write(data);
});
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JWl83jNG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/pxezw0fhgrh9s8tqivzj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JWl83jNG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/pxezw0fhgrh9s8tqivzj.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In below example stop manually process.
&lt;pre&gt;
process.stdin.on("data", (data) =&amp;gt; {
process.stdout.write(data);
process.exit(); // this function call stop the process
});
&lt;/pre&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5_R2_tsK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/wyszsx143axf51r2wq80.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;Handle console logging inside the script.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In this example console will clear before each and every print statement.
&lt;pre&gt;
var index = 1;
const interval = setInterval(() =&amp;gt; {
process.stdout.clearLine();
process.stdout.cursorTo(0);
process.stdout.write(&lt;code&gt;${index++}&lt;/code&gt;);
}, 500);
setTimeout(() =&amp;gt; {
clearInterval(interval);
}, 3000);
&lt;/pre&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4HeYHKG_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/srww4xk32eranbsx5x1e.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;/ul&gt;


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

&lt;h2&gt;
  
  
  util module
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Util module use for logging data on the console like &lt;strong&gt;console.log()&lt;/strong&gt;.

&lt;ul&gt;
&lt;li&gt;It displays data with time information.
&lt;pre&gt;
const util = require("util");
util.log("Node.js process object");
&lt;/pre&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--W5vAq_TX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/3hbr1hcwfmfh9vi26b1f.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;/ul&gt;


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

&lt;h2&gt;
  
  
  v8 module
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Showing &lt;strong&gt;heap&lt;/strong&gt; data of program execution.
&lt;pre&gt;
const v8 = require("v8");
const util = require("util");
util.log(v8.getHeapStatistics());
&lt;/pre&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9azEK_1d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/i58dxk518culbps7o1uv.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  readline module
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;readline&lt;/strong&gt; has &lt;em&gt;createInterface&lt;/em&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We have to provide &lt;strong&gt;&lt;em&gt;read stream&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;output stream&lt;/em&gt;&lt;/strong&gt; in the createInterface.
&lt;pre&gt;
const readline = require("readline");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
rl.question("Where are you living? ", (answer) =&amp;gt; {
rl.write(&lt;code&gt;You are living in ${answer}\n&lt;/code&gt;);
process.exit();
});
&lt;/pre&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DLmzivJC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/dml6mvg5addho2aiijmj.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;/ul&gt;


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

&lt;h2&gt;
  
  
  events module
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;event emtier allow us to create our own Event that we can call any time we want throughout the script's execution.
&lt;pre&gt;
const events = require("events");
const emiter = new events.EventEmitter();
emiter.on("customEvent", (message, sender) =&amp;gt; {
console.log("Inside the CustomEvent");
console.log(&lt;code&gt;${sender} sent you: ${message}&lt;/code&gt;);
});
emiter.emit("customEvent", "Hii, there", "User");
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3xxH-BcZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8q15fox6p3pgmmzmjyx1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3xxH-BcZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8q15fox6p3pgmmzmjyx1.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>object</category>
    </item>
    <item>
      <title>JavaScript destructuring</title>
      <dc:creator>Kaushal</dc:creator>
      <pubDate>Sat, 18 Apr 2020 03:45:54 +0000</pubDate>
      <link>https://dev.to/kaushal/javascript-destructuring-1b4d</link>
      <guid>https://dev.to/kaushal/javascript-destructuring-1b4d</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;JavaScript ES6 comes with the destructuring assignments. A name define its use, destructure values from an array and properties from an object. For instance,&lt;/p&gt;

&lt;h2&gt;
  
  
  Syntax
&lt;/h2&gt;

&lt;pre&gt;
let x, y, rest;
[x, y] = [1, 2];

console.log(a); //  1
console.log(b); //  2

[x, y, ...rest] = [1, 2, 3, 4, 5];

console.log(x); //  1
console.log(y); //  2
console.log(rest); //  [3,4,5]

({ a, b, ...c } = {a: "first", b: "second", c: "third", d: "fourth", e: "fifth"});

console.log(a); //  first
console.log(b); //  second
consoel.log(c); //  { c: 'third', d: 'fourth', e: 'fifth' }
&lt;/pre&gt;

&lt;p&gt;The destructuring assignment uses syntax, on the left side of the equal sign, is assignment of the values from the sourced variable, source is on the right side of the equal sign.&lt;/p&gt;

&lt;h2&gt;
  
  
  Array destructuring
&lt;/h2&gt;

&lt;h5&gt;
  
  
  Assignment is allowed separate from declaration.
&lt;/h5&gt;

&lt;pre&gt;
let a, b;

[a, b] = [1, 2];
console.log(a); // 1
console.log(b); // 2
&lt;/pre&gt;

&lt;h5&gt;
  
  
  We can relinquish(omit) the unnecessary values from the array while destructuring it.
&lt;/h5&gt;

&lt;pre&gt;
let [x, , y, , , z] = [1, 2, 3, 4, 5, 6];
console.log(x); // 1
console.log(y); // 3
console.log(y); // 6
&lt;/pre&gt;

&lt;p&gt;A single comma (,) can seek one position forward. The common can be one or more in the destructuring list as we want to skip the values.&lt;/p&gt;

&lt;h5&gt;
  
  
  Rest element must be last element
&lt;/h5&gt;

&lt;pre&gt;
let [a, , ...b, c] = [1, 2, 3, 4, 5, 6];  // ___give error___
// SyntaxError: Rest element must be last element

let [a, , , ...b] = [1, 2, 3, 4, 5, 6];

console.log(a); //  1
console.log(b); // [ 4, 5, 6 ]
&lt;/pre&gt;

&lt;p&gt;Always consider the rest operator as the last element while unpacking the values from source variable.&lt;/p&gt;

&lt;h5&gt;
  
  
  Use as a swapper
&lt;/h5&gt;

&lt;pre&gt;
let a = 1, b = 2;

[a, b] = [b, a];
console.log(a); // 2
console.log(b); // 1
&lt;/pre&gt;

&lt;h2&gt;
  
  
  Object destructuring
&lt;/h2&gt;

&lt;h5&gt;
  
  
  Declaration and assignment
&lt;/h5&gt;

&lt;pre&gt;
let a, b;
{ a, b } = {a: "first", b: "second"};
console.log(a); //  first
console.log(b); // second
&lt;/pre&gt;

&lt;h5&gt;
  
  
  Assigning with new name(rename)
&lt;/h5&gt;

&lt;pre&gt;
let { a: x, b: y} = {a: "first", b: "second"};

console.log(x); //  first
console.log(y); // second
&lt;/pre&gt;

&lt;p&gt;Here, it will take &lt;strong&gt;&lt;em&gt;a&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;b&lt;/em&gt;&lt;/strong&gt; from the object and assign it to newly named local variable &lt;strong&gt;&lt;em&gt;x&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;y&lt;/em&gt;&lt;/strong&gt;. &lt;/p&gt;

&lt;h5&gt;
  
  
  Default value
&lt;/h5&gt;

&lt;p&gt;In some cases we want to pull out a value from object, only if, it's exist in it, &lt;br&gt;
 if not, set a default value rather than just holding an &lt;strong&gt;&lt;em&gt;undefined&lt;/em&gt;&lt;/strong&gt; in the variable.&lt;/p&gt;

&lt;pre&gt;
let { a = 10, b = 20, x = 30} = {a: "first", b: "second"};

console.log(a); //  first
console.log(b); //  second
console.log(x); //  30
&lt;/pre&gt;

&lt;h5&gt;
  
  
  Default value to newly define local variable
&lt;/h5&gt;

&lt;p&gt;Unpack the value from object and assigned to a variable with a different name and default value, if property not exist in the object.&lt;/p&gt;

&lt;pre&gt;
let { a: xx = 10, b: yy = 20, x = 30} = {a: "first", b: "second"};

console.log(xx); //  first
console.log(yy); //  second
console.log(x); //  30
&lt;/pre&gt;

&lt;h5&gt;
  
  
  Nested object destructuring
&lt;/h5&gt;

&lt;pre&gt;
const fruit = {
  seed: {
    countable: 'A fertilized grain, initially encased in a fruit, which may grow into a mature plant.' ,
    botany: 'A fertilized ovule, containing an embryonic plant.',
    uncountable: 'An amount of fertilized grain that cannot be readily counted.'
  },
  definition: 'All produce that contains seeds is botanically classified as a fruit.',
}

let { countable, definition } = fruit;

console.log(countable);  //  undefined
console.log(definition);  //  All produce that contains seeds is botanically classified as fruit.
&lt;/pre&gt;

&lt;p&gt;See, a variable &lt;strong&gt;&lt;em&gt;countable&lt;/em&gt;&lt;/strong&gt; is printed as &lt;strong&gt;&lt;em&gt;undefined&lt;/em&gt;&lt;/strong&gt;, because the &lt;strong&gt;&lt;em&gt;countable&lt;/em&gt;&lt;/strong&gt; is define with in &lt;strong&gt;seed&lt;/strong&gt; object, which is nested object. Thus, the question is how to destructuring these kinds of objects?&lt;/p&gt;

&lt;pre&gt;
const fruit = {
  seed : {
    countable: 'A fertilized grain, initially encased in a fruit, which may grow into a mature plant.' ,
    botany: 'A fertilized ovule, containing an embryonic plant.',
    uncountable: 'An amount of fertilized grain that cannot be readily counted.'
  },
  definition: 'All produce that contains seeds is botanically classified as a fruit.',
}

let { seed: { countable, botany }, definition } = fruit;

console.log(countable);  //  A fertilized grain, initially encased in a fruit, which may grow...
console.log(botany);  //  A fertilized ovule, containing an embryonic plant.
console.log(definition);  //  All produce that contains seeds is botanically classified as a fruit.
&lt;/pre&gt;

&lt;h5&gt;
  
  
  Destructuring with default values
&lt;/h5&gt;

&lt;pre&gt;
const fruit = {
  seed : {
    countable: 'A fertilized grain, initially encased in a fruit, which may grow into a mature plant.' ,
    botany: 'A fertilized ovule, containing an embryonic plant.',
    uncountable: 'An amount of fertilized grain that cannot be readily counted.'
  },
  definition: 'All produce that contains seeds is botanically classified as fruit.',
}

let { seed: { botany }, definition, sweet = 'Containing a sweetening ingredient.' } = fruit;

console.log(botany);  //  A fertilized ovule, containing an embryonic plant.
console.log(definition);  //  All produce that contains seeds is botanically classified as fruit.
console.log(sweet);  //  Containing a sweetening ingredient.
&lt;/pre&gt;

&lt;h5&gt;
  
  
  Computed Object property names and destructuring
&lt;/h5&gt;

&lt;pre&gt;
const key = 'grapes';
let {[key]: fruit} = { grapes: 'A small, round, smooth-skinned edible fruit.' }

console.log(fruit)  //  A small, round, smooth-skinned edible fruit.
&lt;/pre&gt;

&lt;h5&gt;
  
  
  Rest in Object destructuring
&lt;/h5&gt;

&lt;p&gt;Consider &lt;strong&gt;&lt;em&gt;rest&lt;/em&gt;&lt;/strong&gt; operator as the last element while unpacking the values from the source element.&lt;/p&gt;

&lt;pre&gt;
let { a, b, ...res } = {a: "first", b: "second", c: "third", d: "fourth", e: "fifth"};

console.log(a); //  first
console.log(b); //  second
console.log(res); //  { c: 'third', d: 'fourth', e: 'fifth' }
&lt;/pre&gt;

&lt;h5&gt;
  
  
  Invalid identifier as a property name
&lt;/h5&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Space&lt;/em&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;em&gt;dash&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;special character&lt;/em&gt;&lt;/strong&gt; are not allowed for Object's property name.&lt;/p&gt;

&lt;pre&gt;
let { 'of a person' } = {'of a person': 'Having considerable flesh.'};  //  cannot access property 
let { 'of a person': seed } = {'of a person': 'Having considerable flesh.'}; 
//  we have to rename it for access the value

console.log(seed); //  Having considerable flesh.
&lt;/pre&gt;

&lt;h5&gt;
  
  
  The prototype chain is looked up when the object is deconstructed
&lt;/h5&gt;

&lt;p&gt;When deconstructing an object, if a property currently exists not accessed in itself, it will continue to look up along the prototype chain.&lt;/p&gt;

&lt;pre&gt;
const obj = { property: 123 };
obj.__proto__.anotherProto = 456;
let { anotherProto } = obj

console.log(anotherProto);  // 456
&lt;/pre&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>JavaScript arrow function</title>
      <dc:creator>Kaushal</dc:creator>
      <pubDate>Thu, 16 Apr 2020 17:17:02 +0000</pubDate>
      <link>https://dev.to/kaushal/javascript-arrow-function-2513</link>
      <guid>https://dev.to/kaushal/javascript-arrow-function-2513</guid>
      <description>&lt;h3&gt;
  
  
  Introducrion
&lt;/h3&gt;

&lt;p&gt;ES6 comes with a new function syntax which looks very different from others. Arrow functions were added in 2015, on the whole to make writing functions with less expression. Instead of using the "function" keyword, we can use an arrow (=&amp;gt;), which made up of an equal sign and a greater-than character (do not get confused with the greater-than-or-equal operator, which is written like &amp;gt;=).&lt;/p&gt;

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

&lt;pre&gt;
const variable = (parameter) =&amp;gt; {
  // function body
}
&lt;/pre&gt;

&lt;p&gt;The arrow comes after a list of function's parameters and followed by the function's body. Which is same as,&lt;/p&gt;

&lt;pre&gt;
function functionName () {
  // function body
}
&lt;/pre&gt;

&lt;p&gt;If the function has only one parameter, we can omit the parentheses around the parameter list. If the body is a single expression, rather than a block in braces, that expression will be returned automatically from the function. So, these two function definitions will do the same thing.&lt;/p&gt;

&lt;pre&gt;
const func1 = (x) =&amp;gt; { return x*x; };

cosnt func2 = x =&amp;gt; x*x;
&lt;/pre&gt;

&lt;p&gt;If function has only a single argument in the argument list, its parameter list is just empty set of parentheses.&lt;/p&gt;

&lt;pre&gt;
const func = () =&amp;gt; {
  return "Hello, world";
}
&lt;/pre&gt;

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