<?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>Forem: Aditya Sharan</title>
    <description>The latest articles on Forem by Aditya Sharan (@adityasharan01).</description>
    <link>https://forem.com/adityasharan01</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%2F399970%2Feee8b375-48bc-460d-8f76-ff1fb0a45461.jpg</url>
      <title>Forem: Aditya Sharan</title>
      <link>https://forem.com/adityasharan01</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/adityasharan01"/>
    <language>en</language>
    <item>
      <title>TypeScript Quick Guide 101</title>
      <dc:creator>Aditya Sharan</dc:creator>
      <pubDate>Wed, 18 May 2022 06:39:02 +0000</pubDate>
      <link>https://forem.com/adityasharan01/typescript-quick-guide-101-6fn</link>
      <guid>https://forem.com/adityasharan01/typescript-quick-guide-101-6fn</guid>
      <description>&lt;p&gt;One appropriate next step for the React application would be to integrate TypeScript in order to add a layer of robustness and security.&lt;/p&gt;

&lt;p&gt;TypeScript is a JavaScript superset that adds new features to the language, being one of the most important ones that, with TypeScript, you can add type-checking to your projects. TypeScript is the step that JavaScript needed to look like a high-level programming language (like Java).&lt;/p&gt;

&lt;p&gt;My intention with this (short) article, is to write a quick guide with some of the most important features TypeScript has, without diving that much. So, let’s begin.&lt;/p&gt;

&lt;p&gt;Most Important Types&lt;br&gt;
: string&lt;br&gt;
: number&lt;br&gt;
: boolean&lt;br&gt;
: array&lt;br&gt;
: any&lt;br&gt;
: void&lt;br&gt;
: null&lt;br&gt;
: undefined&lt;br&gt;
How to apply types to your variables&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let myVariable: number;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An array filled only with elements of a specific type type&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let strArr: string[];

//or

let strArr: Array&amp;lt;string&amp;gt;;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Tuples&lt;br&gt;
You use tuples when your array needs to contain a specific type of values in certain indexes. If the array overpass the size of the tuple, an error would not be throw. The only condition is to fulfill the requirements of the tuple.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let strNumTuple: [string, number];

