<?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: Maulik Thaker</title>
    <description>The latest articles on Forem by Maulik Thaker (@mak0099).</description>
    <link>https://forem.com/mak0099</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%2F151751%2F15a8ca60-4895-4c2f-83c8-31f4602fc97d.png</url>
      <title>Forem: Maulik Thaker</title>
      <link>https://forem.com/mak0099</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/mak0099"/>
    <language>en</language>
    <item>
      <title>[Boost]</title>
      <dc:creator>Maulik Thaker</dc:creator>
      <pubDate>Thu, 02 Oct 2025 13:25:20 +0000</pubDate>
      <link>https://forem.com/mak0099/-11gc</link>
      <guid>https://forem.com/mak0099/-11gc</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/sachagreif/whats-new-in-the-2025-state-of-javascript-survey-17ii" class="crayons-story__hidden-navigation-link"&gt;What's new in the 2025 State of JavaScript survey&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/sachagreif" class="crayons-avatar  crayons-avatar--l  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1441%2Fj8ehsrukq7v6bh6tswfc.png" alt="sachagreif profile" class="crayons-avatar__image"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/sachagreif" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Sacha Greif
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Sacha Greif
                
              
              &lt;div id="story-author-preview-content-2867019" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/sachagreif" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1441%2Fj8ehsrukq7v6bh6tswfc.png" class="crayons-avatar__image" alt=""&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Sacha Greif&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/sachagreif/whats-new-in-the-2025-state-of-javascript-survey-17ii" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Oct 1 '25&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/sachagreif/whats-new-in-the-2025-state-of-javascript-survey-17ii" id="article-link-2867019"&gt;
          What's new in the 2025 State of JavaScript survey
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/surveys"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;surveys&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/javascript"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;javascript&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/typescript"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;typescript&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/sachagreif/whats-new-in-the-2025-state-of-javascript-survey-17ii" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/raised-hands-74b2099fd66a39f2d7eed9305ee0f4553df0eb7b4f11b01b6b1b499973048fe5.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/multi-unicorn-b44d6f8c23cdd00964192bedc38af3e82463978aa611b4365bd33a0f1f4f3e97.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;31&lt;span class="hidden s:inline"&gt; reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/sachagreif/whats-new-in-the-2025-state-of-javascript-survey-17ii#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              Comments


              3&lt;span class="hidden s:inline"&gt; comments&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            3 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
      <category>surveys</category>
      <category>javascript</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Prevent Click-Jacking in your web applications</title>
      <dc:creator>Maulik Thaker</dc:creator>
      <pubDate>Tue, 13 Apr 2021 11:14:34 +0000</pubDate>
      <link>https://forem.com/mak0099/prevent-click-jacking-in-your-web-applications-139g</link>
      <guid>https://forem.com/mak0099/prevent-click-jacking-in-your-web-applications-139g</guid>
      <description>&lt;p&gt;Today we gonna lookout the click jacking also known as UI redressing and how we can prevent that in our web applications or website. &lt;/p&gt;

&lt;h3&gt;
  
  
  What is Click-jacking?
&lt;/h3&gt;

&lt;p&gt;Clickjacking is an attack that tricks a user into clicking a webpage element which is invisible or disguised as another element. This can cause users to unwittingly download malware, visit malicious web pages, provide credentials or sensitive information, transfer money, or purchase products online.&lt;/p&gt;

&lt;p&gt;For example, if you have your application which contains login and sign-up kind of forms then it might be a chance to getting under attack of click jacking where a fake UI layer is attached through an &lt;code&gt;&amp;lt;iframe src=""&amp;gt;&lt;/code&gt; tag and embedded into the top of your site.&lt;/p&gt;

&lt;p&gt;Consider the example below:&lt;/p&gt;

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

&amp;lt;!doctype html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
  &amp;lt;meta charset="utf-8"&amp;gt;
  &amp;lt;title&amp;gt;Click jacking&amp;lt;/title&amp;gt;
  &amp;lt;style&amp;gt;
    .toplayer{
       position: relative;
       width:100%;
       z-index:1; 
     } 
     #topmostlayer{
       position: absolute;
       z-index: 9999;
       opacity: 0.0001;
       top: 50%; 
       left: 50% // can be adjusted according to your login button UI placements
     }
  &amp;lt;/style&amp;gt;

