<?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: Muhammad    Uzair</title>
    <description>The latest articles on DEV Community by Muhammad    Uzair (@uzairsamad).</description>
    <link>https://dev.to/uzairsamad</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%2F348473%2Ff24f8f84-9f71-4ebf-bb56-1ebd57c7b925.jpeg</url>
      <title>DEV Community: Muhammad    Uzair</title>
      <link>https://dev.to/uzairsamad</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/uzairsamad"/>
    <language>en</language>
    <item>
      <title>How to get the two maximum values from Array of Objects using reduce method javascript.</title>
      <dc:creator>Muhammad    Uzair</dc:creator>
      <pubDate>Sat, 25 Mar 2023 17:20:25 +0000</pubDate>
      <link>https://dev.to/uzairsamad/how-to-get-the-two-maximum-values-from-array-of-objects-using-reduce-method-javascript-48g5</link>
      <guid>https://dev.to/uzairsamad/how-to-get-the-two-maximum-values-from-array-of-objects-using-reduce-method-javascript-48g5</guid>
      <description>&lt;p&gt;To get the two maximum values from an array of objects using the reduce() method in JavaScript, we can follow a similar approach to the one we used for the array of numbers. However, we need to modify the reducer function to account for the fact that we are working with objects instead of numbers.&lt;/p&gt;

&lt;p&gt;Here's an example:&lt;br&gt;
&lt;code&gt;const arr = [  { name: 'John', age: 25 },  { name: 'Alice', age: 30 },  { name: 'Bob', age: 28 },  { name: 'Mary', age: 35 },];&lt;br&gt;
const twoMaxValues = arr.sort((a, b) =&amp;gt; b.age - a.age)&lt;br&gt;
  .reduce((acc, curr) =&amp;gt; {&lt;br&gt;
    if (acc.length &amp;lt; 2) {&lt;br&gt;
      acc.push(curr);&lt;br&gt;
    } else if (curr.age &amp;gt; acc[1].age) {&lt;br&gt;
      acc[0] = acc[1];&lt;br&gt;
      acc[1] = curr;&lt;br&gt;
    } else if (curr.age &amp;gt; acc[0].age) {&lt;br&gt;
      acc[0] = curr;&lt;br&gt;
    }&lt;br&gt;
    return acc;&lt;br&gt;
  }, []);&lt;br&gt;
console.log(twoMaxValues); // [{ name: 'Mary', age: 35 }, { name: 'Alice', age: 30 }]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We start by sorting the array in descending order based on the age property of the objects using the sort() method with a comparison function that subtracts b.age from a.age.&lt;/p&gt;

&lt;p&gt;Next, we use the reduce() method to iterate over the sorted array. As before, we start with an empty array ([]) as the initial value for the accumulator (acc).&lt;/p&gt;

&lt;p&gt;Inside the reducer function, we first check if the accumulator has less than two values. If so, we simply push the current object to the accumulator array.&lt;/p&gt;

&lt;p&gt;If the accumulator already has two values, we compare the age property of the current object to the age properties of the objects in the accumulator. If the current object has a higher age than the second highest object in the accumulator (acc[1]), we replace acc[1] with the current object, and move the previous second highest object to the first position (acc[0] = acc[1]).&lt;/p&gt;

&lt;p&gt;Finally, if the current object has a higher age than the first object in the accumulator (acc[0]), we replace it with the current object.&lt;/p&gt;

&lt;p&gt;The reduce() method will return an array with the two objects with the highest age properties, which are the two objects with the highest ages in the original array of objects.&lt;/p&gt;

&lt;p&gt;In the example above, the two objects with the highest ages are { name: 'Mary', age: 35 } and { name: 'Alice', age: 30 }, which are returned as the twoMaxValues array.&lt;/p&gt;

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

