<?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: buginit</title>
    <description>The latest articles on DEV Community by buginit (@buginit).</description>
    <link>https://dev.to/buginit</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%2F260480%2Fe6188b4a-f215-411b-8bd4-837475a4f42b.jpg</url>
      <title>DEV Community: buginit</title>
      <link>https://dev.to/buginit</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/buginit"/>
    <language>en</language>
    <item>
      <title>Things you need to know about Tagged Template Literal in JavaScript</title>
      <dc:creator>buginit</dc:creator>
      <pubDate>Sun, 24 Nov 2019 07:24:12 +0000</pubDate>
      <link>https://dev.to/buginit/things-you-need-to-know-about-tagged-template-literal-in-javascript-412o</link>
      <guid>https://dev.to/buginit/things-you-need-to-know-about-tagged-template-literal-in-javascript-412o</guid>
      <description>&lt;p&gt;In simple words: &lt;a href="https://buginit.com/category/javascript/"&gt;JavaScript&lt;/a&gt; Tagged template literal is a function call that uses a &lt;a href="https://buginit.com/javascript/all-you-need-to-know-about-template-literals/"&gt;template literal&lt;/a&gt; to get its arguments.&lt;br&gt;
Here is a tagged function example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;greet&lt;/span&gt;&lt;span class="s2"&gt;`I'm &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="s2"&gt;. I'm &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="s2"&gt; years old.`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Don't get yourself confused, In the above example, &lt;code&gt;greet&lt;/code&gt; is a function that takes three arguments&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The first parameter is an &lt;a href="https://buginit.com/tag/arrays/"&gt;array&lt;/a&gt; containing all of the text from our template literal.&lt;/li&gt;
&lt;li&gt;The 2nd to infinity parameters in our function are the variables to be inserted into our tag function.
Here I'll show you the greet function from inside in detail.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// creating name and age variable &lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;buginit&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;age&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;// creating a greet function&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;strings&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="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;str0&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;strings&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;// "I'm"&lt;/span&gt;
  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;str1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;strings&lt;/span&gt;&lt;span class="p"&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;// ". I'm"&lt;/span&gt;
  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;str2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;strings&lt;/span&gt;&lt;span class="p"&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;// "years old."&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;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// buginit&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;age&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="c1"&gt;// calling greet function here and passing &lt;/span&gt;
&lt;span class="c1"&gt;// name and age variable that we created above&lt;/span&gt;
&lt;span class="nx"&gt;greet&lt;/span&gt;&lt;span class="s2"&gt;`I'm &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="s2"&gt;. I'm &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="s2"&gt; years old.`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


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



&lt;p&gt;Explanation: First we created two variables called &lt;code&gt;name&lt;/code&gt; and &lt;code&gt;age&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Then we defined the &lt;code&gt;greet&lt;/code&gt; function,&lt;/p&gt;

&lt;p&gt;And then called the &lt;code&gt;greet&lt;/code&gt; function with those two variables and some strings around using Tagged Template Literals. So the &lt;code&gt;greet&lt;/code&gt; function will receive all the strings as an &lt;a href="https://buginit.com/tag/arrays/"&gt;array&lt;/a&gt; in the first argument and those variables in the rest of the arguments as shown in the above example please read comments inside example.&lt;/p&gt;

&lt;p&gt;I hope you got the picture in your mind.&lt;/p&gt;

&lt;p&gt;Wanna see more example and real-word examples check this out &lt;a href="https://buginit.com/javascript/a-complete-guide-tagged-template-literal-in-javascript/"&gt;A Complete Guide: Tagged Template Literal In JavaScript&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Originally published at &lt;a href="https://buginit.com/javascript/a-complete-guide-tagged-template-literal-in-javascript/"&gt;buginit.com&lt;/a&gt; on October 9, 2019. For latest updates follow &lt;a href="https://buginit.com"&gt;buginit&lt;/a&gt;&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Here Is The Powerful Guide Of Spread Operator/Syntax In ES6</title>
      <dc:creator>buginit</dc:creator>
      <pubDate>Thu, 14 Nov 2019 02:52:07 +0000</pubDate>
      <link>https://dev.to/buginit/here-is-the-powerful-guide-of-spread-operator-syntax-in-es6-49a1</link>
      <guid>https://dev.to/buginit/here-is-the-powerful-guide-of-spread-operator-syntax-in-es6-49a1</guid>
      <description>&lt;p&gt;Spread Operator in &lt;a href="https://buginit.com/tag/javascript/" rel="noopener noreferrer"&gt;ES6&lt;/a&gt; or syntax ( according to MDN it is syntax) so let’s call it syntax. Well, they also call it &lt;strong&gt;three dot operator&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So how it looks like?&lt;/strong&gt; Oh, it is simply three dots &lt;code&gt;...&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When did it release?&lt;/strong&gt; Of course in ES6.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it actually does?&lt;/strong&gt; The spread operator in &lt;a href="https://buginit.com/tag/javascript/" rel="noopener noreferrer"&gt;ES6&lt;/a&gt; turns iterable values into arguments. we will come back on definition later, for now&lt;/p&gt;