&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
  &amp;lt;form &amp;gt;
    &amp;lt;input type="text" placeholder="Enter username"&amp;gt; 
    &amp;lt;input type="password" placeholder="Enter password"&amp;gt;
  &amp;lt;button class="toplayer btn btn-login"&amp;gt;Login&amp;lt;/button&amp;gt;
  &amp;lt;/form&amp;gt;
  &amp;lt;a id="topmostlayer" role="button"&amp;gt; Click here 
   &amp;lt;iframe  src="https://anonymous-web.com"&amp;gt;&amp;lt;/iframe&amp;gt;
  &amp;lt;/a&amp;gt;

&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;


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

&lt;/div&gt;

&lt;p&gt;In above code, we can see that the login form is there at topmost UI level so whenever URL loads the login page, in DOM tree UI of login is placed at top layer. &lt;/p&gt;

&lt;p&gt;Now, What is interesting here is you can do DOM manipulation using our well-known css property of &lt;code&gt;z-index&lt;/code&gt; along with &lt;code&gt;&amp;lt;iframe&amp;gt;&lt;/code&gt; tag embedded inside &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; tag.&lt;/p&gt;

&lt;p&gt;Here css class named &lt;code&gt;.toplayer&lt;/code&gt; is added to Login button and the z-index of this class can be set to 1 or bydefault. So, whenever &lt;code&gt;&amp;lt;iframe src="https://anonymous-web.com"&amp;gt;&lt;/code&gt; is came into DOM along with id of &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; tag named &lt;code&gt;#topmostlayer&lt;/code&gt; attackers identify your button position in DOM and create exact same replica or placed the position of buttton named "click here" as such that button is overlapped into login button. &lt;/p&gt;

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

  #topmostlayer{
       position: absolute;
       z-index: 9999;
       opacity: 0.0001;
       top: 50%; 
       left: 50% // can be adjusted according to your login button UI placements
     }


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

&lt;/div&gt;

&lt;p&gt;Observe that button "Click here" id styles. You can see that &lt;code&gt;z-index: 9999;&lt;/code&gt; forces the UI to be on top layer on login button also css propery &lt;code&gt;opacity:0.0001;&lt;/code&gt; hides that UI so that you are not aware of any UI is present in your existing DOM level. Such attacks called as &lt;strong&gt;UI redressing&lt;/strong&gt;.&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%2Fs838aiqt7hwl0xzqklbn.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%2Fs838aiqt7hwl0xzqklbn.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Check Click-jacking vulnerability
&lt;/h3&gt;

&lt;p&gt;There are many online tools by which you can check whether our deployed URL can be embedded into another URL or not. Examples are &lt;a href="https://clickjacker.io/" rel="noopener noreferrer"&gt;Clickjacker&lt;/a&gt;, &lt;a href="https://www.lookout.net/test/clickjack.html" rel="noopener noreferrer"&gt;Lookout&lt;/a&gt;, &lt;a href="https://gf.dev/x-frame-options-test" rel="noopener noreferrer"&gt;gf-dev&lt;/a&gt;. I preferred "Clickjacker" because there you can test your deployed URL and it gives you a POC and identify the &lt;code&gt;X-frame-options, CSP headers, Raw Http headers&lt;/code&gt; information about your URL. If &lt;code&gt;X-frame-option&lt;/code&gt; is "sameorigin" then it indicates your URL is safe.&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%2F5maq5spzfpncnnmc2kch.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%2F5maq5spzfpncnnmc2kch.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;below is screenshot of Raw Http headers in case of there is chances of attacks.&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%2F5hgmel47w03qxhqzj99z.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%2F5hgmel47w03qxhqzj99z.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How to prevent Click-jacking?
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. Frame Busting
&lt;/h4&gt;

&lt;p&gt;Simple task is to avoid UI overlapping or DOM manipulation by &lt;code&gt;&amp;lt;iframe&amp;gt;&lt;/code&gt; tag. At frontend side, when page loads at that time we can check whether any UI layer inserted into top of the HTML of &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; tag or not by adding below code.&lt;/p&gt;

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