</description>
    </item>
    <item>
      <title>How to get the two maximum values from reduce method javascript.</title>
      <dc:creator>Muhammad    Uzair</dc:creator>
      <pubDate>Sat, 25 Mar 2023 17:14:57 +0000</pubDate>
      <link>https://dev.to/uzairsamad/how-to-get-the-two-maximum-values-from-reduce-method-javascript-3a1l</link>
      <guid>https://dev.to/uzairsamad/how-to-get-the-two-maximum-values-from-reduce-method-javascript-3a1l</guid>
      <description>&lt;p&gt;In JavaScript, the reduce() method is used to reduce an array to a single value. It is a powerful tool that can be used to solve various problems, including finding the two maximum values from an array.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;const arr = [10, 20, 30, 40, 50];&lt;/code&gt;&lt;br&gt;
&lt;code&gt;const [max1, max2] = arr.reduce(([first, second], current) =&amp;gt; {&lt;br&gt;
  if (current &amp;gt; first) {&lt;br&gt;
    second = first;&lt;br&gt;
    first = current;&lt;br&gt;
  } else if (current &amp;gt; second) {&lt;br&gt;
    second = current;&lt;br&gt;
  }&lt;br&gt;
  return [first, second];&lt;br&gt;
}, [-Infinity, -Infinity]);&lt;/code&gt;&lt;br&gt;
&lt;code&gt;console.log(max1); // Output: 50&lt;br&gt;
console.log(max2); // Output: 40&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Here, we're using destructuring assignment to extract the first two values returned by reduce into max1 and max2. We start by initializing the accumulator to [-Infinity, -Infinity], which will be used to track the two largest numbers. We then iterate over the array, comparing each value to the two largest values found so far. If the current value is greater than the largest value, we shift the largest value to the second largest value, and set the largest value to the current value. If the current value is greater than the second largest value but less than or equal to the largest value, we set the second largest value to the current value. Finally, we return the updated accumulator, which contains the two largest values found in the array.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>reactnative</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Grading Students
</title>
      <dc:creator>Muhammad    Uzair</dc:creator>
      <pubDate>Thu, 24 Dec 2020 08:44:05 +0000</pubDate>
      <link>https://dev.to/uzairsamad/grading-students-2ce</link>
      <guid>https://dev.to/uzairsamad/grading-students-2ce</guid>
      <description>&lt;p&gt;while working with hacker-rank problem-solving challenge, I just stuck in question of finding the results according to given criteria.&lt;br&gt;
Criteria: &lt;br&gt;
1) Find the next number from given input that is divisible by 5.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    i-e =&amp;gt; Input is  73 so the number will be 75
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;2) Find the difference between actual input and the discovered.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    i-e =&amp;gt; 73 -75 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;3) If the difference between them is smaller than 3 then the &lt;br&gt;
   student will be awarded a discovered number as a grade else it &lt;br&gt;
   will remain the same as input&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  i-e 
    1) Input 73 - 75 = 2 //difference is less than 3 So, Grade 
    will be 75 here
    2) Input  67 - 70  = 3 // difference is less than 3 So, 
 Grade will be 67 here
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;4) If input is 33 or less then simply return it no need for any &lt;br&gt;
   processing  &lt;/p&gt;