strNumTuple = [3, ‘Hello’, 1, 2, 3]: // this would be correct.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Adding types to functions&lt;br&gt;
You can add types to the parameters of a function, so, when the function is called, the types of the arguments would need to match. The type after the parameter represents the type of value the function should return.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const mySum = function(num1:number,num2:number):number{

return num1 + num2;

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Interfaces&lt;br&gt;
Let’s say you need that the argument passed to your function needs to be an object with values of specific types. This is one case when interfaces come in handy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface Todo{

title: string;

text: string;

} 
/* the object passed as an argument 
should contain at least values with those types.*/

function showTodo(todo: Todo){

console.log(todo.title+’ ‘+todo.text)

}

let myTodo = {title:’Trash’, text:’take out trash’};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And this is all for now…&lt;br&gt;
Being TypeScript one of the best ways to strengthen applications that need JavaScript, it gains every day more and more importance in nowadays market. So, these days, to only learn JavaScript without Type it’s kind of pointless, and even if JavaScript evolves tomorrow and add features similar to TypeScript, these features are (almost for sure) going to be implemented in a very similar way (well, those are just my predictions).&lt;/p&gt;

</description>
    </item>
    <item>
      <title>React Testing Library — My Notes</title>
      <dc:creator>Aditya Sharan</dc:creator>
      <pubDate>Mon, 16 May 2022 16:20:03 +0000</pubDate>
      <link>https://forem.com/adityasharan01/react-testing-library-my-notes-3mdn</link>
      <guid>https://forem.com/adityasharan01/react-testing-library-my-notes-3mdn</guid>
      <description>&lt;p&gt;Some quick answers to common RTL-related questions.&lt;/p&gt;

&lt;p&gt;Run tests&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;yarn run test&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Where to usually place the tests?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inside a &lt;strong&gt;test&lt;/strong&gt; folder.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What is a common way to name tests?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Component.test.tsx&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What is usually needed to import in test files?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from “react”; //React
import Counter from “../Counter”; //The component to test
import { render } from “@testing-library/react”;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;render is used for rendering the component in the virtual dom so you can then test what has been rendered. Due to this, it usually goes inside a beforeEach.&lt;/p&gt;

&lt;p&gt;What would be an example of a basic test?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;test(“header renders with correct test”, () =&amp;gt; {
     const { getByTestId } = render(&amp;lt;Counter /&amp;gt;);
     const headerEl = getByTestId(“header”);
     expect(headerEl.textContent).toBe(“My Counter”);
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The test's first argument would be the description.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The second argument would be a function with the actions of the tests.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;expect is the function that actually does the test.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It is not a good practice to use getByTestId. This is just an example.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What would be a general description of testing with RTL?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You render a component.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then you look and select elements inside the component.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then you can:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Execute actions on the element (like clicks) and then verify the expected results.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Or just check the element to have the right values without executing any action before.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What would be an example of checking the right values in an element?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Expects the text content inside the element ‘headerEl’ to be the specific string “My Counter”.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;expect(headerEl.textContent).toBe(“My Counter”);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you can’t find any way to select an element you want to, what is the last resource you can use?&lt;/p&gt;

&lt;p&gt;getByTestId and the element need to be marked with the property:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;data-testid
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What is useful for simulating actions?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The most used way is userEvent (because it is more similar to the user):
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import userEvent from ‘@testing-library/user-event’; 
userEvent.dblClick(checkbox);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;But, fireEvent can also be used:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fireEvent.change(inputEl, {
     target: {
          value: “5”
     }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What can you do if you expect something not to have a certain value?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;With not.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;expect(headerEl.textContent).not.toBe(“My Counter”);&lt;br&gt;
How to output the code in the terminal?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;screen.debug()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  That's all folks !!
&lt;/h3&gt;

</description>
    </item>
    <item>
      <title>React Virtual DOM Explained in Plain English</title>
      <dc:creator>Aditya Sharan</dc:creator>
      <pubDate>Mon, 05 Jul 2021 11:35:18 +0000</pubDate>
      <link>https://forem.com/adityasharan01/react-virtual-dom-explained-in-simple-english-10j6</link>
      <guid>https://forem.com/adityasharan01/react-virtual-dom-explained-in-simple-english-10j6</guid>
      <description>&lt;p&gt;We still don't catch how Virtual DOM works. Actually, what is DOM? They say Document Object Model. Well, but what is it exactly? The DOM in simple words represents the UI of your application. &lt;/p&gt;

&lt;h3&gt;
  
  
  Let's dive in.
&lt;/h3&gt;

&lt;p&gt;When a browser downloads the HTML document it creates the tree-like representation of that document, the so-called Object Model where every HTML tag has its corresponding node. &lt;/p&gt;

&lt;p&gt;In that way, Javascript gets access to the HTML tags and can change them: add styles, modify or even delete them. &lt;/p&gt;

&lt;p&gt;Making these changes is not slow. What makes the process slow and costly is how the browser organizes those changes. In every update, HTML parser reads the HTML document then DOM is being created, at the same time CSS parser parses the stylesheets and applies style rules. As a result of the process, Attachment is being created. Afterward, Layout process gives the exact co-ordinates to each node of the render tree, i.e. each element's exact coordinates on the screen.&lt;/p&gt;

&lt;p&gt;So the Render tree is ready, then go Painting and Display.&lt;/p&gt;

&lt;h2&gt;
  
  
  What makes DOM manipulation slow?
&lt;/h2&gt;

&lt;p&gt;Updating DOM is a slow and expensive process&lt;br&gt;
You have to traverse DOM to find a node and update it.&lt;br&gt;
Updating DOM has cascading effects - things need to be recalculated.&lt;/p&gt;

&lt;h2&gt;
  
  
  Virtual DOM
&lt;/h2&gt;

&lt;p&gt;the concept of virtual DOM comes in and performs significantly better than the real DOM. The virtual DOM is only a virtual representation of the DOM. Everytime the state of our application changes, the virtual DOM gets updated instead of the real DOM.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Well, you may ask ” Isn’t the virtual DOM doing the same thing as the real DOM, this sounds like double work? How can this be faster than just updating the real DOM?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  How is Virtual DOM faster?
&lt;/h2&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F02llb1lq9vc25v7l8dfb.PNG" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F02llb1lq9vc25v7l8dfb.PNG" alt="Alt Text" width="762" height="570"&gt;&lt;/a&gt;&lt;br&gt;
There are always two versions of VDOM. One is before the changes and the other is after the changes. So when changes occur React compares two VDOMs and detects the changes.&lt;br&gt;
This process is called ''diffing''.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fel7lvii9tmfkof2c5heo.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fel7lvii9tmfkof2c5heo.png" alt="Alt Text" width="800" height="335"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The changed objects only get updated on the real Dom. Changes in the real DOM cause the screen to change. This is called ''reconciliation''. &lt;/p&gt;

&lt;p&gt;VDOM is like a blueprint and making changes in it is more efficient.&lt;br&gt;
Instead of rendering all changes to the real DOM, we apply them first to the Virtual DOM, which is doesn't get rendered. So the changes to it are very cheap.&lt;/p&gt;

&lt;p&gt;Thanks for reading!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>javascript</category>
      <category>dom</category>
    </item>
    <item>
      <title>10 Daily useful JS code snippets</title>
      <dc:creator>Aditya Sharan</dc:creator>
      <pubDate>Sun, 27 Jun 2021 13:08:23 +0000</pubDate>
      <link>https://forem.com/adityasharan01/10-daily-useful-js-code-snippets-99m</link>
      <guid>https://forem.com/adityasharan01/10-daily-useful-js-code-snippets-99m</guid>
      <description>&lt;p&gt;JavaScript is without question one of the most popular programming languages in web dvelopment.&lt;br&gt;
Take a look at following code snippets that solve similar problems in an elegant way and use this knowledge in daily project situations or to prepare for any upcoming coding interviews.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;1. Reverse a String&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In this example, we are using the spread operator (...), the reverse method from Array, and the join method from String to reverse a given string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const reverseString = string =&amp;gt; [...string].reverse().join('');
//Examples
reverseString('devto'); //otved
reverseString('AdityaSharan'); //narahSaytidA
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;2. Calculate a Number's Factorial&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To calculate the factorial of a given number, we can make use of arrow function and nested ternary operators.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const factorialOfNumber= number =&amp;gt;
   number &amp;lt; 0  ?
(   () =&amp;gt; 
    {
     throw new TypeError('No negative numbers please');
    }
)()
: number &amp;lt;= 1
? 1
:number * factorialOfNumber(number -1);
//Examples
factorialOfNumber(4);  //24
factorialOfNumber(8);  //40320
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;3. Convert a Number to an Array of Digits&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In this example,we use spread operator (...),the map method of Array and the parseInt function to convert a given number to an array of single digits.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const convertToArrays = number =&amp;gt; [...`${number}`].map(ele =&amp;gt;
parseInt(ele));

//Examples
convertToArrays(5678); //[5,6,7,8]
convertToArrays(123456789); //[1,2,3,4,5,6,7,8,9]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;4. Check If a Number Is a Power of Two&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This one is pretty Straight forward.We check that number is not falsy and use the bitwise AND operator (&amp;amp;) to determine if number is power of two.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const isNumberPowerOfTwo = number =&amp;gt; !!number &amp;amp;&amp;amp; (number &amp;amp; (
number -1)) == 0 ;

//Examples
isNumberPowerOfTwo(100); //false
isNumberPowerOfTwo(128); //true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;5. Create an Array of Key-Value pairs From an Object&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In this example, we use the keys method from Object and the map method from Array to map over Object's keys and create an array of key-value pairs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const keyValuePairsToArray = object =&amp;gt; Object.keys(object)
.map(ele =&amp;gt; [ele,object[el]]);

//Examples
keyValuePairsToArray({Java :4 ,Script : 2});
// [  ['Java', 4] , ['Script',2] ]
keyValuePairsToArray( {x:1, y:5, z:8} );
// [ ['x',1], ['y',5], ['z',3] ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;6. Return [Number] Maximum Elements from an Array&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To return the maximum elements from an array, we use an arrow function that takes our array and the number of elements we want the function to return. We use the spread operator(...) and the sort and slice methods from Array. Note that if we dont provide a second argument,number gets a default value of 1, so only one maximum element is returned.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const maxElementsFromArray = (array,number =1) =&amp;gt;[...array]
.sort((x,y) =&amp;gt; y-x).slice(0,number);

//Example
maxElementsFromArray([1,2,3,4,5,6,7]); //[7]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;7. Check if All Elements in an Array Are Equal&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In this example,we check if all elements in an array by using the every method from Array. We basically chekc if every element is equal to the first element in the array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const elementsAreEqual = array =&amp;gt; array.every( ele =&amp;gt; ele=== array[0]);
//Examples
elementsAreEqual([9,8,7,6,5,4]); // false
elementsAreEqual([2,2,2,2,2,2,2]); // true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;8. Return the Average of Two Numbers&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In this example,we use the spread operator(...) and the reduce method from Array to return the average of two given numbers or an array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const averageOfTwoNumbers = (...numbers) =&amp;gt; numbers.reduce((accumulator, currentValue) =&amp;gt; accumulator+currentValue,0) /numbers.length
//Examples
averageOfTwoNumbers (...[6,7,8]); // 7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;9. Return the Sum of Two or More Numbers&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To return the sum of two or more given numbers or an array, we agauin use the spread operator (...) and the reduce method from an Array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const sumOfNumbers = (...array) =&amp;gt; [...array].reduce((accumulator,currentValue) =&amp;gt; accumulator + currentValue, 0);
//Examples
sumOfNumbers(5,6,7,8,9,10);  //45
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;10. Return the PowerSet of an Array Of Numbers&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In the last Example,we want to return the powerset of an array of numbers.Therefore we use the reduce,map and the concat methods from Array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const powersetOfArray = array =&amp;gt; array.reduce((accumulator,currentValue) =&amp;gt; accumulator.concat(accumulator.map(ele =&amp;gt; [currentValue].concat(el))),[ [] ] );

//ExAMPLES
powersetOfArray([4,2]);
// [[],[4],[2],[2,4]]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see it isn't always difficult to solve these tasks with Javascript  and some ES6 Magic.&lt;br&gt;
Thanks for reading!&lt;br&gt;
Don't forget to like this post and &lt;br&gt;
Do let me knw if you knw some good code snippets that can be added in the list so that even I can learn from it.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>discuss</category>
      <category>programming</category>
    </item>
    <item>
      <title>[Facts Alert]When to use which one ?MySQL Vs MongoDB</title>
      <dc:creator>Aditya Sharan</dc:creator>
      <pubDate>Wed, 31 Mar 2021 05:52:06 +0000</pubDate>
      <link>https://forem.com/adityasharan01/facts-alert-when-to-use-which-one-sql-vs-nosql-1p2i</link>
      <guid>https://forem.com/adityasharan01/facts-alert-when-to-use-which-one-sql-vs-nosql-1p2i</guid>
      <description>&lt;h1&gt;
  
  
  Hello everyone!
&lt;/h1&gt;

&lt;p&gt;In this post I will share about SQL vs NoSQL, most of you are already familiar with SQL database, and have a good knowledge on either MySQL, SQL Server, or other SQL databases. In the last several years, NoSQL database is getting widely adopted to solve various problems.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h1&gt;
  
  
  &lt;strong&gt;MongoDB&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;MongoDB is one of the most popular document-oriented databases under the banner of NoSQL database. It employs the format of key-value pairs, here called document store. Document stores in MongoDB are created is stored in BSON files which are, in fact, a little-modified version of JSON files and hence all JS are supported.It offers greater efficiency and reliability which in turn can meet your storage capacity and speed demands. The schema-free implementation of MongoDB eliminates the prerequisites of defining a fixed structure. These models allow hierarchical relationships representation and facilitate the ability to change the structure of the record.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;MongoDB has a lower latency per query &amp;amp; spends less CPU time per query because it is doing a lot less work (e.g. no joins, transactions). As a result, it can handle a higher load in terms of queries per second.&lt;/li&gt;
&lt;li&gt;MongoDB has a faster write speed because it does not have to worry about transactions or rollbacks (and thus does not have to worry about locking).&lt;/li&gt;
&lt;li&gt;NoSQL databases are cheap and open source.&lt;/li&gt;
&lt;li&gt;NoSQL database support caching in system memory so it increases data output performance.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;MongoDb does not support transactions.&lt;/li&gt;
&lt;li&gt;In general, MongoDB creates more work (e.g. more CPU cost) for the client server. For example, to join data one has to issue multiple queries and do the join on the client.&lt;/li&gt;
&lt;li&gt;No Stored Procedures in mongo dB (NoSQL database).&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;h1&gt;
  
  
  &lt;strong&gt;MySQL&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;MySQL is a popular open-source relational database management system (RDBMS) that is developed, distributed and supported by Oracle Corporation. MySQL stores data in tables and uses structured query language (SQL) for database access. It uses Structured Query Language SQL to access and transfer the data and commands such as 'SELECT', 'UPDATE', 'INSERT' and 'DELETE' to manage it.Related information is stored in different tables but the concept of JOIN operations simplifies the process of correlating it and performing queries across multiple tables and minimize the chances of data duplication. It follows the ACID (Atomic, Consistent, Isolated and Durable) model. This means that once a transaction is complete, the data remains consistent and stable on the disc which may include distinct multiple memory locations.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SQL databases are table based databases.&lt;/li&gt;
&lt;li&gt;Data store in rows and columns.&lt;/li&gt;
&lt;li&gt;Each row contains a unique instance of data for the categories defined by the columns.&lt;/li&gt;
&lt;li&gt;Provide facility primary key, to uniquely identify the rows.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Users have to scale relational database on powerful servers that are expensive and difficult to handle. To scale relational database, it has to be distributed on to multiple servers. Handling tables across different servers is difficult.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In SQL server\'s data has to fit into tables anyhow. If your data doesn't fit into tables, then you need to design your database structure that will be complex and again difficult to handle.&lt;/p&gt;
&lt;h2&gt;
  
  
  I have used NoSql Only... as i'm a beginner and there is lot to learn ,here are few insights of using NoSQL
&lt;/h2&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Storing large volumes of data without structure&lt;/strong&gt;: A NoSQL database doesn\'t limit storable data types. Plus, you can add new types as business needs change.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Using cloud computing and storage&lt;/strong&gt;: Cloud-based storage is a great solution, but it requires data to be easily spread across multiple servers for scaling. Using affordable hardware on-site for testing and then for production in the cloud is what NoSQL databases are designed for.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Rapid development&lt;/strong&gt;: If you are developing using modern agile methodologies, a relational database will slow you down. A NoSQL database doesn\'t require the level of preparation typically needed for relational databases.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Would be glad to know what are your reasons for using SQLDB or NoSQL DB.&lt;br&gt;
Comment down below 👇&lt;/p&gt;

</description>
      <category>sql</category>
      <category>database</category>
      <category>webdev</category>
      <category>nosql</category>
    </item>
    <item>
      <title>[BASICS] REACT.JS BEST PRACTICES IN PLAIN ENGLISH.</title>
      <dc:creator>Aditya Sharan</dc:creator>
      <pubDate>Sat, 20 Mar 2021 22:28:08 +0000</pubDate>
      <link>https://forem.com/adityasharan01/basics-follow-these-easy-practices-to-write-react-code-h8o</link>
      <guid>https://forem.com/adityasharan01/basics-follow-these-easy-practices-to-write-react-code-h8o</guid>
      <description>&lt;p&gt;1 . Component name must start with capitals letters.&lt;/p&gt;

&lt;p&gt;2 . All the component must be small and function-specific.&lt;/p&gt;

&lt;p&gt;3 . All the component must have small description&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="cm"&gt;/**
*
* Author: {...}
* Description: {...}
* Dependencies: {...}
*
**/&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;SampleComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&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="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nx"&gt;Sample&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;SampleComponent&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4 . All code must follow es6 coding standards.&lt;/p&gt;

&lt;p&gt;5 . For variables that are NOT constants or constructors, multi-word variables and functions SHOULD be lowerCamelCased.&lt;/p&gt;

&lt;p&gt;6 . Constants:- Pre-defined constants SHOULD be all-uppercase, and words separated by underscores: UPPER_UNDERSCORED.&lt;/p&gt;

&lt;p&gt;7 . Typeof:- In type comparisons, the value tested MUST NOT be wrapped in parenthesis and use triple equals to.&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="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;myVariable&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;8 . In simple condition, Ternary operator should be used instead of if else statement.&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="c1"&gt;// If-else Statement&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;condition&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;//...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;//...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Ternary operator&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;myVariable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;condition&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;exprIfTrue&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;exprIfFalse&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;9 . fragments should be used instead of container div.&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="nf"&gt;render&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="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Fragment&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
       &lt;span class="nx"&gt;Some&lt;/span&gt; &lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h2&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;A&lt;/span&gt; &lt;span class="nx"&gt;heading&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h2&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="nx"&gt;More&lt;/span&gt; &lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h2&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Another&lt;/span&gt; &lt;span class="nx"&gt;heading&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h2&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;       &lt;span class="nx"&gt;Even&lt;/span&gt; &lt;span class="nx"&gt;more&lt;/span&gt; &lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Fragment&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;10 . All files related to any one component should be in a single folder&lt;/p&gt;

&lt;p&gt;11 . Functional components should be favored if we do not need to make use of React state.&lt;/p&gt;

&lt;p&gt;12 . Anonymous functions should not be used as handlers.&lt;/p&gt;

&lt;p&gt;13 . Inline styles should not be used inside component.&lt;/p&gt;

&lt;p&gt;14 . For a component to hide itself return null from render.&lt;/p&gt;

&lt;p&gt;15 . Higher Order Components should be used for cross-cutting concerns.&lt;/p&gt;

&lt;p&gt;16 . Prefer state initialization in class member variable declaration over constructor&lt;/p&gt;

&lt;p&gt;17 . Index should not be used as a key&lt;/p&gt;

&lt;p&gt;18 . Short-Circuit evaluation should be used in jsx&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="c1"&gt;// Avoid&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;sampleComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&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;isTrue&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;True&lt;/span&gt;&lt;span class="o"&gt;!&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&amp;gt; : nul&lt;/span&gt;&lt;span class="err"&gt;l
&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// Recommended: short-circuit evaluation&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;sampleComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&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;isTrue&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;True&lt;/span&gt;&lt;span class="o"&gt;!&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Would love to hear from you guys if you could add up practices in my above list.&lt;br&gt;
Comment down below 👇&lt;/p&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>webpack</category>
    </item>
    <item>
      <title>Just Enough CSS for Developers to Know!</title>
      <dc:creator>Aditya Sharan</dc:creator>
      <pubDate>Tue, 16 Mar 2021 20:30:32 +0000</pubDate>
      <link>https://forem.com/adityasharan01/just-enough-css-for-developers-to-know-e0a</link>
      <guid>https://forem.com/adityasharan01/just-enough-css-for-developers-to-know-e0a</guid>
      <description>&lt;h1&gt;
  
  
  How CSS works ?
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Selectors:&lt;/strong&gt;&lt;br&gt;
CSS Selectors define the elements to which a set of CSS rules apply.&lt;br&gt;
&lt;strong&gt;Specificity:&lt;/strong&gt;&lt;br&gt;
Specificity is the means by which browsers decide which CSS property values are the most relevant to an element.&lt;br&gt;
&lt;strong&gt;Cascade:&lt;/strong&gt;&lt;br&gt;
The cascade is an algorithm that defines how to combine property values originating from different sources.&lt;/p&gt;

&lt;h1&gt;
  
  
  How to render an element?
&lt;/h1&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwlk2oyg1zg4b5u75d1tq.PNG" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwlk2oyg1zg4b5u75d1tq.PNG" alt="Alt Text" width="493" height="332"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  How to render where I want ?
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Postioning&lt;/strong&gt;: The position CSS property sets how an element is positioned in a document.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Float:&lt;/strong&gt; The float CSS property places an element on the left or right side of its container, allowing text and inline elements to wrap around it.&lt;/p&gt;

&lt;h1&gt;
  
  
  How to render the entire row of elements?
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Flex:&lt;/strong&gt;&lt;br&gt;
The flex CSS shorthand property sets how a flex item will grow or shrink to fit the space available in its flex container.&lt;/p&gt;

&lt;h1&gt;
  
  
  How to render the entire page as I wish?
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Grid:&lt;/strong&gt;&lt;br&gt;
The grid CSS property is a shorthand property that sets all of the explicit and implicit grid properties in a single declaration.&lt;br&gt;
&lt;strong&gt;Layout:&lt;/strong&gt;&lt;br&gt;
A CSS Layout mode,sometimes simply called layout, is a algorithm that determines the position and size of the boxes based on the way they interact with their sibling and ancestor boxes.&lt;/p&gt;

&lt;h1&gt;
  
  
  How to layout on different screen size ?
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Media Queires:&lt;/strong&gt;&lt;br&gt;
Media queries let the presentation of content be tailored to a specific range of output devices without having to change the content itself.&lt;br&gt;
&lt;strong&gt;Responsive Design:&lt;/strong&gt;&lt;br&gt;
Responsive Design is a team used to describe an approach to web design or a set of best practices,used to create a layout that can respond to the device being used to view the content.&lt;/p&gt;

&lt;h1&gt;
  
  
  How to make it Beautiful?
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Font&lt;/li&gt;
&lt;li&gt;Colours&lt;/li&gt;
&lt;li&gt;Gradients&lt;/li&gt;
&lt;li&gt;Backgrounds&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  How to make it more interesting?
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Animations&lt;/li&gt;
&lt;li&gt;Transitions&lt;/li&gt;
&lt;li&gt;Transform&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  How to make Dev faster and Organised?
&lt;/h1&gt;

&lt;p&gt;Using CSS Pre-processor:&lt;br&gt;
Sass Less,Post CSS or any pre-processor.&lt;/p&gt;

&lt;h1&gt;
  
  
  How to ease Teamwork and Seperation?
&lt;/h1&gt;

&lt;p&gt;BEM(Block Element Modifier):&lt;br&gt;
The BEM methodoogy is a popular naming convention for classes in HTML and CSS.It's goal is to help developers better understand the relationship between the HTML and CSS in a given project.&lt;/p&gt;

&lt;p&gt;That was it for this little article. I got to learn so much from this. And I hope you also find this useful. Thank u so much! 😀&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>showdev</category>
    </item>
    <item>
      <title>[DON'T STAY BEHIND]Study these topics to see yourself becoming a confident Web devloper</title>
      <dc:creator>Aditya Sharan</dc:creator>
      <pubDate>Tue, 16 Mar 2021 18:05:14 +0000</pubDate>
      <link>https://forem.com/adityasharan01/don-t-stay-behind-study-these-topics-to-see-yourself-becoming-a-confident-web-devloper-26gb</link>
      <guid>https://forem.com/adityasharan01/don-t-stay-behind-study-these-topics-to-see-yourself-becoming-a-confident-web-devloper-26gb</guid>
      <description>&lt;p&gt;Note:This is not a roadmap.It's just a list of topics which i feel people tend to forget after studying web development.So here are some topics which could read and refresh them on the weekend.&lt;/p&gt;

&lt;h2&gt;
  
  
  MUST know Browser Concepts:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;History&lt;/li&gt;
&lt;li&gt;Document&lt;/li&gt;
&lt;li&gt;Location&lt;/li&gt;
&lt;li&gt;Navigation&lt;/li&gt;
&lt;li&gt;pageXOffset&lt;/li&gt;
&lt;li&gt;Screen&lt;/li&gt;
&lt;li&gt;Alert&lt;/li&gt;
&lt;li&gt;Print&lt;/li&gt;
&lt;li&gt;resizeBy and resizeTo&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  MUST know HTML Concepts:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Attributes&lt;/li&gt;
&lt;li&gt;Base URI&lt;/li&gt;
&lt;li&gt;nth-child&lt;/li&gt;
&lt;li&gt;siblings&lt;/li&gt;
&lt;li&gt;appending child&lt;/li&gt;
&lt;li&gt;insert before and after&lt;/li&gt;
&lt;li&gt;remove child&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  MUST know Javascript Concepts:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;mouseover Vs mouseenter&lt;/li&gt;
&lt;li&gt;keydown Vs keypress Vs keyup&lt;/li&gt;
&lt;li&gt;double click&lt;/li&gt;
&lt;li&gt;right click&lt;/li&gt;
&lt;li&gt;debounce&lt;/li&gt;
&lt;li&gt;throttle&lt;/li&gt;
&lt;li&gt;prototypal inheritance&lt;/li&gt;
&lt;li&gt;focus vs blur&lt;/li&gt;
&lt;li&gt;drag and drop&lt;/li&gt;
&lt;li&gt;try-catch-throw-finally&lt;/li&gt;
&lt;li&gt;error types&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  MUST know TypeScript Concepts:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Class Inheritance&lt;/li&gt;
&lt;li&gt;Interfaces&lt;/li&gt;
&lt;li&gt;Enums&lt;/li&gt;
&lt;li&gt;Type Assertions&lt;/li&gt;
&lt;li&gt;Generics&lt;/li&gt;
&lt;li&gt;Intersection Types &lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;You can google out the topics mentioned above and get the resouces to read and watch.All the best &lt;br&gt;
Happy Learning!!&lt;br&gt;
Would be glad to know about the topics that you think should get added onto any of these list.&lt;br&gt;
Comment down below 👇 &lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>webdev</category>
      <category>html</category>
      <category>css</category>
      <category>javascript</category>
    </item>
    <item>
      <title>SQL tips that will make you productive from day1 at your job.</title>
      <dc:creator>Aditya Sharan</dc:creator>
      <pubDate>Tue, 16 Mar 2021 17:43:41 +0000</pubDate>
      <link>https://forem.com/adityasharan01/sql-tips-that-will-make-you-productive-from-day1-at-your-job-lpb</link>
      <guid>https://forem.com/adityasharan01/sql-tips-that-will-make-you-productive-from-day1-at-your-job-lpb</guid>
      <description>&lt;p&gt;In this post,I'm going to write the SQL skills which i feel usually required in the day to day responsiblities of a developer.&lt;/p&gt;

&lt;h3&gt;
  
  
  Topic1: Window Functions
&lt;/h3&gt;

&lt;h3&gt;
  
  
  Topic2: CTE and WTH
&lt;/h3&gt;

&lt;h3&gt;
  
  
  Topic3: Query Optimization
&lt;/h3&gt;

&lt;h3&gt;
  
  
  Topic4: Organized, Clean Syntax
&lt;/h3&gt;

&lt;h3&gt;
  
  
  Topic5: User Defined Functions
&lt;/h3&gt;

&lt;p&gt;But for the interview prep specifically you may not need the above 5 but you should have these ready:&lt;/p&gt;

&lt;h3&gt;
  
  
  1.) COALESCE and CASE WHEN
&lt;/h3&gt;

&lt;h3&gt;
  
  
  2.) Subqueries
&lt;/h3&gt;

&lt;h3&gt;
  
  
  3.)COUNT DISTINCT
&lt;/h3&gt;

&lt;h3&gt;
  
  
  4.)Self Joins