&amp;lt;style&amp;gt;
/* Hide page by default */
html { display : none; }
&amp;lt;/style&amp;gt;
&amp;lt;script&amp;gt;
if (self == top) {
// Everything checks out, show the page.
document.documentElement.style.display = 'block';
} else {
// Break out of the frame.
top.location = self.location;
}
&amp;lt;/script&amp;gt; 


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

&lt;/div&gt;

&lt;p&gt;Above technique called &lt;strong&gt;Frame busting&lt;/strong&gt;. JavaScript that runs on user’s browser is used to stop itself being embeded into iframe and escape out of it. When the page loads, this JS code will check if the domain of the page matches the domain of the browser window. If it does then no problem, if it does not then it will escape out of the iframe and load the site in the browser by replacing the site trying to load it in the Iframe. &lt;/p&gt;

&lt;h4&gt;
  
  
  2. X-Frame Options &amp;amp; Content-Security-Policy
&lt;/h4&gt;

&lt;p&gt;At server side we can set X-Frame-Options is a response header. Developers can use it to protect their site against clickjacking. It can be used to indicate whether or not a browser should be allowed to render a page in an Iframe by have its value set as any of the following:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 DENY

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

&lt;/div&gt;

&lt;p&gt;By specifying DENY, no site will be allowed to load the page in a frame.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 SAMEORIGIN

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

&lt;/div&gt;

&lt;p&gt;On the other hand, if you specify SAMEORIGIN, you can still use the page in a frame as long as the site including it in a frame is the same as the one serving the page.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 ALLOW-FROM uri

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

&lt;/div&gt;

&lt;p&gt;If you specify this, then the site can be displayed in a frame only by uri specified. However, this is an obsolete directive that no longer works in modern browsers.  &lt;/p&gt;

&lt;p&gt;The HTTP Content-Security-Policy response header allows web site administrators to control resources the user agent is allowed to load for a given page. It is used for a vast number of security vulnerabilities other than clickjacking such as XSS. However our guide will be focussed on its use in protection against clickjacking only. The HTTP Content-Security-Policy (CSP) frame-ancestors directive specifies valid parents that may embed a page using an Iframe. It can be used to indicate whether or not a browser should be allowed to render a page in an Iframe by have its value set as any of the following:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 'none'

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

&lt;/div&gt;

&lt;p&gt;By specifying ‘none’, no site will be allowed to load the page in a frame.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 'self'

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

&lt;/div&gt;

&lt;p&gt;On the other hand, if you specify ‘self’, you can still use the page in a frame as long as the site including it in a frame is the same as the one serving the page.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 frame-ancestors uri

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

&lt;/div&gt;

&lt;p&gt;If you specify this, then the site can be displayed in a frame only by uri specified. For example: If you implement the below header directive, then your site will be allowed to be iframed only by the specified url.&lt;/p&gt;

</description>
      <category>security</category>
      <category>webdev</category>
    </item>
    <item>
      <title>ES2021 new features</title>
      <dc:creator>Maulik Thaker</dc:creator>
      <pubDate>Mon, 01 Mar 2021 13:54:11 +0000</pubDate>
      <link>https://forem.com/mak0099/es2021-new-features-3b0k</link>
      <guid>https://forem.com/mak0099/es2021-new-features-3b0k</guid>
      <description>&lt;p&gt;ES2021 is the version of ECMAScript corresponding to the year 2021. Some features they've added into this version which is very much interesting. &lt;/p&gt;

&lt;p&gt;The new JavaScript features in ES2021 are:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A. String.prototype.replaceAll()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A new &lt;code&gt;replaceAll()&lt;/code&gt; method has been added to the String prototype. See below example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const str = "Apple is good for health. You should consume
Apple daily."
const strReplace = str.replaceAll("Apple", "Banana");
console.log(strReplace); // Banana is good for health. You should consume Banana daily.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;B. Private methods &amp;amp; Private Accessors&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We can restrict the method being called outside of the class by generating private methods.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Class Person{

 #showTypeMethod(){
    console.log("This is a type");
 }

 showHelloMethod(){
    console.log("Hello World");
 } 

}