&lt;p&gt;Solution:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  function gradingStudents(grades) {
   let final = [];
     for (let b = 0; b &amp;lt; grades.length; b++) {
      let base = parseInt(grades[b]);
       let val = parseInt(grades[b]);
       if (base &amp;lt; 38) {
        final.push(base);
        } else {
        for (let a = 0; a &amp;lt; 5; a++) {
            if (val % 5 == 0) {
                if (val - base &amp;lt; 3) {
                    final.push(val);
                    break;
                } else {
                    final.push(base);
                    break;
                }
            } else {
                val++;
            }
        }
    }
}
return final
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Hope you find this helpful or if there is any optimize method of solving this kindly recommend in a comment section.&lt;br&gt;
Thanks.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>problemsolving</category>
      <category>programming</category>
      <category>development</category>
    </item>
    <item>
      <title>How to check if Number is Float in JS</title>
      <dc:creator>Muhammad    Uzair</dc:creator>
      <pubDate>Thu, 17 Sep 2020 11:50:56 +0000</pubDate>
      <link>https://dev.to/uzairsamad/how-to-check-if-number-is-float-in-js-h98</link>
      <guid>https://dev.to/uzairsamad/how-to-check-if-number-is-float-in-js-h98</guid>
      <description>&lt;p&gt;Usually we check types in javascript by using typeOf method but javascript doesn't support float type so it return a Number when you check a type of float number.&lt;br&gt;
Like: typeOf(4.56) = Number&lt;/p&gt;

&lt;p&gt;How to check if number is float or not in JS:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   function isFloat(n){
      return Number(n) === n &amp;amp;&amp;amp; n % 1 !== 0;
    }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Explanation:&lt;br&gt;
If the mod of a number divided by 1  is not equal to zero then it must a float number.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>challenge</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Factorial with Recursive Function in JS</title>
      <dc:creator>Muhammad    Uzair</dc:creator>
      <pubDate>Thu, 17 Sep 2020 11:19:04 +0000</pubDate>
      <link>https://dev.to/uzairsamad/factorial-with-recursive-function-in-js-4h2m</link>
      <guid>https://dev.to/uzairsamad/factorial-with-recursive-function-in-js-4h2m</guid>
      <description>&lt;p&gt;Write a function to find a factorial of a number .&lt;br&gt;
example: Factorial of 5! = 5*4*3*2*1&lt;/p&gt;

&lt;p&gt;I have done this by implementing two methods:&lt;/p&gt;

&lt;p&gt;By For Loop:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     function factorial(val){
         var numbers = val;
           for(let i = val-1; i &amp;gt; 0; i--) {
               numbers = numbers * i;
              }
         return numbers;
         }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;By Recursion Method:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    function factorial(x) 
         { 
         if (x === 0)
         {
         return 1;
           }
       return x * factorial(x-1);
           }
     console.log(factorial(6));
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

</description>
    </item>
    <item>
      <title>DOM Manipulation</title>
      <dc:creator>Muhammad    Uzair</dc:creator>
      <pubDate>Sun, 30 Aug 2020 19:31:18 +0000</pubDate>
      <link>https://dev.to/uzairsamad/dom-manipulation-nfo</link>
      <guid>https://dev.to/uzairsamad/dom-manipulation-nfo</guid>
      <description>&lt;p&gt;In this task I was told to create a HTML Button and manipulate it with my javascript.&lt;br&gt;
The button's initial text label is 0. After each click, the button must increment by 1. Recall that the button's text label is the JS object's innerHTML property.&lt;/p&gt;

&lt;h4&gt;
  
  
  html
&lt;/h4&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;       &amp;lt;html&amp;gt;
           &amp;lt;head&amp;gt;
              &amp;lt;link rel="stylesheet" href="css/button.css" 
              type="text/css"&amp;gt;
              &amp;lt;meta charset="utf-8"&amp;gt;
              &amp;lt;title&amp;gt;Button&amp;lt;/title&amp;gt;
          &amp;lt;/head&amp;gt;
         &amp;lt;body&amp;gt; 
           &amp;lt;button id='btn' &amp;gt;0&amp;lt;/button&amp;gt;
           &amp;lt;script src="js/button.js" type="text/javascript"&amp;gt; 
           &amp;lt;/script&amp;gt;
          &amp;lt;/body&amp;gt;
    &amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;
  
  
  css
&lt;/h4&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     #btn{
           width:96px;
           height:48px;
           font-size:24px;
          }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;
  
  
  js
&lt;/h4&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt; document.addEventListener('DOMContentLoaded', () =&amp;gt; {
  const button = document.getElementById('btn');

 button.addEventListener('click', (e) =&amp;gt; {
      const count = Number(e.currentTarget.innerText) + 1;

      e.currentTarget.innerText = count;
     });
   });
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