&lt;/h3&gt;

&lt;h3&gt;
  
  
  5.)Different join types
&lt;/h3&gt;

&lt;h2&gt;
  
  
  Here is a Bonus tip for you:
&lt;/h2&gt;

&lt;p&gt;There are lot of keywords in SQL but do you know they follow up an order of precendence.&lt;/p&gt;

&lt;h2&gt;
  
  
  From &amp;gt;Join&amp;gt; Where &amp;gt; Group By&amp;gt; Having&amp;gt; Select&amp;gt; Order By&amp;gt; Limit
&lt;/h2&gt;

&lt;p&gt;Happy SQL Learning !&lt;/p&gt;

</description>
      <category>sql</category>
      <category>database</category>
      <category>devops</category>
      <category>devjournal</category>
    </item>
    <item>
      <title>Personalised GIT CheatSheet(For Specific Situations)</title>
      <dc:creator>Aditya Sharan</dc:creator>
      <pubDate>Tue, 16 Mar 2021 17:03:42 +0000</pubDate>
      <link>https://forem.com/adityasharan01/personalised-git-cheatsheet-for-specific-situations-224j</link>
      <guid>https://forem.com/adityasharan01/personalised-git-cheatsheet-for-specific-situations-224j</guid>
      <description>&lt;p&gt;In this post,I have considered all the common situations which i have come across while working as developer, curated all the commands and listed down according to the situation.&lt;br&gt;
