<?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: Mainak Chattopadhyay</title>
    <description>The latest articles on Forem by Mainak Chattopadhyay (@mainak0907).</description>
    <link>https://forem.com/mainak0907</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%2F998819%2F6e81c754-5cbf-4e4b-b1bd-7abdfe0eabef.jpeg</url>
      <title>Forem: Mainak Chattopadhyay</title>
      <link>https://forem.com/mainak0907</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/mainak0907"/>
    <language>en</language>
    <item>
      <title>React JS Superpower - Virtual DOM</title>
      <dc:creator>Mainak Chattopadhyay</dc:creator>
      <pubDate>Wed, 06 Dec 2023 05:48:23 +0000</pubDate>
      <link>https://forem.com/mainak0907/react-js-superpower-virtual-dom-178d</link>
      <guid>https://forem.com/mainak0907/react-js-superpower-virtual-dom-178d</guid>
      <description>&lt;h4&gt;
  
  
  The Virtual DOM (VDOM) is a representation of the real DOM in memory. It is a lightweight, tree-like data structure that mirrors the actual DOM tree. When there are changes to the data model, the VDOM is updated instead of the real DOM. This makes updates to the UI much faster, as it only requires updating the VDOM and then reconciling the changes with the real DOM.
&lt;/h4&gt;

&lt;p&gt;Here are some of the reasons why VDOM is faster than real DOM updates:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Diffing&lt;/strong&gt;&lt;/em&gt;: The VDOM uses a diffing algorithm to efficiently identify the minimum set of changes that need to be made to the real DOM. This avoids the need to re-render the entire DOM tree, which can be expensive.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Batch Updates&lt;/strong&gt;&lt;/em&gt;: VDOM updates are batched together, so that multiple changes can be applied to the real DOM in a single operation. This further reduces the number of times the real DOM needs to be updated.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Selective Updates&lt;/strong&gt;&lt;/em&gt;: VDOM updates are only applied to the parts of the real DOM that have actually changed. This is in contrast to direct DOM updates, which can re-render entire sections of the DOM even if they haven't changed.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;No Reflow or Repaint&lt;/strong&gt;&lt;/em&gt;: Updating the VDOM does not trigger reflow or repaint. This means that the browser does not need to recalculate the layout of the page or redraw the pixels on the screen. This can save a significant amount of time, especially for complex UIs.&lt;/p&gt;

&lt;p&gt;Overall, the VDOM is a powerful tool that can significantly improve the performance of web applications. By using the VDOM, developers can create more responsive and performant UIs that provide a better user experience.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>react</category>
      <category>opensource</category>
    </item>
    <item>
      <title>The Not-so-commonly Covered JS Topics</title>
      <dc:creator>Mainak Chattopadhyay</dc:creator>
      <pubDate>Thu, 30 Nov 2023 17:52:29 +0000</pubDate>
      <link>https://forem.com/mainak0907/the-not-so-commonly-covered-js-topics-3opl</link>
      <guid>https://forem.com/mainak0907/the-not-so-commonly-covered-js-topics-3opl</guid>
      <description>&lt;h2&gt;
  
  
  In this blog, I would discuss some of the most important Javascript Questions, often asked in the interviews I appeared for.
&lt;/h2&gt;




&lt;h3&gt;
  
  
  Immediately Invoked Function Expression (IIFE)
&lt;/h3&gt;




&lt;p&gt;An Immediately Invoked Function Expression (IIFE) is a common JavaScript design pattern that involves defining and invoking a function immediately after its creation. This pattern is often used to create a private scope for variables, avoiding polluting the global namespace and preventing variable collisions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(function () {
    // code to be executed immediately
})();

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Components:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Enclosure in Parentheses:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;(function() { ... }) creates an anonymous function expression. Wrapping the function in parentheses is necessary because in JavaScript, function declarations cannot be immediately invoked.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Function Declaration:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;function() { ... } is an anonymous function declaration. It can also be a named function if you want to refer to it within its own scope.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Invocation:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The final pair of parentheses () immediately invokes the function. This execution happens right after the function is defined.&lt;/p&gt;