</description>
      <category>javascript</category>
      <category>html</category>
      <category>css</category>
    </item>
    <item>
      <title>Reversing a String</title>
      <dc:creator>Muhammad    Uzair</dc:creator>
      <pubDate>Sun, 30 Aug 2020 16:28:53 +0000</pubDate>
      <link>https://dev.to/uzairsamad/reversing-a-string-319b</link>
      <guid>https://dev.to/uzairsamad/reversing-a-string-319b</guid>
      <description>&lt;p&gt;Reverse string  using the split, reverse, and join methods.&lt;br&gt;
If an exception is thrown, catch it and print the contents of the exception's  on a new line.&lt;br&gt;
Print  on a new line. If no exception was thrown, then this should be the reversed string; if an exception was thrown, this should be the original string. &lt;/p&gt;


&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt; function reverseString(s) {&lt;br&gt;
   try {&lt;br&gt;
    let reversString = s.split("").reverse()&lt;br&gt;
    console.log(reversString.join(""))&lt;br&gt;&lt;br&gt;
    }&lt;br&gt;
 catch (e) {&lt;br&gt;
     console.log(e.message);&lt;br&gt;
    console.log(s)&lt;br&gt;
    }&lt;br&gt;&lt;br&gt;
  }&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Explanation:&lt;br&gt;
&lt;/h4&gt;

&lt;p&gt;-The split method converts the string into array.&lt;br&gt;
-The reverse methods reverse the entries of an array. &lt;br&gt;
-The Join methods finally prints the array entries with joining &lt;br&gt;
 them according to the condition you pass in parenthesis.&lt;/p&gt;

&lt;p&gt;Output:&lt;/p&gt;


&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     reverseString("1234")&lt;br&gt;
     Output = 4321&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Try,Catch&lt;br&gt;
&lt;/h4&gt;

&lt;p&gt;I have used this try catch because if the data type will be other than string so the split function will not be applicable it will give runtime error,But in my case if there will be any error it will sent to catch block rather than displaying runtime error it will display a message.  &lt;/p&gt;

&lt;p&gt;Hope you find this helpful.&lt;/p&gt;

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

</description>
    </item>
    <item>
      <title>Looping Task </title>
      <dc:creator>Muhammad    Uzair</dc:creator>
      <pubDate>Sun, 30 Aug 2020 12:34:44 +0000</pubDate>
      <link>https://dev.to/uzairsamad/looping-task-54ob</link>
      <guid>https://dev.to/uzairsamad/looping-task-54ob</guid>
      <description>&lt;p&gt;I was doing Hacker Rank Javascript 10 Day Challenge in which i saw a problem and thought that  i would share. &lt;/p&gt;

&lt;p&gt;Q: Complete the vowelsAndConsonants function in the editor below. It has one parameter, a string, , consisting of lowercase English alphabetic letters (i.e., a through z). The function must do the following:&lt;/p&gt;

&lt;p&gt;First, print each vowel in  on a new line. The English vowels are a, e, i, o, and u, and each vowel must be printed in the same order as it appeared in .&lt;br&gt;
Second, print each consonant (i.e., non-vowel) in  on a new line in the same order as it appeared in .&lt;/p&gt;

&lt;h3&gt;
  
  
  I have done this by adding two loops in my function
&lt;/h3&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt; function vowelsAndConsonants(s) {
  let vowel = ['a','e','i','o','u']
  for(var i=0; i&amp;lt; s.length;i++){
      if(vowel.includes(s.charAt(i))){
        console.log(s.charAt(i))
    }
 }
  for(var i=0; i&amp;lt; s.length;i++){
    if(!vowel.includes(s.charAt(i))){
        console.log(s.charAt(i))
     }
 }
 }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;
  
  
  Calling the function