With more than 160 commands available, becoming a git expert takes time. But everyone has a few commands that they use frequently. In this post I’ll share mine.&lt;/p&gt;

&lt;h1&gt;
  
  
  SITUATION 1:I want a clean working directory, but I don’t want to lose my current changes.
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# save the current state of the working directory 
git stash

# apply the latest stashed change to your current working tree
git stash pop

# list stashed changes
git stash list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  SITUATION 2: I messed up my last commit message.
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# change the latest commit's message 
git commit --amend -m "Fixed message"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  SITUATION 3: I accidentally pushed a file. Now I want to remove it from the remote branch (but not from my local branch).
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git rm --cached &amp;lt;file-path&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  SITUATION 4: I made a bunch of changes to a file but I regret it 😱. I want to go back to the main branch version.
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout main &amp;lt;file-path&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  SITUATION 5: I want to take a commit from one branch and apply it onto mine.
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git cherry-pick &amp;lt;commit-hash&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  SITUATION 6: I want my branch to be based off the most recent commit of the main branch.
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# 1. Get the latest version of the main branch 
git checkout main
git pull origin

# 2. Checkout your branch
git checkout &amp;lt;my-branch&amp;gt;

# 3. Replay your changes on top of the main branch
git rebase main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  SITUATION 7:I merged my branch into main but I want to rollback the merge
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# 1. Checkout a new branch from the main branch
git checkout -b mybranch-rollback

