<?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: Preetika Taneja</title>
    <description>The latest articles on DEV Community by Preetika Taneja (@preetikataneja).</description>
    <link>https://dev.to/preetikataneja</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%2F450517%2Fc6eb2565-eaa0-445f-9526-3ef0e898468e.png</url>
      <title>DEV Community: Preetika Taneja</title>
      <link>https://dev.to/preetikataneja</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/preetikataneja"/>
    <language>en</language>
    <item>
      <title>A Brief dig into ES6</title>
      <dc:creator>Preetika Taneja</dc:creator>
      <pubDate>Sat, 15 Aug 2020 12:53:05 +0000</pubDate>
      <link>https://dev.to/preetikataneja/a-brief-dig-into-es6-1l71</link>
      <guid>https://dev.to/preetikataneja/a-brief-dig-into-es6-1l71</guid>
      <description>&lt;p&gt;&lt;strong&gt;'ES'&lt;/strong&gt; in ES6 stands for the &lt;strong&gt;ECMA Script&lt;/strong&gt;. In 2015, we got the &lt;strong&gt;sixth version&lt;/strong&gt; of ECMA script which we call as &lt;strong&gt;ES6&lt;/strong&gt;. It was finalized in 2015 and it includes abundance of excellent features.&lt;br&gt;
The major added features in ES6 were:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;'let' and 'const'&lt;/li&gt;
&lt;li&gt;default parameter values&lt;/li&gt;
&lt;li&gt;generators&lt;/li&gt;
&lt;li&gt;template strings&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;and many more&lt;/p&gt;

&lt;p&gt;However, not all the browsers support all the newer features of JavaScript. In such a case,  &lt;a href="https://babeljs.io/"&gt;Babel&lt;/a&gt; comes to rescue. Babel is just a compiler. In simple words, Babel takes your version of JavaScript and translate into that version of JavaScript which the browsers understand. One of the cool things about Babel is that you can use it with the ESNext features and you can even choose which browser you want it to support.&lt;/p&gt;

&lt;p&gt;In this article, I am going to discuss about a few of those features which were new in the ES6 version of JavaScript.&lt;/p&gt;

&lt;h2&gt;
  
  
  So, Let us dig into these features one by one ✌
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;em&gt;Let&lt;/em&gt; and &lt;em&gt;const&lt;/em&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;ES6 introduced two new ways to create variables: Let and const&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Let&lt;/strong&gt; is a kind of replacement of var. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;const&lt;/strong&gt; is used to assign constant values to identifiers. The value of const cannot be updated later in the code.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hUPGR65o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1597314291676/3OSdF_MM_.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hUPGR65o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1597314291676/3OSdF_MM_.png" alt="letconst.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Template Strings
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Template string is nothing but just a string which allows embedding expressions inside it. We use  the backtick (``) to describe template strings. &lt;/li&gt;
&lt;li&gt;Template strings help to make the code more readable and they also provide syntatic sugar for constructing strings.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, we would normally embed strings using this way:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--J4Ic-rS8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1597315352912/h5g8aEmw8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--J4Ic-rS8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1597315352912/h5g8aEmw8.png" alt="woTS.png"&gt;&lt;/a&gt;&lt;br&gt;
However, Template strings make embedding of strings much easier and readable as shown:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pS00MB80--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1597315685330/fQJhLf4PW.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pS00MB80--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1597315685330/fQJhLf4PW.png" alt="wTS.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Arrows
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;ES6 gives us a new syntax for defining functions using a fat arrow &lt;strong&gt;=&amp;gt;&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Arrow function helps to bring clarity and a lot of code reduction.
The following two code snippets show how we can implement the same function without and with using Arrow functions respectively.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wEu7xbaI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1597317441957/kfKENeW_Y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wEu7xbaI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1597317441957/kfKENeW_Y.png" alt="woAF.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2PmB0H1o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1597318457558/94pn_0QQ9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2PmB0H1o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1597318457558/94pn_0QQ9.png" alt="wAF.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Also, we need not write the keyword 'function' while using Arrow functions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Rest operator and Spread operator
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The Rest operator allows us to represent any number of arguments as an array. For example, &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lRKK1CZn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1597324486191/wBknbCFuO.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lRKK1CZn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1597324486191/wBknbCFuO.png" alt="ro.png"&gt;&lt;/a&gt;&lt;br&gt;
Here, we can change the number of arguments to be passed anytime without worrying about whether the function will give the right output or not.&lt;br&gt;
In this case I have passed 5 arguments i.e. &lt;em&gt;2,3,4,1,10&lt;/em&gt;, so the output here will be 240. If you pass 4 arguments i.e. &lt;em&gt;2,3,4,1&lt;/em&gt;, the output comes out to be 24.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Spread operator is used to expand an iterable object or string into a list of arguments. Its syntax is similar to rest operator but it is the opposite of Rest operator. Spread syntax "expands" an array into its elements, while rest syntax collects multiple elements and "condenses" them into a single element.
Spread operator is basically used to concatenate multiple objects or multiple arrays.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KlnggbL_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1597327808309/2LI4GP2nh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KlnggbL_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1597327808309/2LI4GP2nh.png" alt="SO.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Destructuring
&lt;/h3&gt;

&lt;p&gt;Destructuring, as the name suggests, allows us to &lt;strong&gt;unpack&lt;/strong&gt; arrays and objects into a bunch of variables which makes working with arrays and objects a bit more convenient. Destructuring allows binding using pattern matching.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ENEaw0Rl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1597339139249/HBkalqDI0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ENEaw0Rl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1597339139249/HBkalqDI0.png" alt="ds.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Classes
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The concept of Classes is similar as used in other programming languages. Classes are templates for creating objects. The class syntax has two components -class expression and class declaration.&lt;/li&gt;
&lt;li&gt;The class name(identifier) should start with a capital letter.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0DhFIj7t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1597339909606/ZXwF-lEV9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0DhFIj7t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1597339909606/ZXwF-lEV9.png" alt="c.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, these were a few of those features that I like the most in ES6. It was hard to cover all the features in a single blog while keeping it crisp and short. &lt;/p&gt;

&lt;p&gt;Please give it a thumbs up if my blog serves to help you.  😃&lt;/p&gt;

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