&lt;/h4&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  vowelsAndConsonants(javascript)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;
  
  
  Output:
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  a
  a
  i
  o
  o
  j
  v
  s
  c
  r
  p
  t
  l
  p
  s
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Observe:&lt;br&gt;
Each letter is printed on a new line.&lt;br&gt;
Then the vowels are printed in the same order as they appeared in the input&lt;br&gt;
Then the consonants are printed in the same order as they appeared in input&lt;/p&gt;

&lt;p&gt;Hope you find this helpful and if there is any optimize method to do this kindly tell me in the comment section&lt;/p&gt;

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

</description>
      <category>javascript</category>
      <category>challenge</category>
    </item>
    <item>
      <title>How to find a count of specific character in a string and take out dynamic value out of a repeating {{}} character in JavaScript</title>
      <dc:creator>Muhammad    Uzair</dc:creator>
      <pubDate>Wed, 10 Jun 2020 20:10:18 +0000</pubDate>
      <link>https://dev.to/uzairsamad/how-to-find-a-count-of-specific-character-in-a-string-and-take-out-dynamic-value-out-of-a-repeating-character-in-javascript-abe</link>
      <guid>https://dev.to/uzairsamad/how-to-find-a-count-of-specific-character-in-a-string-and-take-out-dynamic-value-out-of-a-repeating-character-in-javascript-abe</guid>
      <description>&lt;p&gt;I was working in JavaScript since last year,I have taken in a great experiences from various situations,As a developer we are facing new scenarios everyday and learning new things with every rising sun, Like yesterday i was supposed to solve a problem to find a count of specific character  {{}} repeating in my string and to catch a value in it which will always be different depends on user input.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem 1: Finding the count  {{}}  this in my string
&lt;/h2&gt;

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

&lt;p&gt;It will first finds that either two curly brackets  opening at the same time then it will return an array contains all the possible matches .The g in it is the parameter of Regular Expression it  will search globally.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem 2 : Taking the dynamic values out of  {{}}   from a string based on user input
&lt;/h2&gt;

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

&lt;p&gt;In this case i have applied this function on my input box if its value changes, the function checks that if curly brackets occur then it will return an array.&lt;br&gt;
If there will be one match found then it will return the value in array with an index[0] but if there may be more than one match found it was returning an array with first match at index 0 and then two empty strings on index 1 and index 2 and then second match on index 3,it repeats this behavior after every match , So that's why i applied a loop with i+=3 at every iteration it will take a step of 2.&lt;/p&gt;

&lt;p&gt;May be it was an expensive method  but it solved my problem,As I have not worked much with Regular Expressions so that's why may be it was scrambled and time taken process but it worked for me.&lt;/p&gt;

&lt;p&gt;Hope you find this article useful. Please share your thoughts or if there is any method by which this can be done easily in the comment section.&lt;/p&gt;

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

</description>
      <category>javascript</category>
      <category>regularexpressions</category>
      <category>coding</category>
    </item>
    <item>
      <title>Some ES-6 Features </title>
      <dc:creator>Muhammad    Uzair</dc:creator>
      <pubDate>Sun, 12 Apr 2020 14:24:47 +0000</pubDate>
      <link>https://dev.to/uzairsamad/some-es-6-features-3if5</link>
      <guid>https://dev.to/uzairsamad/some-es-6-features-3if5</guid>
      <description>&lt;h2&gt;
  
  
  Rest Operator
&lt;/h2&gt;

&lt;p&gt;The rest parameter syntax allows us to represent an indefinite number of arguments as an array&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt; function add(num1,...args){ in args it will return array containing numbers
    return args[0]+args[1]

 }
  console.log(add(1,3,5));   in args there is 3,5 so the sum will be 8
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;
  
  
  Spread Operator
&lt;/h2&gt;