# 2. Find out the commit hash that merged your branch to develop.
git log 

# 3. Revert the merge commit
git revert -m 1 &amp;lt;commit-hash&amp;gt;

# 4. Push the changes to your new branch
git push origin mybranch-rollback

# 5. Open a pull request to main for your new branch

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

&lt;/div&gt;



&lt;p&gt;If you liked it, follow me on &lt;a href="https://github.com/adityasharan01" rel="noopener noreferrer"&gt;github&lt;/a&gt;&lt;br&gt;
Would love to hear from you which commands you use daily so that i get to learn all those as well.&lt;br&gt;
Comment down below 👇&lt;/p&gt;

</description>
      <category>github</category>
      <category>cheatsheet</category>
      <category>techblogs</category>
      <category>devops</category>
    </item>
    <item>
      <title>A thing to keep in mind when using fetch() [API Call]</title>
      <dc:creator>Aditya Sharan</dc:creator>
      <pubDate>Sat, 13 Mar 2021 18:16:35 +0000</pubDate>
      <link>https://forem.com/adityasharan01/a-thing-to-keep-in-mind-when-using-fetch-api-call-1od6</link>
      <guid>https://forem.com/adityasharan01/a-thing-to-keep-in-mind-when-using-fetch-api-call-1od6</guid>
      <description>&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm4t3eyay44enhf10knnr.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm4t3eyay44enhf10knnr.JPG" alt="Alt Text" width="550" height="177"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Take a look at the below code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fetch('https://jsonplaceholder.typicode.com/todos/4')
        .then(response =&amp;gt; response.json())
            .then(result =&amp;gt; console.log('success:',result))
                .catch(error =&amp;gt; console.log('error:', error));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, we’re making an &lt;strong&gt;API&lt;/strong&gt; call to get a todo with id 4 and it will work&lt;br&gt;