const person = new Person();
person.showHelloMethod(); // Hello World
person.showTypeMethod(); // Error: person.showTypeMethod is not a function
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, you can make your &lt;code&gt;showTypeMethod()&lt;/code&gt; private by putting &lt;code&gt;#&lt;/code&gt; before function name. So now our &lt;code&gt;#showTypeMethod()&lt;/code&gt; is private to our class only. If you try to access this method outside of person class then it will cause an error.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C. Promise.any&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Promise.any gives you a signal as soon as one of the promises fulfills. This is similar to Promise.race, except Promise.any doesn’t reject early when one of the promises rejects.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const myFetch = url =&amp;gt; setTimeout(() =&amp;gt; fetch(url), Math.floor(Math.random() * 3000));
const promises = [
  myFetch('/endpoint-1'),
  myFetch('/endpoint-2'),
  myFetch('/endpoint-3'),
];

// Using .then .catch
Promise.any(promises) // Any of the promises was fulfilled.
       .then(console.log) // e.g. '3'
       .catch(console.error); //All of the promises were rejected.

// Using async-await
try {
  const first = await Promise.any(promises); // Any of the promises was fulfilled.
 console.log(first);
}catch (error) { // All of the promises were rejected
  console.log(error);
}

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;D. Logical Assignment Operators&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Assignment operators are used widely in JavaScript to compare and conditionally checked numbers, arguments etc. Normally we write the if condition as below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let x = 1;
let y = 2;
if(x){
  x = y;
}
console.log(x); 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But using assignment operator we can shorthand the if condition like below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let x = 1;
let y = 2;
x&amp;amp;&amp;amp;=y;
console.log(x);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;E. WeakRef &amp;amp; Finalizer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Main use of weak references is to implement caches or mappings to large objects. In many scenarios, we don't want to keep a lot of memory for a long time saving this rarely used cache or mappings. We can allow the memory to be garbage collected soon and later if we need it again, we can generate a fresh cache. If variable is no longer reachable, JavaScript garbage collector automatically removes it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const callback = () =&amp;gt; {
  const aBigObj = {
    name: "Hello world"
  };
  console.log(aBigObj);
}

(async function(){
  await new Promise((resolve) =&amp;gt; {
    setTimeout(() =&amp;gt; {
      callback();
      resolve();
    }, 2000);
  });
})();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When executing above code, it prints "Hello world" after 2 seconds. Based on how we use the &lt;code&gt;callback()&lt;/code&gt; function, &lt;code&gt;aBigObj&lt;/code&gt; is stored in memory forever, may be.&lt;/p&gt;

&lt;p&gt;Let us make &lt;code&gt;aBigObj&lt;/code&gt; a weak reference.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const callback = () =&amp;gt; {
  const aBigObj = new WeakRef({    name: "Hello world"  });  console.log(aBigObj.deref().name);}

(async function(){
  await new Promise((resolve) =&amp;gt; {
    setTimeout(() =&amp;gt; {
      callback(); // Guaranteed to print "Hello world"
      resolve();
    }, 2000);
  });

  await new Promise((resolve) =&amp;gt; {
    setTimeout(() =&amp;gt; {
      callback(); // No Gaurantee that "Hello world" is printed
      resolve();
    }, 5000);
  });
})();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first &lt;code&gt;setTimeout()&lt;/code&gt; will surely print the value of name. That is guaranteed in the first turn of event loop after creating the weak reference.&lt;/p&gt;