&lt;h2&gt;
  
  
  Let’s understand with an example.
&lt;/h2&gt;

&lt;p&gt;Let say: you have two &lt;a href="https://buginit.com/tag/arrays/" rel="noopener noreferrer"&gt;arrays&lt;/a&gt; called &lt;code&gt;mid&lt;/code&gt; and &lt;code&gt;all&lt;/code&gt;. And you have to insert &lt;code&gt;mid&lt;/code&gt; in the middle of &lt;code&gt;all&lt;/code&gt;. Quickly!!!&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;mid&lt;/span&gt; &lt;span class="o"&gt;=&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="mi"&gt;4&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;all&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;mid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Expected Output: &lt;code&gt;[1, 2, 3, 4, 5, 6]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Awesome!! That’s all, Yeah you got it!!&lt;/p&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%2Fbuginit.com%2Fwp-content%2Fuploads%2F2019%2F10%2Five-never-been-proud-of-you-meme-300x261.jpg" 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%2Fbuginit.com%2Fwp-content%2Fuploads%2F2019%2F10%2Five-never-been-proud-of-you-meme-300x261.jpg" alt="a meme for you"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;According to MDN, Here you got the long boring definition below:&lt;/p&gt;

&lt;p&gt;Spread syntax allows an iterable such as an array expression or string to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected, or an object expression to be expanded in places where zero or more key-value pairs (for object literals) are expected.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So that’s all, do I know all about it?&lt;/strong&gt; Naa! man, life isn’t that easy 🙁&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;What actually you can do with spread syntax? Let’s break it down with examples in short.&lt;/strong&gt;
&lt;/h4&gt;

&lt;h2&gt;
  
  
  #1 Apply for new
&lt;/h2&gt;

&lt;p&gt;When calling a constructor with new it’s not possible to directly use an array as arguments. But now you can use an array directly 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;var&lt;/span&gt; &lt;span class="nx"&gt;dateFields&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1970&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="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;  &lt;span class="c1"&gt;// 1 Jan 1970&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;d&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;Date&lt;/span&gt;&lt;span class="p"&gt;(...&lt;/span&gt;&lt;span class="nx"&gt;dateFields&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;a href="https://buginit.com/javascript/here-is-the-powerful-guide-of-spread-operator-syntax/" rel="noopener noreferrer"&gt;To see all 6 types of example the complete guide of Spread Operator/Syntax In ES6&lt;/a&gt;
&lt;/h3&gt;

</description>
      <category>javascript</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How To Debug JavaScript Like A Pro.</title>
      <dc:creator>buginit</dc:creator>
      <pubDate>Fri, 08 Nov 2019 03:04:55 +0000</pubDate>
      <link>https://dev.to/buginit/how-to-debug-javascript-like-a-pro-32pg</link>
      <guid>https://dev.to/buginit/how-to-debug-javascript-like-a-pro-32pg</guid>
      <description>&lt;p&gt;First of all, I want to tell you, yes there are good and bad ways to console.log in &lt;a href="https://buginit.com/category/javascript/"&gt;JavaScript&lt;/a&gt; that can make your life easier as a JavaScript developer. So let’s get started on how to debug javascript?&lt;/p&gt;

&lt;p&gt;Let’s imagine we have 3 objects to log like below.&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;foo&lt;/span&gt; &lt;span class="o"&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;tom&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;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;nervous&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&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;bar&lt;/span&gt; &lt;span class="o"&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;dick&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;40&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;nervous&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&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;baz&lt;/span&gt; &lt;span class="o"&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;harry&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;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;nervous&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Bad Code 💩
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;foo&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="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bar&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="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;baz&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In the above approach, the problem is we don’t have the variables name to see which one is which? You have to concatenate a string to see which is which. &lt;/p&gt;

&lt;h3&gt;
  
  
  Good Code ✅
&lt;/h3&gt;

&lt;p&gt;But there is a trick called Computed Property Names/property shorthands&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;bar&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;baz&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;It reduces the code but also shows exactly which variable defines the data.&lt;/p&gt;

&lt;p&gt;one line of code.&lt;br&gt;
one console log.&lt;br&gt;
and all the specified information.&lt;/p&gt;