because there is a todo with id 4 But what If the id does not exist or the&lt;br&gt;
server throws an error like 404 or 500 or any other error?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fetch('https://jsonplaceholder.typicode.com/todos/2382822')
        .then(response =&amp;gt; response.json())
            .then(result =&amp;gt; console.log('success:',result))
                .catch(error =&amp;gt; console.log('error:', error));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, we have provided a very large id that does not exist. But if you&lt;br&gt;
execute in the browser console, you will see that a success message is&lt;br&gt;
printed even though it’s clearly a 404 error.&lt;br&gt;
Ideally, the .catch handler should be executed but that does not&lt;br&gt;
happen in the case of fetch .&lt;br&gt;
fetch only goes into .catch handler when it fails to make the&lt;br&gt;
request for example when the network is not available or the domain&lt;br&gt;
does not exist.&lt;/p&gt;

&lt;p&gt;So If you’re using fetch for performing CRUD (create, read, update,&lt;br&gt;
delete) operation and the id do not exist then you will get an error.&lt;br&gt;
If you’re using fetch then you have to write a lot of extra code for&lt;br&gt;
handling every HTTP status code error which is cumbersome.&lt;br&gt;
So If you’re building a large scale application or you don’t want to&lt;br&gt;
handle all HTTP status code errors, then use axios or superagent or&lt;br&gt;
any other library instead of fetch .&lt;br&gt;
Because in all of those libraries catch will be executed when there is&lt;br&gt;
any type of error that is easy to handle rather than writing code for&lt;br&gt;
every status code.&lt;br&gt;
This is the reason, you will find code for fetch written like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fetch('https://jsonplaceholder.typicode.com/todos/4')
                .then((response) =&amp;gt; {
                   if (response.ok) {
                     return response.json();
                   }
                    return Promise.reject(response);
                })
                .then((result) =&amp;gt; {
                    console.log(result);
                })
                .catch((error) =&amp;gt; {
                    console.log('Something went wrong.', error);
                });

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

