<?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: Baljeet Singh</title>
    <description>The latest articles on DEV Community by Baljeet Singh (@mbaljeetsingh).</description>
    <link>https://dev.to/mbaljeetsingh</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%2F176397%2Fdac9f870-5b1c-49a1-8c15-ec96863a6cf0.jpeg</url>
      <title>DEV Community: Baljeet Singh</title>
      <link>https://dev.to/mbaljeetsingh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mbaljeetsingh"/>
    <language>en</language>
    <item>
      <title>Which is Array Reduce method in Javascript</title>
      <dc:creator>Baljeet Singh</dc:creator>
      <pubDate>Wed, 21 Jul 2021 05:28:28 +0000</pubDate>
      <link>https://dev.to/mbaljeetsingh/which-is-array-reduce-method-in-javascript-2294</link>
      <guid>https://dev.to/mbaljeetsingh/which-is-array-reduce-method-in-javascript-2294</guid>
      <description>&lt;p&gt;&lt;strong&gt;Reduce&lt;/strong&gt; method in javascript is used to reduce the array to a single value. It takes a callback function which takes four parameters (accumulator, currentValue, index, array), but mostly we use the first two.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--E25aMWhv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/dljpca7mb/v1626843737/baljeetsingh.in/carbon_1_reyngn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--E25aMWhv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/dljpca7mb/v1626843737/baljeetsingh.in/carbon_1_reyngn.png" alt="array reduce method syntax"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let's take a look at some of the examples,&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Calculate sum of all the elements in an array&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const arr = [2,3,5,4];

// here accumulator is names sum
// item is the current value
// 0 is the initial value
const arraySum = arr.reduce((sum, item) =&amp;gt; sum + item, 0);
console.log('Output is: ', arraySum);
// Output is: 14
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Calculate total number of fruits in the array&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const fruits = [
  { name: 'Apple', quantity: 3 },
  { name: 'Banana', quantity: 4 },
  { name: 'Mango', quantity: 2 },
];

const totalFruits = fruits.reduce((total, fruit) =&amp;gt; total + fruit.quantity, 0);
console.log('Total Fruits are:', totalFruits);
// Total Fruits are: 9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Group Students by ClassName&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const students = [
  { name: 'Baljeet', className: 10 },
  { name: 'Fatehjit', className: 2 },
  { name: 'Ekjeet', className: 10 },
  { name: 'Manvir', className: 5 },
];
const output = students.reduce((groupedStudents, student) =&amp;gt; {
  const className = student.className;
  if (groupedStudents[className] == null) {
    groupedStudents[className] = [];
  }
  groupedStudents[className].push(student);
  return groupedStudents;
}, {});
console.log('Grouped Students: ', output);
/* output 
{ 2: [ { name: 'Fatehjit', className: 2 } ],
  5: [ { name: 'Manvir', className: 5 } ],
  10: [ { name: 'Baljeet', className: 10 },
     { name: 'Ekjeet', className: 10 } ] } */
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
    </item>
    <item>
      <title>What is CSR, SSR, SSG, ISR (Different Rendering Strategies) and which framework does it better (Angular, React, Vue)</title>
      <dc:creator>Baljeet Singh</dc:creator>
      <pubDate>Wed, 21 Jul 2021 05:27:40 +0000</pubDate>
      <link>https://dev.to/mbaljeetsingh/what-is-csr-ssr-ssg-isr-different-rendering-strategies-and-which-framework-does-it-better-angular-react-vue-4lkp</link>
      <guid>https://dev.to/mbaljeetsingh/what-is-csr-ssr-ssg-isr-different-rendering-strategies-and-which-framework-does-it-better-angular-react-vue-4lkp</guid>
      <description>&lt;p&gt;01) &lt;strong&gt;CSR&lt;/strong&gt; stands for Client Side Rendering. Here the entire website is rendered in the browser.  &lt;/p&gt;

&lt;p&gt;Use when building a admin dashboard and when seo is not important. Required javascript enabled on the browser.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Angular, React, Vue&lt;/strong&gt; all support it out of the box.  &lt;/p&gt;

&lt;p&gt;02) &lt;strong&gt;SSR&lt;/strong&gt; stands for Server Side Rendering. Here the webpages are rendered on the server and then sent to the client.  &lt;/p&gt;

&lt;p&gt;Use when speed and seo is important. App works without javascript enabled in browser.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Angular&lt;/strong&gt; supports it via Angular Universal&lt;br&gt;&lt;br&gt;
&lt;strong&gt;React&lt;/strong&gt; via NextJS&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Vue&lt;/strong&gt; via NuxtJS  &lt;/p&gt;

&lt;p&gt;03) &lt;strong&gt;SSG&lt;/strong&gt; stands for Static Site Generation. Here the webpages are rendered on the build time.  &lt;/p&gt;

&lt;p&gt;Use when speed and seo is important. Host the app on any static hosting (netlify/vercel)  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Angular&lt;/strong&gt; supports it via Scully/Angular Universal&lt;br&gt;&lt;br&gt;
&lt;strong&gt;React&lt;/strong&gt; via NextJS/Gatsby&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Vue&lt;/strong&gt; via NuxtJS/Gridsome  &lt;/p&gt;

&lt;p&gt;04) &lt;strong&gt;ISR&lt;/strong&gt; stands for Incremental Static Regeneration. Here the webpages are regenerated on the fly based after the defined time.  &lt;/p&gt;

&lt;p&gt;Same benefits as SSG. Entire app doesn't need to be build after each change.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Angular&lt;/strong&gt; doesn't support it&lt;br&gt;&lt;br&gt;
&lt;strong&gt;React&lt;/strong&gt; via NextJS&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Vue&lt;/strong&gt; doesn't support it  &lt;/p&gt;

&lt;p&gt;Can you share an app you built and which rendering strategy and framework you used❓&lt;/p&gt;

</description>
    </item>
    <item>
      <title>FOUR DIFFERENT WAYS TO WRITE FUNCTIONS IN JAVASCRIPT</title>
      <dc:creator>Baljeet Singh</dc:creator>
      <pubDate>Thu, 03 Oct 2019 07:25:27 +0000</pubDate>
      <link>https://dev.to/mbaljeetsingh/four-different-ways-to-write-functions-in-javascript-30fm</link>
      <guid>https://dev.to/mbaljeetsingh/four-different-ways-to-write-functions-in-javascript-30fm</guid>
      <description>&lt;p&gt;&lt;strong&gt;Functions&lt;/strong&gt; are the basic building blocks of the Javascript. A &lt;strong&gt;function&lt;/strong&gt; in Javascript is a code block that performs a specific task or set of tasks.&lt;br&gt;
There are basically &lt;strong&gt;4&lt;/strong&gt; (four) different ways we can define &lt;strong&gt;functions&lt;/strong&gt; in Javascript.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Function Declaration&lt;/li&gt;
&lt;li&gt;Function Expression&lt;/li&gt;
&lt;li&gt;Arrow Function Expression&lt;/li&gt;
&lt;li&gt;Concise Arrow Function Expression
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Function Declaration&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;square&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Function Expression&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;square&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Arrow Function Expression&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;square&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Concise Arrow Function Expression&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;square&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;If you prefer you can take a look at the video tutorial,&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/DaVmnMHppq4"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

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