&lt;h3&gt;
  
  
  There is more in this tutorial here &lt;a href="https://buginit.com/javascript/how-to-debug-javascript-like-a-pro/"&gt;To see all examples with results click here&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Follow for latest updates &lt;a href="https://facebook.com/buginit"&gt;Facebook&lt;/a&gt; &lt;a href="https://twitter.com/buginit"&gt;Twitter&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>tutorial</category>
      <category>beginners</category>
      <category>productivity</category>
    </item>
    <item>
      <title>22 Examples Of Arrow Function JavaScript: Part 1</title>
      <dc:creator>buginit</dc:creator>
      <pubDate>Thu, 07 Nov 2019 00:47:08 +0000</pubDate>
      <link>https://dev.to/buginit/22-examples-of-arrow-function-javascript-part-1-372c</link>
      <guid>https://dev.to/buginit/22-examples-of-arrow-function-javascript-part-1-372c</guid>
      <description>&lt;p&gt;An Arrow Function in &lt;a href="https://buginit.com/category/javascript/"&gt;JavaScript&lt;/a&gt; also called a “Fat arrow” function is a syntactically compact alternative to a regular function expression. It allows us to write shorter function syntax. Arrow functions are anonymous and change the way &lt;code&gt;this&lt;/code&gt; binds in functions.&lt;/p&gt;

&lt;p&gt;Arrow functions doesn’t support its own bindings to the &lt;code&gt;this&lt;/code&gt;, &lt;code&gt;arguments&lt;/code&gt;, &lt;code&gt;super&lt;/code&gt;, or &lt;code&gt;new.target&lt;/code&gt; keywords.&lt;/p&gt;

&lt;h3&gt;
  
  
  #1 Basic Example
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var materials = [
  'JavaScript',
  'HTML',
  'CSS',
  'Buginit.com'
];
// before 
console.log(materials.map(function (material) { return material.length}));
// with arrow function
console.log(materials.map(material =&amp;gt; material.length));
// expected output: Array [10, 4, 3, 11]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  #2 Basic syntax
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(param1, param2, …, paramN) =&amp;gt; { statements } 
(param1, param2, …, paramN) =&amp;gt; expression
// equivalent to: =&amp;gt; { return expression; }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  #2.1 Optional Parentheses
&lt;/h4&gt;

&lt;p&gt;Parentheses are optional when there’s only one parameter present:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(singleParam) =&amp;gt; { statements }
singleParam =&amp;gt; { statements }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  #2.2 Without Parameters
&lt;/h4&gt;

&lt;p&gt;If you do not have any parameters then it should be written with a pair of parentheses like the example below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;() =&amp;gt; { statements }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;a href="https://buginit.com/javascript/an-advanced-guide-of-arrow-function-javascript/"&gt;To see all 22 examples of Arrow Function Click here&lt;/a&gt;
&lt;/h3&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://buginit.com/javascript/an-advanced-guide-of-arrow-function-javascript-part-2/"&gt;Part 2&lt;/a&gt;
&lt;/h3&gt;

</description>
      <category>javascript</category>
      <category>tutorial</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Do You Really Know JavaScript Includes Method?</title>
      <dc:creator>buginit</dc:creator>
      <pubDate>Wed, 06 Nov 2019 02:10:58 +0000</pubDate>
      <link>https://dev.to/buginit/do-you-really-know-javascript-includes-method-49le</link>
      <guid>https://dev.to/buginit/do-you-really-know-javascript-includes-method-49le</guid>
      <description>&lt;p&gt;&lt;a href="https://buginit.com/category/javascript/"&gt;JavaScript&lt;/a&gt; includes method is very handy when you need to search or find something in the array or string, yes it works on both. It returns the Boolean value true if the array contains the value and false if not, and the same applied to the &lt;a href="https://buginit.com/tag/strings/"&gt;strings&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  #1 Array Example
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var array1 = [1, 2, 3];

console.log(array1.includes(2));
// expected output: true

var pets = ['cat', 'dog', 'bat'];

console.log(pets.includes('cat'));
// expected output: true

console.log(pets.includes('at'));
// expected output: false
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  #1.1 Find by Specific Index
&lt;/h3&gt;

&lt;p&gt;In &lt;a href="https://buginit.com/category/javascript/"&gt;JavaScript&lt;/a&gt; include method, you can also find values from specific indexes, as second parameter it receives &lt;code&gt;fromIndex&lt;/code&gt; for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var array1 = [1, 2, 3];

console.log(array1.includes(2, 1));
// expected output: true

var array1 = [1, 2, 3];