&lt;/div&gt;



&lt;p&gt;where inside the .then handler, we’re checking if the response is ok .&lt;br&gt;
If the response is &lt;strong&gt;OK&lt;/strong&gt; , we’re calling &lt;strong&gt;response.json()&lt;/strong&gt; method which&lt;br&gt;
will send the result to the next .then handler.&lt;br&gt;
If the response is &lt;strong&gt;NOT OK&lt;/strong&gt;, then we’re &lt;strong&gt;rejecting the promise&lt;/strong&gt; so it will&lt;br&gt;
call the &lt;strong&gt;.catch()&lt;/strong&gt; handler to print the actual error.&lt;/p&gt;

&lt;p&gt;I hope this article help you to understand something or improve yourself ! If you have any question ask me in comment !&lt;br&gt;
Would be &lt;strong&gt;Happy to HELP&lt;/strong&gt;! 😊&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>JSX and Rendering elements</title>
      <dc:creator>Aditya Sharan</dc:creator>
      <pubDate>Tue, 14 Jul 2020 21:36:32 +0000</pubDate>
      <link>https://forem.com/adityasharan01/jsx-and-rendering-elements-e95</link>
      <guid>https://forem.com/adityasharan01/jsx-and-rendering-elements-e95</guid>
      <description>&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fsz7wmhpngb0o9mlrpcct.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fsz7wmhpngb0o9mlrpcct.JPG" alt="Alt Text" width="473" height="101"&gt;&lt;/a&gt;&lt;br&gt;