&lt;p&gt;It will unpack the values of a array,this method will not affect a original element but creates copy&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt; let arr = ["a","b","c","d"]
 let arr2 = ["e","f","g"]
 let newarr = [...arr , ...arr2];    combine both array into new one
 console.log(newarr); result===&amp;gt;  ["a","b","c","d","e","f","g"]
 newarr.push("h");   it will just push into the new array           
 console.log(newarr);   result===&amp;gt;  ["a","b","c","d","e","f","g","h"]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;
  
  
  Template Literals
&lt;/h2&gt;

&lt;p&gt;It is replacement to single/double quotes,it also gives facility to addd variables or do operations,start with backticks instead of quotes&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt; var para = ` My Name is         
 Uzair `
 console.log(para); It will include line break in result
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Interpolate with backticks&lt;/strong&gt;&lt;br&gt;
Adding variables in between or performing operations&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  var  myVariable = `test1`
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;${}&lt;/strong&gt; is used to combine variable in it&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  var variable2 = `Something ${ myVariable }`  
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;you can also perform operation in it&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt; var variable3 = `sum is ${1+2+3} ` you can also perform operation in it
 console.log(variable2 + variable3)   
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;for of loop&lt;/strong&gt;&lt;br&gt;
prints all the values of list &lt;br&gt;
iterates all the elements&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt; let list = [1,2,7,4,5,6] 
  for(let value of list){
    console.log(value); 
  } result ====&amp;gt; 123456
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;for in loop&lt;/strong&gt;&lt;br&gt;
it will iterate the length / index not elements&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let list = [1,2,7,4,5,6]
       for(i in list){
           console.log(i);
            } 0,1,2,3,4,5   all indexes of array 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;
  
  
  Arrow Functions
&lt;/h2&gt;

&lt;p&gt;An arrow function expression is a syntactically compact alternative to a regular  function expression,The fat arrows are amazing because they would make your this behave properly, i.e., this will have the same value as in the context of the function&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt; hello = () =&amp;gt; {
     return "Hello World!";
  }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;
  
  
  Sets
&lt;/h2&gt;

&lt;p&gt;A Set is a collection of unique elements&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const arr = [5, 1, 5, 7, 7, 5];
const unique = [...new Set(arr)]; // [ 5, 1, 7 ]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;
  
  
  Maps
&lt;/h2&gt;

&lt;p&gt;The map() method in JavaScript creates an array by calling a specific function on each element present in the parent array.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     var el = document.getElementById('root'); 
     var arr = [2, 5, 6, 3, 8, 9]; 

    var newArr = arr.map(function(val, index){ 
        return {key:index, value:val*val}; 
    })     
    console.log(newArr) 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Hope you find this article useful. Please share your thoughts in the comment section.&lt;/p&gt;

</description>
      <category>es6</category>
      <category>javascript</category>
      <category>programming</category>
      <category>wevdev</category>
    </item>
    <item>
      <title>Destructuring of Objects</title>
      <dc:creator>Muhammad    Uzair</dc:creator>
      <pubDate>Sat, 11 Apr 2020 17:57:56 +0000</pubDate>
      <link>https://dev.to/uzairsamad/destructuring-of-objects-4lc7</link>
      <guid>https://dev.to/uzairsamad/destructuring-of-objects-4lc7</guid>
      <description>&lt;h2&gt;
  
  
  Destructuring objects
&lt;/h2&gt;

&lt;p&gt;Destructuring on objects lets you bind variables to different properties of an object. You specify the property being bound, followed by the variable you are binding its value to.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var data = {
       name : "Uzair",
       age : 17,
       gender : "male"
   }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;destructuring object items name into name and so on..&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   var {name,age,person} = data
   console.log(age)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;it is also possible to retrive values to a object that is not declared&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  var {name,age,gender} = {name:"Catty" , age:"21" , gender:"female"}
  console.log(age)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;it is also possible to assing value to variable that are declared before&lt;br&gt;