&lt;p&gt;But there is no guarantee that the second &lt;code&gt;setTimeout()&lt;/code&gt; prints "Backbencher". It might have been sweeped by the gargage collector. Since the garbage collection works differently in different browsers, we cannot guarantee the output. That is also why, we use &lt;code&gt;WeakRef&lt;/code&gt; in situations like managing cache.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;FinalizationRegistry&lt;/code&gt; is a feature of WeakRef which lets programmers register callbacks to be invoked after an object is garbage collected.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const registry = new FinalizationRegistry((value) =&amp;gt; {
  console.log(value);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here registry is an instance of &lt;code&gt;FinalizationRegistry&lt;/code&gt;. The callback function passed to &lt;code&gt;FinalizationRegistry&lt;/code&gt; gets triggered when an object is garbage collected.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(function () {
  const obj = {};
  registry.register(obj, "Hello World");
})();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When obj is garbage collected, the second argument of &lt;code&gt;.register()&lt;/code&gt; method is passed to the callback function. So, according to our code logic, when obj is garbage collected, "Hello World" is passed to the callback function and is printed in the console.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;F. Numeric Seperators&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let x = 1000000; // Not in human readable format right?
console.log(x); 

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

&lt;/div&gt;



&lt;p&gt;Using Regular Number Literals:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let x = 1_000_000;
console.log(x); // 1000000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For more information, you can visit &lt;a href="https://github.com/tc39/proposal-numeric-separator"&gt;this link.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There may be many features that changed or added into ES12 but above is most common one where there are mostly useful and effective.&lt;/p&gt;

</description>
      <category>ecmascript</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>My Steps of Online Learning</title>
      <dc:creator>Maulik Thaker</dc:creator>
      <pubDate>Mon, 01 Feb 2021 07:39:46 +0000</pubDate>
      <link>https://forem.com/mak0099/my-steps-of-online-learning-28a</link>
      <guid>https://forem.com/mak0099/my-steps-of-online-learning-28a</guid>
      <description>&lt;p&gt;There are many ways to enhance or learn new skills that takes you to the next levels. But nowadays, most people are used to learn online (i.e. through web) because it's easy way to update yourself rather than any dependencies on anything. Web surfing is a great way to learning any specific skill to update yourself.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem during web surfing&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Many times people are distracted themselves while finding any particular about any specific topic as we all know that its a huge ocean of WWW (World Wide Web) and we can get these kind of difficulties very often.  &lt;/p&gt;

&lt;p&gt;Let me tell you my experience about the same. Whenever I am trying to learn any new thing through online, I often distracted when many options or solutions are available, I got difficulties what to choose OR what will be my best answers. So, I defined some steps according to my roadmap. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step-1 : Dedication towards your goal&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;First-most thing is to decide what you needs to learn from upcoming days, months or years and stick into it. Because if you are creating the roadmap of your upcoming skills than its most important part to search about only specific what you intend to achieve. Goal should not be changed once you defined it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step-2 : Define the path and platform&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once you decide your goal then many solutions are available to serve you the best. Suppose I am trying to learn my IT related skills let's say JavaScript. So there are many web sites or courses that teach me JS but I need to think whether I will go for websites or to join any specific course according to my feasibility. May be I can go for intro by some of the websites then jump to the course or will find such course which provides me the intro as well as full brief about the JS. This can be vary person to person. But once I defined my way then again its a question about which course should I joined or which website should I prefer ?&lt;br&gt;
To answer this question, I will check some official websites and courses and choose one of them and defined my learning path.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step-3 : Prove your skills&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now, best thing is to apply your learnings practically. Keep in mind that &lt;code&gt;"Theories will remain theories unless you prove it practically"&lt;/code&gt;. Each and every learning, you need to prove your knowledge by apply it into some practical way. Consistently, you need to put your skills in more and more practical way. Keep practicing and learn from your mistakes is the best part to motivate yourself. You need to challenge yourself about what you've learned and keep updated about that skill. &lt;/p&gt;

&lt;p&gt;So, Guys above are the core steps according to me while dealing with online learning. You need to enhance these steps and divide according to your feasibility and suitability to your skills. Hope you like this blog. Thank you be safe and have a nice day.        &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Divide Bootstrap Grid into an odd columns</title>
      <dc:creator>Maulik Thaker</dc:creator>
      <pubDate>Tue, 15 Sep 2020 12:49:51 +0000</pubDate>
      <link>https://forem.com/mak0099/divide-bootstrap-grid-into-an-odd-columns-5geo</link>
      <guid>https://forem.com/mak0099/divide-bootstrap-grid-into-an-odd-columns-5geo</guid>
      <description>&lt;p&gt;Hello friends. Today I am covering very small topic about how to divide row into odd columns as many of you are requested me earlier. So lets's get started.&lt;/p&gt;

&lt;p&gt;So, If you are not familiar with Bootstrap grid, Please refer &lt;a href="https://getbootstrap.com/docs/4.1/layout/grid/"&gt;this link&lt;/a&gt; to understand bootstrap grid system.&lt;/p&gt;

&lt;p&gt;As we all know bootstrap row is divided into 12 columns maximum and each column has an equal width. We can easily divide our columns into an even number like below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;div class="row"&amp;gt; &amp;lt;!-- Total width 100% --&amp;gt;
    &amp;lt;div class="col-lg-3"&amp;gt;
     &amp;lt;!-- Width of this column will be 25% --&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="col-lg-3"&amp;gt;
     &amp;lt;!-- Width of this column will be 25% --&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="col-lg-3"&amp;gt;
     &amp;lt;!-- Width of this column will be 25% --&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="col-lg-3"&amp;gt;
     &amp;lt;!-- Width of this column will be 25% --&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt; 

&amp;lt;!-- OR ---&amp;gt;

&amp;lt;div class="row"&amp;gt;
    &amp;lt;div class="col-lg-4"&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="col-lg-4"&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="col-lg-4"&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;

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

&lt;/div&gt;



&lt;blockquote&gt;
&lt;h5&gt;
  
  
  Here &lt;code&gt;.col-lg-, .col-md-, col-sm-, col-xs-&lt;/code&gt; are Bootstrap's grid system work across multiple devices. &lt;code&gt;lg&lt;/code&gt; covers large breakpoints like Desktop, &lt;code&gt;md&lt;/code&gt; covers medium breakpoints like tablets and ipads, &lt;code&gt;sm&lt;/code&gt; means small breakpoints like latest smartphones &amp;amp; &lt;code&gt;xs&lt;/code&gt; covers extra small devices.
&lt;/h5&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now, coming to our focus on dividing grid into an odd columns. If you look at above code where columns are divided into 4 parts then you will get the logic of column width. Bootstrap &lt;code&gt;row&lt;/code&gt; is build with full width (i.e. 100%) of your screen size. So, if I want to divide my columns into 5 equal parts then it's very simple to calculate my each column width is having 20% width pretty simple right ? &lt;/p&gt;

&lt;blockquote&gt;
&lt;h5&gt;
  
  
  This needs to be done for Bootstrap 3 only as Bootstrap 4 provide the class name &lt;code&gt;col-&lt;/code&gt; which divides your column into an equal parts automatically.
&lt;/h5&gt;
&lt;/blockquote&gt;

&lt;p&gt;You can use Bootstrap 4 class &lt;code&gt;col-&lt;/code&gt; to do your work but it will keep dividing your layout and you can't put the control if you are dealing with any dynamic UI.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  &amp;lt;!-- Bootstrap 4 --&amp;gt;
  &amp;lt;div class="row"&amp;gt; 
    &amp;lt;div class="col"&amp;gt;  &amp;lt;/div&amp;gt;
    &amp;lt;div class="col"&amp;gt;  &amp;lt;/div&amp;gt;
    &amp;lt;div class="col"&amp;gt;  &amp;lt;/div&amp;gt;
    &amp;lt;div class="col"&amp;gt;  &amp;lt;/div&amp;gt;
    &amp;lt;div class="col"&amp;gt;  &amp;lt;/div&amp;gt;
     ....
     ....
  &amp;lt;/div&amp;gt;
   &amp;lt;!-- col class automatically divides my columns
   into equal parts --&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example above, if we keep dividing our UI using this &lt;code&gt;col&lt;/code&gt; class and if we want control over &lt;code&gt;col-xs-&lt;/code&gt; type devices, then eventually UI will not handle automatically. Sometimes it's preferable also with some situations.&lt;/p&gt;

&lt;p&gt;So, let's write some CSS to do our work doesn't matter if you are using any older or newer version of Bootstrap. (You can also use SASS / SCSS)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; # Solution

.col-xs-equal,
.col-sm-equal,
.col-md-equal,
.col-lg-equal {
    position: relative;
    min-height: 1px;
    padding-right: 10px;
    padding-left: 10px;
}

# Next, we are adding here some media queries with various
  breakpoints

.col-xs-equal {
    width: 20%;
    float: left;
}
@media (min-width: 768px) {
.col-sm-equal {
        width: 20%;
        float: left;
    }
}
@media (min-width: 992px) {
    .col-md-equal {
        width: 20%;
        float: left;
    }
}
@media (min-width: 1200px) {
    .col-lg-equal {
        width: 20%;
        float: left;
    }
}

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

&lt;/div&gt;



&lt;p&gt;Now, you are ready to build your HTML and apply these classes together&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="row"&amp;gt;
    &amp;lt;div class="col-lg-equal col-md-equal col-sm-equal 
    col-xs-equal"&amp;gt;
    ...
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="col-lg-equal col-md-equal col-sm-equal 
    col-xs-equal"&amp;gt;
    ...
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="col-lg-equal col-md-equal col-sm-equal 
    col-xs-equal"&amp;gt;
    ...
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="col-lg-equal col-md-equal col-sm-equal 
    col-xs-equal"&amp;gt;
    ...
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="col-lg-equal col-md-equal col-sm-equal 
    col-xs-equal"&amp;gt;
    ...
    &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can always change in media queries according to your UI needs. Here we took example of dividing row into 5 columns so you can also try to divide your column into 7, 9, etc. columns the logic will remain same only need to change width into your applied css.  &lt;/p&gt;

</description>
      <category>bootstap</category>
      <category>gridlayout</category>
    </item>
    <item>
      <title>Angular Image optimization using Gulp</title>
      <dc:creator>Maulik Thaker</dc:creator>
      <pubDate>Mon, 10 Aug 2020 08:06:00 +0000</pubDate>
      <link>https://forem.com/mak0099/angular-image-optimization-using-gulp-4p1j</link>
      <guid>https://forem.com/mak0099/angular-image-optimization-using-gulp-4p1j</guid>
      <description>&lt;p&gt;Hello, This is my very first Post in Dev.to and I want to share about how we can reduce image size by using gulp tool in Angular. You can take a tour of gulp [&lt;a href="https://gulpjs.com/"&gt;https://gulpjs.com/&lt;/a&gt;] in brief if not familiar. &lt;/p&gt;

&lt;p&gt;First most you need to create angular project by using&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ng new project-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;then,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cd project-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and install npm depencencies ( &lt;code&gt;$ npm install&lt;/code&gt;)&lt;/p&gt;

&lt;p&gt;After that install Gulp as a dev dependencies on your project using following command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npm install -D gulp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, create a gulpfile.js at root of your project. One more gulp dependency we need to reduce image size is called gulp-imagemin. Install this dev dependency using below command :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npm install -D gulp-imagemin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can write following code into your gulpfile.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const gulp = require('gulp'); // Initialize gulp 
const imagemin = require('gulp-imagemin');
 function optimizeImages(){
    return src('src/assets/images /*').pipe(imagemin()).pipe(gulp.dest('dist/newProject/assets/images'));
 }
exports.default = optimizeImages; // Call of task as default
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, gulp is need to be initialized first and then we used here imagemin feature of gulp. After that we create a function (In case of gulp it's task) named optimizeImages() and use src() for accept entry point of our image path (In my case, I usually stored my images at src/assets/images). Now we have to store optimized image at one path right ? So for that we used here gulp.dest('path'). For Angular, we need to create a build for deployment purpose so I run my gulp task after creating dist so I gave the path like dist / newProject/assets/images. Now we need to call our task named 'optimizeImages'. Gulp provide various ways of calling your tasks (publicly and privately) among-them one I used is&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;exports.default = optimizeImages;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your gulp task (optimizeImages) is called when you type $ gulp in terminal. &lt;/p&gt;

&lt;p&gt;So, let's call our gulp task by:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ng build --prod &amp;amp;&amp;amp; gulp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can see the each image size stored at your (dist/newProject/assets/images) destination path and compare it with your source path. It's pretty much reduced. Isn't it nice ? There are many other gulp plugins which can individually taken care of reduce of image size and removed unused css and js that we covered later. &lt;/p&gt;

</description>
      <category>angular</category>
      <category>gulp</category>
      <category>gulpimagemin</category>
    </item>
  </channel>
</rss>