This is neither a string nor HTML,it's JSX.&lt;/p&gt;

&lt;p&gt;JSX or Javascript XML, is an XML/HTML-like syntax used by react that extends ECMAScript(ES) so that XML/HTML-like-text can co-exist with Javascript/React code.&lt;/p&gt;




&lt;p&gt;Since JSX is closer to Javascript than to HTML,ReactDOM uses camelCase property naming convention instead of HTML attribute names.&lt;br&gt;
For eg :&lt;br&gt;
class becomes className&lt;br&gt;
tabindex becomes tabIndex&lt;/p&gt;




&lt;h5&gt;
  
  
  Let's say there is a  somewhere in your HTML file :


&lt;/h5&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ff3fyw0yst2f9aipmqopk.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ff3fyw0yst2f9aipmqopk.JPG" alt="Alt Text" width="341" height="113"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h6&gt;
  
  
  # This is the 'root' DOM node because everything inside it will be managed by ReactDOM.
&lt;/h6&gt;

&lt;p&gt;To &lt;strong&gt;render&lt;/strong&gt; a &lt;strong&gt;React element&lt;/strong&gt; into a root DOM node, pass both to ReactDOM.render() :&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fq4k8xl6tp3oyufga2f4b.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fq4k8xl6tp3oyufga2f4b.JPG" alt="Alt Text" width="622" height="127"&gt;&lt;/a&gt;&lt;br&gt;
Running you react app after this will give the following output :&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ft27peelhzsxosbvvwxd7.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ft27peelhzsxosbvvwxd7.JPG" alt="Alt Text" width="356" height="215"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's all folks.&lt;br&gt;
Thanks for reading!&lt;/p&gt;


</description>
      <category>javascript</category>
      <category>render</category>
      <category>react</category>
      <category>elements</category>
    </item>
  </channel>
</rss>