the name of new variable should be same as the keys of object otherwise it will be undifined&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      var data = {
          name : "Uzair",
          age : 17,
          gender : "male"
      };
      var name,age,gender;

     ({name,age,gender} = data);
      console.log(age);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;if we want to use a new variable name and assing it object key value&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt; var data = {
        name: "Uzair",
        age: 17,
        gender: "male",
     };
     //changing key names with new variables
      var { name: nickname, age: umer } = data;
      console.log(nickname); //it will render uzair
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;using default value , it will assing only in-case when key is not there / undefined&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;          var data = {
          name : "Uzair",
          age : 17,
          gender : "male"
      }

  var {name="usama" , friend ="wahab"} = data

  console.log(name); // name is same as the object value

  console.log(friend); //friend is with default value of wahab
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;we can also set default value when assinging with a new name&lt;br&gt;
if the variable will match with the object key it will assing values from object otherwise it will &lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  var data = {
        name: "Uzair",
        age: 17,
        gender: "male",
      };

    var {
      name: nickname = "uzey",
      age: umer = "barahogya",
      friend: dost = "some text",
    } = data;
    console.log(name); //here name will be assigned the uzair because it 
    exits in object
    console.log(dost); //it will assing some text
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;computed property name&lt;br&gt;
 you can specify the name of a property&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var data = {
     name: "Uzair",
     age: 17,
     gender: "male",
   };

  var prop = "name";    //here we are assinging object key name in prop
  var { [prop]: myname } = data;  
  the value of myname will be the value of data.name prop has key name in it 
  it will find value from abject**
  console.log(myname);  //we will get Uzair in result 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;rest method means you can assing more the one value to a variable&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        var data = {
           name: "Uzair",
           age: 17,
           gender: "male",
           friends: ["faiq", "ibad", "wahib"],
                  };

    var { name, ...others } = data;
    console.log(name); //result will be uzair
    console.log(others); //result will be {  age: 17
                                             gender: "male"
                                            friends:["faiq", "ibad", "wahib"]
                                           }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Hope you find this article useful. Please share your thoughts in the comment section.&lt;/p&gt;

</description>
      <category>es6</category>
      <category>computerscience</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Destructuring of Array</title>
      <dc:creator>Muhammad    Uzair</dc:creator>
      <pubDate>Fri, 10 Apr 2020 17:15:31 +0000</pubDate>
      <link>https://dev.to/uzairsamad/destructuring-of-array-4fnf</link>
      <guid>https://dev.to/uzairsamad/destructuring-of-array-4fnf</guid>
      <description>&lt;p&gt;&lt;strong&gt;Concept&lt;/strong&gt; &lt;br&gt;
The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays.It is an elegant way to extract data from arrays. &lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    var array = ["My","Name","IS","Uzair"]
    console.log(array); //result ==&amp;gt;  ["My","Name","IS","Uzair"]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;name1 will be assigned by My &amp;amp; name2 will be with Name   &lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    var [name1,name2] = ["My","Name","IS","Uzair"]   
    console.log(name1);//result ==&amp;gt; My
    console.log(name2);//result ==&amp;gt; Name
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;( ,)comma is used skip one element every time&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    //name3 will be assigned by Is $ name4 will be with Uzair
    var [,,name3,name4] = ["My","Name","IS","Uzair"]
    console.log(name3);//result ==&amp;gt; IS
    console.log(name4);//result ==&amp;gt; Uzair
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;( ... ) &lt;strong&gt;spread operator&lt;/strong&gt;(three dots)  unpack the string and this will be assinged like a array&lt;br&gt;
 here name5 will be My and newArray will be the new array containing remaining elements&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    var [name5,...newArray] = ["My","Name","IS","Uzair"]
    console.log(newArray);//result==&amp;gt; ["Name","IS","Uzair"]
    console.log(name5);// result==&amp;gt; My
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Hope you find this article useful. Please share your thoughts in the comment section.&lt;/p&gt;

</description>
      <category>es6</category>
      <category>webdev</category>
      <category>computerscience</category>
    </item>
  </channel>
</rss>