console.log(array1.includes(2, 2));
// expected output: false
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In the above example, we are passing &lt;code&gt;fromIndex&lt;/code&gt; in the second parameter to tell the &lt;code&gt;include()&lt;/code&gt; method that if the value exists from that specific index.&lt;/p&gt;

&lt;h3&gt;
  
  
  To read &lt;a href="https://buginit.com/javascript/do-you-really-know-javascript-includes-method/"&gt;Full 9 examples of JavaScript Includes Method click here&lt;/a&gt;
&lt;/h3&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>7 Examples Of JavaScript Dynamic Import ES10</title>
      <dc:creator>buginit</dc:creator>
      <pubDate>Sun, 03 Nov 2019 11:08:47 +0000</pubDate>
      <link>https://dev.to/buginit/7-examples-of-javascript-dynamic-import-es10-319m</link>
      <guid>https://dev.to/buginit/7-examples-of-javascript-dynamic-import-es10-319m</guid>
      <description>&lt;p&gt;In this article, we will talk about &lt;a href="https://buginit.com/category/javascript/"&gt;JavaScript&lt;/a&gt; Dynamic Import that introduced in &lt;a href="https://buginit.com/tag/es10/"&gt;ES10/2019&lt;/a&gt;, we will cover basics and different types of examples also we will take a look at static and &lt;a href="https://buginit.com/javascript/7-examples-javascript-dynamic-import-es10/"&gt;Dynamic Import&lt;/a&gt; in JavaScript. And don’t worry I’m not going to give you a long lecture, we will cover this with small points and examples.&lt;/p&gt;

&lt;p&gt;Let’s start, Basically dynamic import is a new function like import statement that introduced in ES10/2019 and it returns a promise. As we know let’s have a look at static import of JavaScript below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import MyModule from './my-module.js';
import { NamedExport } from './other-module.js';
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now, Let’s have a look at the basic JavaScript dynamic import statement.&lt;/p&gt;

&lt;h2&gt;
  
  
  #1 Simple Single Line Example
&lt;/h2&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import("module/foo.js").then(foo =&amp;gt; console.log(foo.default))
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In the above example, we used the single-line statement of Arrow function for console.log to make it shorter. You can also use the normal function like the below example:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import('module/foo.js').then(function(foo) {
  console.log(foo.default);
})
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;a href="https://buginit.com/javascript/7-examples-javascript-dynamic-import-es10/"&gt;To Read full 7 Examples Of JavaScript Dynamic Import ES10 click here&lt;/a&gt;
&lt;/h4&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>JavaScript Destructuring ES6: The Complete Guide</title>
      <dc:creator>buginit</dc:creator>
      <pubDate>Tue, 29 Oct 2019 11:04:56 +0000</pubDate>
      <link>https://dev.to/buginit/javascript-destructuring-es6-the-complete-guide-2opi</link>
      <guid>https://dev.to/buginit/javascript-destructuring-es6-the-complete-guide-2opi</guid>
      <description>&lt;p&gt;In this article, we are gonna learn about &lt;a href="https://buginit.com/category/javascript/"&gt;javascript&lt;/a&gt; destructuring that is introduced in ES6. You can learn all the features of javascript destructuring step by step with approx 17 types of examples.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://buginit.com/category/javascript/"&gt;JavaScript&lt;/a&gt; destructuring assignment syntax is expressive, compact and more readable that makes it possible to “destructured” (upwarp) values from arrays or properties from objects, into different variables.&lt;/p&gt;

&lt;h1&gt;
  
  
  JavaScript Destructuring Expression (demo)
&lt;/h1&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[a, b] = [50, 100];

console.log(a);
// expected output: 50

console.log(b);
// expected output: 100

[a, b, ...rest] = [10, 20, 30, 40, 50];

console.log(rest);
// expected output: [30,40,50]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  We can use JavaScript Destructuring in so many different ways.
&lt;/h3&gt;

&lt;h2&gt;
  
  
  TLDR;
&lt;/h2&gt;

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

&lt;p&gt;&lt;a href="https://buginit.com/tag/arrays/"&gt;Array&lt;/a&gt; destructuring is very much similar and straight forward, you can use an array literal on the left-hand-side of an assignment expression. Each variable name on the array literal maps to the corresponding item at the same index on the destructured array.&lt;/p&gt;

&lt;h2&gt;
  
  
  #1.1 Basic variable assignment.
&lt;/h2&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let foo = ['one', 'two', 'three'];

let [red, yellow, green] = foo;
console.log(red); // "one"
console.log(yellow); // "two"
console.log(green); // "three"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;To read the full guide of 17 examples &lt;a href="https://buginit.com/javascript/javascript-destructuring-es6-the-complete-guide/"&gt;click here&lt;/a&gt;&lt;/p&gt;

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