&lt;ol&gt;
&lt;li&gt; Basic IIFE
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(function () {
    var localVar = "I am local to the IIFE";
    console.log(localVar);
})();
// localVar is not accessible here

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

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Passing Parameters
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(function (param) {
    console.log("Parameter value: " + param);
})("Hello, IIFE!");
// Output: Parameter value: Hello, IIFE!

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

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt; Returning Values
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var result = (function (a, b) {
    return a + b;
})(5, 10);
console.log(result);
// Output: 15

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

&lt;/div&gt;






&lt;h3&gt;
  
  
  Hoisting
&lt;/h3&gt;




&lt;p&gt;Hoisting is a concept which enables us to extract values of variables and functions even before initialising/assigning value without getting error and this is happening due to the 1st phase (memory creation phase) of the Execution Context.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;getName(); // Namaste
console.log(x); // undefined
var x = 7;
function getName() {
  console.log("Namaste");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;getName(); // Uncaught TypeError: getName is not a function
console.log(getName);
var getName = function () {
  console.log("Namaste");
};
// The code won't execute as the first line itself throws an TypeError.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Variable hoisting:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When you declare a variable (like giving a name to a new toy), the robot takes note of it and puts a label on it. &lt;br&gt;
This label goes to the top of your play area, so you know it's there. &lt;br&gt;
But the actual toy (the value) is put in the right place only when you decide.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Function Hoisting:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Imagine you want to play a game (function) like hide and seek. &lt;br&gt;
You say, "I want to play hide and seek!" &lt;br&gt;
The super-smart robot listens and says, &lt;br&gt;
"Sure! I know how to play hide and seek. Let's play!" &lt;br&gt;
You can start playing before you even tell the robot all the rules because it already knows the game.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Function Expressions:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Function expressions, such as arrow functions and anonymous functions, are not hoisted in the same way as function declarations. &lt;br&gt;
They behave more like variable declarations.&lt;/p&gt;

&lt;p&gt;Imagine we want to play another game, like "Simon Says." But this time, we don't have a rule book ready. &lt;br&gt;
Instead, we have a friend named "Simon" who knows the rules and is ready to lead the game.&lt;/p&gt;


&lt;h3&gt;
  
  
  Temporal Dead Zone
&lt;/h3&gt;




&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(a); // ReferenceError: Cannot access 'a' before initialization
console.log(b); // prints undefined as expected
let a = 10;
console.log(a); // 10
var b = 15;
console.log(window.a); // undefined
console.log(window.b); // 15
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;It looks like let isn't hoisted, &lt;strong&gt;but it is&lt;/strong&gt;&lt;/p&gt;



&lt;p&gt;Both a and b are actually initialized as undefined in hoisting stage. But var b is inside the storage space of GLOBAL, and a is in a separate memory object called script, where it can be accessed only after assigning some value to it first ie. one can access 'a' only if it is assigned. Thus, it throws error.&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;Temporal Dead Zone&lt;/strong&gt;: Time since when the let variable was hoisted until it is initialized some value.&lt;/p&gt;

&lt;p&gt;So any line till before "let a = 10" is the TDZ for a&lt;br&gt;
Since a is not accessible on global, its not accessible in window/this also. window.b or this.b -&amp;gt; 15; But window.a or this.a -&amp;gt;undefined, just like window.x-&amp;gt;undefined (x isn't declared anywhere)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reference Error&lt;/strong&gt; are thrown when variables are in temporal dead zone.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax Error&lt;/strong&gt; doesn't even let us run single line of code.&lt;/p&gt;


&lt;h3&gt;
  
  
  Currying
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://javascript.info/currying-partials"&gt;Follow this link to have an in-depth understanding &lt;/a&gt;&lt;/p&gt;


&lt;h3&gt;
  
  
  Closures
&lt;/h3&gt;

&lt;p&gt;Function bundled along with it's lexical scope is &lt;strong&gt;closure&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;JavaScript has a lexcial scope environment. If a function needs to access a variable, it first goes to its local memory. When it does not find it there, it goes to the memory of its lexical parent. See Below code, Over here function y along with its lexical scope i.e. (function x) would be called a closure.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function x() {
  var a = 7;
  function y() {
    console.log(a);
  }
  return y;
}
var z = x();
console.log(z); // value of z is entire code of function y.

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

&lt;/div&gt;



&lt;p&gt;In above code, When y is returned, not only is the function returned but the entire closure (fun y + its lexical scope) is returned and put inside z. So when z is used somewhere else in program, it still remembers var a inside x()&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A closure is a function that has access to its outer function scope even after the function has returned. Meaning, A closure can remember and access variables and arguments reference of its outer function even after the function has returned.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Closures can impact memory management, as they can prevent variables from being garbage collected when they are no longer needed. &lt;br&gt;
To avoid memory leaks, it's essential to be mindful of retaining closures and to clean up references when they are no longer required.&lt;/p&gt;




&lt;h3&gt;
  
  
  Cookies
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://javascript.info/cookie"&gt;Get an detailed view about cookies&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  LocalStorage and SessionStorage
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://javascript.info/localstorage"&gt;Checkout this comprehensive URL&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;If you are stuck till here , I would like to give you a goldmine &lt;br&gt;
&lt;a href="https://alok722.github.io/namaste-javascript-notes/dist/lectures.html"&gt;Deep Dive !!! Cheers&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>interview</category>
    </item>
    <item>
      <title>How Does Chrome's V8 Engine Actually Work?</title>
      <dc:creator>Mainak Chattopadhyay</dc:creator>
      <pubDate>Wed, 29 Nov 2023 06:45:20 +0000</pubDate>
      <link>https://forem.com/mainak0907/how-does-chromes-v8-engine-actually-work-4c2h</link>
      <guid>https://forem.com/mainak0907/how-does-chromes-v8-engine-actually-work-4c2h</guid>
      <description>&lt;h2&gt;
  
  
  v8 of Google has Interpreter called Ignition, a compiler called Turbo Fan and garbage collector called Orinoco
&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%2Fpgd4l1gpe9sthastb1m3.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%2Fpgd4l1gpe9sthastb1m3.png" alt="V8 Architecture"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;ul&gt;
&lt;li&gt;JS runs literally everywhere from smart watch to robots to browsers because of Javascript Runtime Environment (JRE).&lt;/li&gt;
&lt;/ul&gt;




&lt;ul&gt;
&lt;li&gt;JRE is like a big container which has everything which are required to run Javascript code.&lt;/li&gt;
&lt;/ul&gt;




&lt;ul&gt;
&lt;li&gt;JRE consists of a JS Engine (❤️ of JRE), set of APIs to connect with outside environment, event loop, Callback queue, Microtask queue etc.&lt;/li&gt;
&lt;/ul&gt;




&lt;ul&gt;
&lt;li&gt;Browser can execute javascript code because it has the Javascript Runtime Environment.&lt;/li&gt;
&lt;/ul&gt;




&lt;ul&gt;
&lt;li&gt;ECMAScript is a governing body of JS. It has set of rules which are followed by all JS engines like Chakra(Edge), Spidermonkey(Firefox)(first javascript engine created by JS creator himself), v8(Chrome)&lt;/li&gt;
&lt;/ul&gt;




&lt;ul&gt;
&lt;li&gt;Javascript Engine is not a machine. Its software written in low level languages (eg. C++) that takes in hi-level code in JS and spits out low level machine code.&lt;/li&gt;
&lt;/ul&gt;




&lt;ul&gt;
&lt;li&gt;Code inside Javascript Engine passes through 3 steps : &lt;strong&gt;Parsing, Compilation and Execution&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&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%2Ftafm3wjoll4vl8byncoj.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%2Ftafm3wjoll4vl8byncoj.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;&lt;strong&gt;Parsing&lt;/strong&gt;&lt;/em&gt; - Code is broken down into tokens. In "let a = 7" -&amp;gt; let, a, =, 7 are all tokens. Also we have a syntax parser that takes code and converts it into an AST (Abstract Syntax Tree) which is a JSON with all key values like type, start, end, body etc (looks like package.json but for a line of code in JS. Kinda unimportant)(Check out astexplorer.net -&amp;gt; converts a line of code into AST).&lt;/li&gt;
&lt;/ul&gt;




&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;&lt;strong&gt;Compilation&lt;/strong&gt;&lt;/em&gt; - JS has something called Just-in-time(JIT) Compilation - uses both interpreter &amp;amp; compiler. Also compilation and execution both go hand in hand. The AST from previous step goes to interpreter which converts hi-level code to byte code and moves to execeution. While interpreting, compiler also works hand in hand to compile and form optimized code during runtime. Does JavaScript really Compiles? The answer is a loud YES. More info at: &lt;a href="https://github.com/getify/You-Dont-Know-JS/blob/2nd-ed/get-started/ch1.md#whats-in-an-interpretation" rel="noopener noreferrer"&gt;Link&lt;/a&gt;. JS used to be only interpreter in old times, but now has both to compile and interpreter code and this make JS a JIT compiled language, its like best of both world.&lt;/li&gt;
&lt;/ul&gt;




&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;&lt;strong&gt;Execution&lt;/strong&gt;&lt;/em&gt; - Needs 2 components ie. Memory heap(place where all memory is stored) and Call Stack. There is also a garbage collector. It uses an algo called Mark and Sweep. &lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Additional Information -
&lt;/h4&gt;




&lt;p&gt;&lt;strong&gt;The Mark-and-Sweep algorithm&lt;/strong&gt; is a garbage collection algorithm used in computer programming to automatically reclaim memory that is no longer in use or referenced by the program. It is one of the fundamental techniques for memory management in languages that do not use manual memory management like C or C++. The algorithm consists of two main phases: marking and sweeping.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Mark Phase:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The algorithm begins by traversing the entire memory heap, starting from the roots (e.g., global variables, local variables, and registers), and marking all the objects that are reachable and still in use.&lt;/li&gt;
&lt;li&gt;It identifies and marks objects that are reachable by following references or pointers from the root set.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Sweep Phase:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;After the marking phase, the algorithm sweeps through the entire memory heap again, deallocating memory that was not marked in the previous phase.&lt;/li&gt;
&lt;li&gt;Unmarked objects are considered as garbage, meaning they are no longer accessible or needed by the program.&lt;/li&gt;
&lt;li&gt;The memory occupied by these unreferenced objects is then freed up and made available for future use.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The Mark-and-Sweep algorithm has some advantages and disadvantages:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantages:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It can handle circular references, where a group of objects reference each other in a cycle, as it relies on reachability rather than reference counting.&lt;/li&gt;
&lt;li&gt;It reclaims all unreachable memory, preventing memory leaks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Disadvantages:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It may introduce pause times during the collection process, as it requires stopping the execution of the program temporarily to perform the collection.&lt;/li&gt;
&lt;li&gt;Fragmentation can occur in the memory heap as a result of the non-contiguous layout of the reclaimed memory.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;While the Mark-and-Sweep algorithm is a classic garbage collection technique, there are other algorithms like generational garbage collection and incremental garbage collection, each with its own set of trade-offs and optimizations.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Inline caching&lt;/strong&gt; is a technique used in computer programming and language runtime environments, particularly in the context of dynamic dispatch and polymorphism. It aims to optimize method or function calls by caching information about the types of objects involved in the call, reducing the overhead associated with dynamic dispatch.&lt;/p&gt;

&lt;p&gt;Here's how inline caching typically works:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;First Call:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When a method or function is called with a specific set of object types, the runtime system records information about the types involved in the call.&lt;/li&gt;
&lt;li&gt;This information is cached or "inlined" directly in the code that performs the method dispatch.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Subsequent Calls:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On subsequent calls to the same method or function with the same or compatible types, the cached information is used to skip the dynamic dispatch mechanism.&lt;/li&gt;
&lt;li&gt;Instead of going through the usual process of dynamic type resolution and method lookup, the cached information is directly used to determine the appropriate method to invoke.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Inline caching is particularly effective in situations where the types involved in method calls do not change frequently. It reduces the overhead associated with dynamic dispatch and can significantly improve the performance of certain code paths.&lt;/p&gt;

&lt;p&gt;This technique is often used in object-oriented languages with dynamic dispatch, such as JavaScript, Python, or Smalltalk. In these languages, objects can have multiple types, and the correct method to call may depend on the actual runtime type of an object.&lt;/p&gt;

&lt;p&gt;Inline caching is closely related to the concept of polymorphic inline caching (PIC), where the caching mechanism is designed to handle multiple types efficiently. Polymorphic inline caching is an extension of inline caching that allows for handling a varying number of types associated with a method call.&lt;/p&gt;

&lt;p&gt;The effectiveness of inline caching depends on the usage patterns of the program. If the types involved in method calls are stable or change infrequently, the caching mechanism can significantly improve performance by avoiding the overhead of repeated dynamic dispatch.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
      <category>react</category>
    </item>
    <item>
      <title>My first Open Source Contribution Month</title>
      <dc:creator>Mainak Chattopadhyay</dc:creator>
      <pubDate>Fri, 03 Nov 2023 16:29:41 +0000</pubDate>
      <link>https://forem.com/mainak0907/my-first-open-source-contribution-month-65p</link>
      <guid>https://forem.com/mainak0907/my-first-open-source-contribution-month-65p</guid>
      <description>&lt;h3&gt;
  
  
  Intro
&lt;/h3&gt;

&lt;p&gt;I was hoping you could take a look at my GitHub Account &lt;a href="https://github.com/mainak0907"&gt; Link &lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This was my very first open-source contribution. I am a 3rd Year Engineering Undergraduate at VIT Chennai, trying to break out in the domain.&lt;/p&gt;

&lt;h3&gt;
  
  
  Highs and Lows
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/daabChingrii/HFTNeoVogue/pull/8"&gt;Pull Request 1&lt;/a&gt; - This was about revamping the ReadMe for better navigation and contributing experience.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/SpandanM110/De-SchoolMate/pull/69"&gt;Pull Request 2&lt;/a&gt; - This was a UI Enhancement for a Hackathon Project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/rudra016/WebDev-OpenSource/pull/225"&gt;Pull Request 3&lt;/a&gt; - This helped me learn NEXT JS and JSON - SERVER&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/rudra016/WebDev-OpenSource/pull/170"&gt;Pull Request 4&lt;/a&gt; - This helped me learn Tailwind CSS&lt;/p&gt;

&lt;h3&gt;
  
  
  Growth
&lt;/h3&gt;

&lt;p&gt;Hacktoberfest is more than just about making contributions. It's also a great opportunity to learn from the open source community.&lt;/p&gt;

&lt;p&gt;Many open source projects have active communities on Discord or Slack. These communities are a great place to ask questions and get help from experienced developers.&lt;/p&gt;

&lt;p&gt;I also recommend following open source projects on social media and reading their blogs. This is a great way to stay up-to-date on the latest developments and learn about new technologies.&lt;/p&gt;

&lt;p&gt;Hacktoberfest 2023 was an amazing experience. I learned a lot, made some great contributions, and connected with the open source community.&lt;/p&gt;

&lt;p&gt;If you're a developer, I encourage you to participate in Hacktoberfest next year. It's a great way to learn, give back, and make a difference.&lt;/p&gt;

&lt;p&gt;Here are some additional tips for participating in Hacktoberfest:&lt;/p&gt;

&lt;p&gt;Start early. Don't wait until the last week of October to start contributing.&lt;/p&gt;

&lt;p&gt;Don't be afraid to ask for help. The open-source community is very welcoming and helpful.&lt;/p&gt;

&lt;p&gt;Be patient and persistent. It may take some time to get your pull requests merged.&lt;/p&gt;

&lt;p&gt;Have fun! Hacktoberfest is a great opportunity to learn and connect with other developers.&lt;/p&gt;

</description>
      <category>hack23contributor</category>
      <category>hacktoberfest23</category>
      <category>beginners</category>
    </item>
    <item>
      <title>hello</title>
      <dc:creator>Mainak Chattopadhyay</dc:creator>
      <pubDate>Wed, 30 Aug 2023 16:12:07 +0000</pubDate>
      <link>https://forem.com/mainak0907/hello-c2i</link>
      <guid>https://forem.com/mainak0907/hello-c2i</guid>
      <description>&lt;p&gt;This is TRC BLOG&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Security Vulnerabilities and Prevention in HTML5</title>
      <dc:creator>Mainak Chattopadhyay</dc:creator>
      <pubDate>Sun, 01 Jan 2023 07:40:43 +0000</pubDate>
      <link>https://forem.com/ieeecsvitc/security-vulnerabilities-and-prevention-in-html5-p0m</link>
      <guid>https://forem.com/ieeecsvitc/security-vulnerabilities-and-prevention-in-html5-p0m</guid>
      <description>&lt;p&gt;The very basics of web development is HTML which provides a lot of functionalities to markup our webpages.&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%2F6p9gh8xxn1914tu7g3em.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%2F6p9gh8xxn1914tu7g3em.png" alt="HTML5 logo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML5 has introduced some new features which make web pages richer. New features include new semantic elements like &lt;em&gt;'header', 'footer'&lt;/em&gt;, etc., new attributes for form elements like &lt;em&gt;date, time, range&lt;/em&gt;, etc., new graphic elements like &lt;em&gt;SVG&lt;/em&gt; and &lt;em&gt;canvas&lt;/em&gt;, and new multimedia elements like &lt;em&gt;audio&lt;/em&gt; and &lt;em&gt;video&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Hence , with increased functionality , the data flow has also increased leading to a possible data theft by attackers.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For example&lt;/strong&gt; - An attacker can steal the data by inserting some wicked code through HTML forms which will be kept in the database. Security flaws are possible if proper security measures are not taken when using HTML5 features like communication APIs, storage APIs, geolocation, sandboxed frames, offline applications, etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let us explore HTML Security
&lt;/h2&gt;

&lt;p&gt;As HTML applications are web-based applications, developers should take proper measures to safeguard the stored data and communications&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;The following is the list of a few vulnerabilities that are possible in HTML--&amp;gt;&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;HTML Injection&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Clickjacking&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;HTML5 attributes and events vulnerabilities&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Web Storage Vulnerability&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reverse Tabnabbing &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  HTML Injection
&lt;/h2&gt;

&lt;p&gt;As the name suggest , the attacker injects a malicious piece of code for channeling the data.&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%2F4zypftncdn3hend7pzl2.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%2F4zypftncdn3hend7pzl2.png" alt="HTML Injection"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;There are two types of HTML Injection -&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Stored HTML Injection&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The malicious code injected by an attacker will get stored in the backend and will get executed whenever a user makes a call to that functionality.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Reflected HTML Injection&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The malicious code will not get code stored in the webserver rather will be executed every time the user responds to the malicious code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Best Practices to prevent HTML injection -&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Use safe Javascript methods like innerText in place of innerHTML&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Code Sanitization: Removing illegal characters from input and output refers to HTML code sanitization.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Output Encoding: Converting untrusted data into a safe form where data will be rendered to the user instead of getting executed. It converts special characters in input and output to entities form so that they cannot be executed. For example, &amp;lt; will be converted to "&amp;amp;lt" ; etc.,&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Clickjacking
&lt;/h2&gt;

&lt;p&gt;It is an attack where an attacker uses low iframes with low opaqueness or transparent layers to trick users into clicking on something somewhat diverse from what they actually see on the page.&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%2Fwgxqkbetcqsc2zvar5bz.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%2Fwgxqkbetcqsc2zvar5bz.png" alt="Clickjacking"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Thus an attacker is hijacking clicks which will execute some malicious code and hence the name 'Clickjacking'&lt;/em&gt;. &lt;br&gt;
It is also known as UI redressing or iframe overlay.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For example&lt;/strong&gt;,&lt;br&gt;
 &lt;em&gt;on a social networking website, a clickjacking attack leads to an unauthorized user spamming the entire network of your friends by sending some false messages&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;There are two ways to prevent Clickjacking --&amp;gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Client-side methods&lt;/strong&gt;: The most common method is to prevent the webpages from being displayed within a frame which is known as frame-buster or frame-killer. &lt;br&gt;
&lt;em&gt;Though this method is effective in a few cases it is not considered a best practice as it can be easily bypassed.&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Server-side methods&lt;/strong&gt;: Security experts recommend server-side methods to be the most effective methods to defend against clickjacking. Below are the two response headers to deal with this. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Using X-Frame-Options response header.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Using Content Security Policy(CSP) response header.&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;Note - We would talk about response headers in details in later blogs&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  HTML5 Attributes &amp;amp; Events Vulnerabilities
&lt;/h2&gt;

&lt;p&gt;HTML5 has few tags, attributes, and events that are prone to different attacks as they can execute Javascript code. These will be vulnerable to &lt;em&gt;XSS(Cross - site scripting)&lt;/em&gt; and &lt;em&gt;CSRF(Cross-Site Request Forgery)&lt;/em&gt; 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%2Fxfcfcuq69kuerzmlpkuz.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%2Fxfcfcuq69kuerzmlpkuz.png" alt="HTML EV"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Examples-&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;1.&lt;strong&gt;Malicious script injection via formaction attribute&lt;/strong&gt;&lt;/p&gt;

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

&amp;lt;form id="form1" /&amp;gt;
&amp;lt;button form="form1" formaction="javascript:alert(1)"&amp;gt;Submit&amp;lt;/button&amp;gt;


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

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;In the above code snippet, the malicious script can be injected in formaction attribute. To prevent this, users should not be allowed to submit forms with form and formaction attributes or transform them into non-working attributes.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;2.&lt;strong&gt;Malicious script injection via an onfocus event&lt;/strong&gt;&lt;/p&gt;

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

&amp;lt;input type="text" autofocus onfocus="alert('hacked')"/&amp;gt; 


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

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;This will automatically get focus and then executes the script injected. To prevent this, markup elements should not contain autofocus attributes.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;3.&lt;strong&gt;Malicious script injection via an onerror event in the video-tag&lt;/strong&gt;&lt;/p&gt;

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

&amp;lt;video src="/apis/authContent/content-store/Infosys/Infosys_Ltd/Public/lex_auth_012782317766025216289/web-hosted/assets/temp.mp3" onerror="alert('hacked')"&amp;gt;&amp;lt;/video&amp;gt;


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

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;This code will run the script injected if the given source file is not available. So, we should not use event handlers in audio and video tags as these are prone to attacks.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Lets us take a look into &lt;/p&gt;

&lt;h2&gt;
  
  
  HTML Sanitization
&lt;/h2&gt;

&lt;p&gt;HTML Sanitization provides protection from a few vulnerabilities like XSS(Cross-site scripting) by replacing HTML tags with safe tags or HTML entities.&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%2Fkgm9g9vb1tw4cqxorpm0.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%2Fkgm9g9vb1tw4cqxorpm0.png" alt="HTML Sanitization"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The tags such as &lt;code&gt;&amp;lt;b&amp;gt;,&amp;lt;i&amp;gt;,&amp;lt;u&amp;gt;,&amp;lt;em&amp;gt;,&amp;lt;strong&amp;gt;&lt;/code&gt;, which are used for changing fonts are often allowed. The sanitization process removes advanced tags like &lt;code&gt;&amp;lt;script&amp;gt; &amp;lt;embed&amp;gt;,&amp;lt;object&amp;gt; and &amp;lt;link&amp;gt;&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;This process also removes potentially dangerous attributes like 'onclick' attribute in order to prevent malicious code injection into the application.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Entity names for some HTML characters&lt;/em&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%2Fn2or0cjonrmiritj2r48.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%2Fn2or0cjonrmiritj2r48.png" alt="Table"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When a web browser finds these entities, they will not be executed. But instead, they will be converted back to HTML tags and printed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Example -&lt;/em&gt;&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Consider the scenario that an attacker injects the below HTML code into a web page.&lt;/p&gt;

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

&amp;lt;a href="#" onmouseover="alert('hacked')"&amp;gt;Avengers&amp;lt;/a&amp;gt;


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

&lt;/div&gt;

&lt;p&gt;On using HTML sanitization, the response will be as below.&lt;/p&gt;

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

&amp;amp;lt;a href="#" onmouseover="alert('hacked')"&amp;amp;gt; Avengers &amp;amp;lt;/a&amp;amp;gt;


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

&lt;/div&gt;

&lt;p&gt;This code will not be executed instead of stored as plain text in the response.&lt;/p&gt;

&lt;p&gt;There are many sanitizer libraries available to do this job. Some of the commonly used libraries are &lt;strong&gt;&lt;em&gt;DOMPurify, XSS, and XSS-filters.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Local Storage Vulnerabilities
&lt;/h2&gt;

&lt;p&gt;In our web applications, we often store some data in the browser cache. As the data is stored at the client-side, there is a chance of data-stealing by injecting some malicious code, if no proper care is taken. Let us now see how to store the data properly to prevent such attacks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;HTML5 has introduced Web storage or offline storage which deals with storing data in a local cache. Data can be stored using two types of objects in HTML5. Local storage and Session storage. These storages hold data in the form of key-value pairs.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Local storage&lt;/strong&gt;&lt;/em&gt; holds the data in the browser cache until the user deletes it or it expires based on the expiry date given. &lt;code&gt;setItem()&lt;/code&gt; method is used to assign data to local storage. &lt;/p&gt;

&lt;p&gt;The below code creates three items with names bgcolor, textcolor, fontsize and assigns the values to them.&lt;/p&gt;

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

localStorage.setItem("bgcolor", document.getElementById("bgcolor").value);
localStorage.setItem("textcolor", document.getElementById("textcolor").value);
localStorage.setItem("fontsize", document.getElementById("fontsize").value);



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

&lt;/div&gt;

&lt;p&gt;Users can view the storage data in the browser by pressing F12 as shown below:&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%2Fw96clzsas1t346fwxnc4.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%2Fw96clzsas1t346fwxnc4.png" alt="Local Storage"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Similarly, &lt;strong&gt;session storage&lt;/strong&gt; holds the data until the session ends or the browser/tab is closed&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;An attacker can inject some malicious code and can steal the data stored here. So we should always ensure that sensitive information is not stored at the client side.&lt;/p&gt;

&lt;p&gt;Preventive measure -&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Use cookies with the 'httponly' flag to protect the data stored at the client-side&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Let us get an overview of another type of possible attack&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Reverse Tabnabbing
&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%2Fhb2t5vylpaqr7c4jwis1.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%2Fhb2t5vylpaqr7c4jwis1.png" alt="Reverse Tabnabbing"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We would try to understand this with the help an example -&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Consider a message forum or a blog where an attacker can post his own website link. If any user visits that link will be shown some information but in the background that malicious website will redirect the parent login page to a fake page that looks similar to the original login page&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;When a user comes back to the message forum, they appear to be logged out. Without thinking they will enter their credentials to log in as the page looks similar to the original one. Now the attacker can get hold of that authentication data. Now the user will be redirected to the message forum page automatically so that they won't get a doubt that they have entered credentials in a fake login page&lt;/em&gt;&lt;/p&gt;

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