<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Aniket Batabyal on Medium]]></title>
        <description><![CDATA[Stories by Aniket Batabyal on Medium]]></description>
        <link>https://medium.com/@aniketbatabyal?source=rss-15df93944557------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*j4dArByJKGgB5iGHv9LjGw.jpeg</url>
            <title>Stories by Aniket Batabyal on Medium</title>
            <link>https://medium.com/@aniketbatabyal?source=rss-15df93944557------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 18:50:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aniketbatabyal/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Supercharge Your Functions with an Optimized call() Polyfill]]></title>
            <link>https://aniketbatabyal.medium.com/supercharge-your-functions-with-an-optimized-call-polyfill-d6bcd629a5d?source=rss-15df93944557------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6bcd629a5d</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Aniket Batabyal]]></dc:creator>
            <pubDate>Tue, 07 Mar 2023 15:29:27 GMT</pubDate>
            <atom:updated>2023-03-07T15:29:27.681Z</atom:updated>
            <content:encoded><![CDATA[<h4>Boost Performance and Reduce Overhead with Caching Mechanism</h4><h4>What is Function.prototype.call anyway?</h4><p>Function.prototype.call() is a built-in JavaScript function that allows developers to call a function with a specific this value and arguments. However, there might be instances where this function is not supported by certain browsers or environments. To overcome this, developers can write their own custom implementation of the call() function, which is commonly referred to as a polyfill.</p><p>In this blog post, we will explore an optimized implementation of the Function.prototype.call() polyfill that uses a caching mechanism to improve performance. We will begin by discussing the unoptimized implementation and the challenges it poses before diving into the optimized solution.</p><ul><li><strong>Unoptimised Version:</strong></li></ul><p>The unoptimized implementation of the Function.prototype.call() polyfill is a straightforward approach that works by returning a new function that executes the original function with the desired this value and arguments.</p><pre>Function.prototype.customCall = function (context, ...outerArgs) {<br>    const originalFunction = this;<br>    return function (...innerArgs) {<br>        return originalFunction.apply(context, [...outerArgs, ...innerArgs]);<br>    }<br>}</pre><p>The above implementation creates a new function object every time it is called, which can be a performance bottleneck, especially when calling the function multiple times with the same this value and arguments.</p><ul><li><strong>Optimised Implementation</strong></li></ul><p>To improve the performance of the Function.prototype.call() polyfill, we can use a caching mechanism that stores the results of each function call to avoid creating new function objects. Here&#39;s the optimized implementation of the Function.prototype.call() polyfill:</p><pre>const cache = new WeakMap();<br><br>Function.prototype.customCallOptimised = function (context, ...args) {<br>    const originalFunction = this;<br><br>    const cacheKey = context.toString() + args.toString();<br><br>    if (cache.has(originalFunction) &amp;&amp; cache.get(originalFunction).has(cacheKey)) {<br>        return cache.get(originalFunction).get(cacheKey);<br>    } <br><br>    const cachedFunc = function (...innerArgs) {<br>        try  {<br>            return originalFunction.apply(context, [...args, ...innerArgs]);<br>        } catch (err) {<br>            console.error(&quot;Error while calling the original function&quot;);<br>        }<br>    }<br><br>    if (cache.has(originalFunction)) {<br>        cache.get(originalFunction).set(cacheKey, cachedFunc)<br>    } else {<br>        cache.set(originalFunction, new Map([[cacheKey, cachedFunc]]))<br>    }<br>    <br>    return cachedFunc;<br>}</pre><p>The above implementation uses a WeakMap to store the cached results of each function call. The cacheKey is created by concatenating the string representations of the context and args parameters. If the cached result is found, it is returned, otherwise, a new function is created, and its result is cached.</p><p>The cached function is created using a closure, which captures the context and args parameters of the Function.prototype.call() method. This function is then returned, and subsequent calls with the same this value and arguments will return the cached result.</p><h3>Conclusion</h3><p>In this blog post, we explored an optimized implementation of the Function.prototype.call() polyfill that uses a caching mechanism to improve performance. By caching the results of each function call, we can avoid creating new function objects and improve the performance of our code.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6bcd629a5d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Javascript Promises: A Comprehensive Guide to Asynchronous Programming]]></title>
            <link>https://aniketbatabyal.medium.com/mastering-javascript-promises-a-comprehensive-guide-to-asynchronous-programming-9a0fd089b02b?source=rss-15df93944557------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a0fd089b02b</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Aniket Batabyal]]></dc:creator>
            <pubDate>Wed, 22 Feb 2023 17:37:55 GMT</pubDate>
            <atom:updated>2023-02-22T17:37:55.090Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Shakespeare of promises" src="https://cdn-images-1.medium.com/max/1024/1*HNum56V0tHlrLiI50APfiQ.jpeg" /><figcaption>Shakespeare of Promises</figcaption></figure><h4>Learn how to write efficient and error-free code with Promises, the essential tool for modern web development.</h4><h4>What are promises anyway?</h4><p>In JavaScript, a Promise is an object that represents a value that may not be available yet, but will be at some point in the future. Promises are commonly used for handling asynchronous operations, such as making API requests, reading files, or accessing a database.</p><p>When you create a Promise, you specify an operation that may take some time to complete, and then you define what should happen when the operation is successful or when it fails. You can think of a Promise as a container that holds a value that may become available later on.</p><p>Promises have three states:</p><ol><li>Pending: The initial state, before the operation has completed.</li><li>Fulfilled: The operation completed successfully and the promise has a value.</li><li>Rejected: The operation failed and the promise has a reason for the failure.</li></ol><p>You can attach callbacks to a Promise to handle the fulfillment or rejection of the operation. For example, you might specify a callback to update the user interface with the result of an API request when it is available.</p><p>Promises provide a clean and consistent way to work with asynchronous operations in JavaScript, making it easier to write maintainable and predictable code.</p><h4>The Mechanism Of Promises:</h4><p>The mechanism of Promises in JavaScript is based on the concept of “callbacks” and “asynchronous operations.”</p><p>When you create a Promise, you pass a function that takes two arguments: “resolve” and “reject.” These two arguments are also functions that you can call when the operation is successful or when it fails, respectively.</p><p>When the Promise is created, it enters the “pending” state, indicating that the operation has not yet been completed. The Promise then executes the function that you passed to it, which usually involves making an asynchronous operation, such as an API request or reading a file.</p><p>When the operation is completed successfully, you call the “<strong>resolve</strong>” function and pass it the result. This transitions the Promise to the “<strong>fulfilled</strong>” state, indicating that the operation was successful and that the Promise now has a value. Any callbacks that were attached to the Promise are then executed with the result.</p><p>If the operation fails, you call the “<strong>reject</strong>” function and pass it the reason for the failure. This transitions the Promise to the “<strong>rejected</strong>” state, indicating that the operation failed and that the Promise has a reason for the failure. Again, any callbacks that were attached to the Promise are then executed with the reason for the failure.</p><p>By using Promises, you can write asynchronous code that is more maintainable and easier to read. Promises also allow you to handle errors and exceptions in a more consistent and predictable way, which can help to prevent bugs and make your code more robust.</p><h4>Enough Talk! Show me the freaking code!</h4><p>Okay! Okay! I know it’s a lot to digest so here is a simple code example explaining promises:</p><pre>// Create a Promise that resolves after a certain amount of time<br>const myPromise = new Promise((resolve, reject) =&gt; {<br>  setTimeout(() =&gt; {<br>    const randomNum = Math.random();<br>    if (randomNum &lt; 0.5) {<br>      resolve(randomNum);<br>    } else {<br>      reject(&quot;Oops, something went wrong!&quot;);<br>    }<br>  }, 2000);<br>});<br><br>// Attach a callback to handle the fulfilled Promise<br>myPromise.then(result =&gt; {<br>  console.log(`The Promise was fulfilled with the result: ${result}`);<br>}).catch(reason =&gt; {<br>  console.log(`The Promise was rejected with the reason: ${reason}`);<br>});</pre><p>In this code, we create a new Promise that resolves after 2 seconds. Inside the Promise function, we generate a random number and use it to either resolve the Promise with the number as the result or reject the Promise with an error message.</p><p>We then attach a callback to the Promise using the then method. This callback will be executed when the Promise is fulfilled and will receive the result as an argument. If the Promise is rejected, we attach another callback using the catch method, which will be executed with the reason for the rejection as an argument.</p><p>When we run this code, we’ll see the console output either the result or the error message, depending on whether the Promise was fulfilled or rejected. This is the basic mechanism of Promises in JavaScript: we create a Promise that represents an asynchronous operation, attach callbacks to handle the results or errors, and let the Promise handle the rest.</p><h4>Promise Chaining? What the hell is that?</h4><blockquote>Imagine you’re running a relay race, where each team member runs a segment of the race before passing the baton to the next runner. Similarly, in JavaScript, Promise chaining allows you to pass the results of one Promise to the next Promise in a sequence, so that you can execute multiple asynchronous operations in a specific order.</blockquote><p>With Promise chaining, you can write asynchronous code that looks like synchronous code, making it easier to read and maintain. Here’s an example to illustrate how Promise chaining works:</p><pre>fetch(&#39;https://api.example.com/data&#39;)<br>  .then(response =&gt; response.json())<br>  .then(data =&gt; processData(data))<br>  .then(result =&gt; displayResult(result))<br>  .catch(error =&gt; handleError(error));</pre><p>In this example, we first make an API request using the fetch function, which returns a Promise that resolves with the response from the server. We then chain a series of then methods to the Promise, which handle the response and pass the data to the next then method.</p><p>In this case, the first then method parses the response as JSON and returns the result, which is then passed to the processData function. The result of that function is then passed to the displayResult function, which displays the final result to the user.</p><p>If any errors occur at any point in the chain, the catch method will handle the error and prevent it from crashing the application.</p><p>By chaining Promises in this way, you can create a sequence of asynchronous operations that are executed in order, with each operation building on the result of the previous operation. This makes it easier to write code that is easy to read, easy to maintain, and less prone to errors.</p><p>So go forth, JavaScript developer, and embrace the power of Promise chaining to create beautiful and elegant asynchronous code!</p><p><strong>Some complex examples ahead to better your understanding:</strong></p><pre>const getUser = () =&gt; {<br>  return new Promise((resolve, reject) =&gt; {<br>    setTimeout(() =&gt; {<br>      resolve({ id: 1, name: &quot;John&quot; });<br>    }, 2000);<br>  });<br>};<br><br>const getPosts = (userId) =&gt; {<br>  return new Promise((resolve, reject) =&gt; {<br>    setTimeout(() =&gt; {<br>      resolve([<br>        { id: 1, title: &quot;Post 1&quot;, authorId: userId },<br>        { id: 2, title: &quot;Post 2&quot;, authorId: userId }<br>      ]);<br>    }, 2000);<br>  });<br>};<br><br>getUser()<br>  .then(user =&gt; getPosts(user.id))<br>  .then(posts =&gt; console.log(posts))<br>  .catch(error =&gt; console.error(error));</pre><p>In this example, we define two functions that return Promises: getUser, which returns a Promise that resolves with a user object, and getPosts, which takes a user ID as an input and returns a Promise that resolves with an array of post objects for that user.</p><p>We then chain the Promises together using the then method: we first call getUser and pass the result to getPosts, which takes the user ID and uses it to fetch the user&#39;s posts. Finally, we log the result of getPosts to the console.</p><p><strong>Parallel Promises</strong></p><pre>const getPost = (postId) =&gt; {<br>  return new Promise((resolve, reject) =&gt; {<br>    setTimeout(() =&gt; {<br>      resolve({ id: postId, title: `Post ${postId}` });<br>    }, 2000);<br>  });<br>};<br><br>const postIds = [1, 2, 3];<br><br>Promise.all(postIds.map(id =&gt; getPost(id)))<br>  .then(posts =&gt; console.log(posts))<br>  .catch(error =&gt; console.error(error));</pre><p>In this example, we define a function getPost that returns a Promise that resolves with a post object for a given ID. We also define an array of post IDs that we want to fetch.</p><p>We then use the Promise.all method to execute all the Promises in parallel: we call getPost for each post ID in the array using the map method, and then pass the resulting array of Promises to Promise.all. When all the Promises have resolved, the resulting array of post objects is passed to the then callback, which logs the array to the console.</p><p>These examples demonstrate how Promises can be used in a variety of scenarios, from basic asynchronous operations to more complex scenarios involving multiple Promises, chaining, and parallel execution.</p><p><strong>Handle the naughty errors</strong></p><pre>const fetchUserData = () =&gt; {<br>  return new Promise((resolve, reject) =&gt; {<br>    // Fetch user data from an API<br>    fetch(&#39;https://myapi.com/users&#39;)<br>      .then(response =&gt; response.json())<br>      .then(data =&gt; resolve(data))<br>      .catch(error =&gt; reject(error));<br>  });<br>};<br><br>const displayUserData = () =&gt; {<br>  fetchUserData()<br>    .then(data =&gt; {<br>      // Display the user data<br>      console.log(data);<br>    })<br>    .catch(error =&gt; {<br>      // Display an error message<br>      console.error(`Error fetching user data: ${error}`);<br>    });<br>};</pre><p>In this example, we define a function fetchUserData that returns a Promise that fetches user data from an API. We use the fetch function to make an HTTP request to the API and parse the response using the json method. If the request is successful, we resolve the Promise with the data; otherwise, we reject the Promise with the error.</p><p>We then define a function displayUserData that calls fetchUserData and displays the user data if the Promise resolves, or an error message if it rejects.</p><p><strong>Promise chaining with error handling? What?</strong></p><pre>const fetchUser = () =&gt; {<br>  return new Promise((resolve, reject) =&gt; {<br>    // Fetch user data from an API<br>    fetch(&#39;https://myapi.com/users/1&#39;)<br>      .then(response =&gt; {<br>        if (response.ok) {<br>          return response.json();<br>        } else {<br>          throw new Error(&#39;Failed to fetch user&#39;);<br>        }<br>      })<br>      .then(data =&gt; resolve(data))<br>      .catch(error =&gt; reject(error));<br>  });<br>};<br><br>const fetchUserPosts = (user) =&gt; {<br>  return new Promise((resolve, reject) =&gt; {<br>    // Fetch user&#39;s posts from an API<br>    fetch(`https://myapi.com/users/${user.id}/posts`)<br>      .then(response =&gt; {<br>        if (response.ok) {<br>          return response.json();<br>        } else {<br>          throw new Error(&#39;Failed to fetch user posts&#39;);<br>        }<br>      })<br>      .then(posts =&gt; resolve(posts))<br>      .catch(error =&gt; reject(error));<br>  });<br>};<br><br>fetchUser()<br>  .then(user =&gt; fetchUserPosts(user))<br>  .then(posts =&gt; console.log(posts))<br>  .catch(error =&gt; console.error(`Error fetching user data: ${error}`));</pre><p>In this example, we define two functions: fetchUser and fetchUserPosts, which return Promises that fetch user data and user posts, respectively, from an API.</p><p>We then chain the Promises together: we first call fetchUser and pass the result to fetchUserPosts, which fetches the user&#39;s posts using the user object. Finally, we log the result of fetchUserPosts to the console.</p><p>If any of the Promises in the chain reject with an error, the error is caught by the catch method and logged to the console.</p><h4>To Conclude:</h4><p>In conclusion, Promises are an essential tool for handling asynchronous operations in JavaScript. They provide a standardized way to handle the results of async operations and make it easier to write clean and maintainable code.</p><p>By using Promises, you can avoid the “callback hell” problem that can arise when using nested callbacks for async operations. Instead, you can chain Promises together and handle the results in a more readable and intuitive way.</p><p>Promises also provide a way to handle errors in async operations. By using the catch method, you can handle errors in a centralized way and avoid the need for complex error handling in multiple parts of your code.</p><p>In addition, Promises can be combined with other features of JavaScript, such as async/await, to create even more powerful and expressive code.</p><p>Overall, Promises are a powerful and essential feature of modern JavaScript development. By mastering Promises, you can write more readable, maintainable, and robust code for your projects.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a0fd089b02b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unleashing the Power of Google Chrome DevTools Performance Tab for Faster Web Performance]]></title>
            <link>https://aniketbatabyal.medium.com/unleashing-the-power-of-google-chrome-devtools-performance-tab-for-faster-web-performance-21ffa56b4ed6?source=rss-15df93944557------2</link>
            <guid isPermaLink="false">https://medium.com/p/21ffa56b4ed6</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Aniket Batabyal]]></dc:creator>
            <pubDate>Sun, 19 Feb 2023 06:34:59 GMT</pubDate>
            <atom:updated>2023-02-19T06:34:59.541Z</atom:updated>
            <content:encoded><![CDATA[<p>You still haven’t seen everything yet!</p><p>In today’s digital world, website performance is a crucial aspect of user experience. Slow website performance can lead to high bounce rates, lost revenue, and a negative brand image. Fortunately, Google Chrome DevTools Performance Tab provides developers with the necessary tools to optimize website performance. In this blog, we’ll explore how to use Chrome DevTools Performance Tab to improve website performance.</p><h4><strong>Understanding the Chrome DevTools Performance Tab</strong></h4><p>The Performance Tab in Chrome DevTools allows developers to analyze and measure website performance. It provides a timeline of website activities such as script execution, layout and paint, rendering, and networking. The timeline displays a detailed breakdown of each activity, allowing developers to identify performance bottlenecks.</p><h4><strong>Using the Performance Tab to Optimize Website Performance</strong></h4><p>There are several ways to use the Performance Tab to optimize website performance. Some of the most effective methods include:</p><ul><li><em>Using the Timeline</em>: The Timeline section in the Performance Tab provides a visual representation of the website’s performance.<br>Developers can use the Timeline to identify performance bottlenecks and optimize the website’s loading speed.</li><li><em>Network Analysis</em>: The Network section in the Performance Tab provides detailed information about the website’s network activity. Developers can use this information to optimize the website’s resource loading, reduce unnecessary requests, and improve overall website performance.</li><li><em>CPU Profiling</em>: The CPU section in the Performance Tab provides detailed information about the website’s CPU usage. Developers can use this information to identify performance bottlenecks caused by inefficient code and optimize the website’s performance.</li></ul><h4><strong>Best Practices for Using the Performance Tab</strong></h4><p>To get the most out of the Performance Tab, it’s essential to follow some best practices. These include:</p><ul><li>Start with a Clean Slate: To get accurate performance measurements, it’s essential to start with a clean slate. This means clearing the browser cache, disabling browser extensions, and running the website on a fresh instance of the browser.</li><li>Use a Real-World Connection: It’s essential to test website performance using a real-world connection speed. This allows developers to optimize the website’s performance for real-world users.</li><li>Emulate Mobile Devices: With mobile devices accounting for over half of all internet traffic, it’s crucial to optimize website performance for mobile devices. Using the Performance Tab’s device emulation feature, developers can simulate the performance of different mobile devices and optimize the website’s performance accord</li></ul><p><strong>Conclusion</strong></p><p>In conclusion, the Chrome DevTools Performance Tab is a powerful tool that can help developers optimize website performance. By using the Performance Tab to analyze website performance, developers can identify and fix performance bottlenecks, reducing website loading times, and improving user experience. By following best practices and using the Performance Tab’s features, developers can unleash the full potential of the Chrome DevTools Performance Tab for faster web performance.</p><p>Read the resources to know more in depth about the topic, it’s well structured and well maintained.</p><p>Try it yourself!</p><p><a href="https://developer.chrome.com/docs/devtools/performance/#get-started">https://developer.chrome.com/docs/devtools/performance/#get-started</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21ffa56b4ed6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Navigate Your Way Through Web Development]]></title>
            <link>https://aniketbatabyal.medium.com/navigate-your-way-through-web-development-da122765e1bd?source=rss-15df93944557------2</link>
            <guid isPermaLink="false">https://medium.com/p/da122765e1bd</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Aniket Batabyal]]></dc:creator>
            <pubDate>Wed, 15 Feb 2023 04:38:29 GMT</pubDate>
            <atom:updated>2023-02-15T04:58:05.515Z</atom:updated>
            <content:encoded><![CDATA[<p>The Power of JavaScript’s Navigator Object</p><figure><img alt="Javascript navigator" src="https://cdn-images-1.medium.com/max/1024/1*yj6ScmfpG6-7ohMYMl0NVA.png" /><figcaption>Navigate it through!</figcaption></figure><blockquote>“Have you ever gone on a treasure hunt? Sometimes, you need a map to find your treasure. A navigator in JavaScript is like a map for your computer. It helps your computer find things on the internet, like websites and pictures. It’s like a guide that shows your computer where to go!”</blockquote><h4>What the hell is a navigator?</h4><p>The navigator object is a built-in object in JavaScript that provides information about the user’s web browser and operating system. This object is available in all modern web browsers, including Google Chrome, Mozilla Firefox, and Microsoft Edge.</p><p>Some of the most common properties and methods of the navigator object include:</p><ul><li><strong>userAgent</strong>: This property returns a string that contains information about the user’s web browser, such as its name and version.</li></ul><pre>console.log(navigator.userAgent);</pre><ul><li><strong>platform</strong>: This property returns a string that describes the user’s operating system, such as Windows or macOS.</li></ul><pre>console.log(navigator.platform);</pre><ul><li><strong>cookieEnabled</strong>: This property returns a Boolean value indicating whether or not the user’s web browser is set up to accept cookies.</li></ul><pre>console.log(&quot;Cookies enabled: &quot; + navigator.cookieEnabled);</pre><ul><li><strong>geolocation</strong>: This property provides access to the user’s current location, if the user has granted permission to access their geolocation.</li></ul><pre>navigator.geolocation.getCurrentPosition(function(position) {<br>  console.log(&quot;Latitude: &quot; + position.coords.latitude);<br>  console.log(&quot;Longitude: &quot; + position.coords.longitude);<br>});</pre><ul><li><strong>language</strong>: This property returns a string that specifies the user’s preferred language for web content.</li></ul><pre>// languages: gives all of the supported languages (list)<br>// language: give the current set language<br>console.table({ languages: navigator.languages, language: navigator.language})</pre><ul><li><strong>screen</strong>: This will display the dimensions of the user’s screen, in pixels.</li></ul><pre>console.log(&quot;Screen resolution: &quot; + screen.width + &quot;x&quot; + screen.height);</pre><h4>Conclusion</h4><p>The Navigator interface represents the state and the identity of the user agent. It allows scripts to query it and to register themselves to carry on some activities.A Navigator object can be retrieved using the read-only <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/navigator">window.navigator</a> property.</p><p>The most common uses are in service workers &amp; to check if the internet connection is available or not.</p><p>P.S: check out <a href="https://developer.mozilla.org/en-US/docs/Web/API/Navigator">https://developer.mozilla.org/en-US/docs/Web/API/Navigator</a> (SUPRISE!!)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da122765e1bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Supercharge Your JavaScript with Web Workers]]></title>
            <link>https://aniketbatabyal.medium.com/how-to-supercharge-your-javascript-with-web-workers-a-beginners-guide-36acf8d6b17f?source=rss-15df93944557------2</link>
            <guid isPermaLink="false">https://medium.com/p/36acf8d6b17f</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Aniket Batabyal]]></dc:creator>
            <pubDate>Tue, 14 Feb 2023 12:06:19 GMT</pubDate>
            <atom:updated>2023-02-14T13:09:53.680Z</atom:updated>
            <content:encoded><![CDATA[<h4>A Beginner’s Guide</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eq6Fmi_GyIPTlIUjMCmZPg.png" /><figcaption>Web Worker Image created by using: <a href="https://www.fotor.com/features/ai-image-generator/">https://www.fotor.com/features/ai-image-generator/</a></figcaption></figure><h4>What are Web Workers</h4><p>Web workers are a feature of JavaScript that allows us to execute scripts in the background without blocking the main thread. This is useful when we need to perform long-running tasks that could potentially freeze the user interface, such as complex computations or data processing.</p><p>Web workers are separate JavaScript files that run in their own threads. They are created using the Worker constructor, and they communicate with the main thread using the postMessage() and onmessage methods. In this blog post, we&#39;ll explore how to use web workers in JavaScript with examples and easy-to-understand context for readers over the age of 18.</p><h4>Creating a Web Worker</h4><p>To create a web worker, we need to create a new JavaScript file that will run in the background. For example, let’s create a file called worker.js that calculates the factorial of a given number:</p><pre>// worker.js<br><br>function calculateFactorial(n) {<br>  let result = 1;<br>  for (let i = 2; i &lt;= n; i++) {<br>    result *= i;<br>  }<br>  return result;<br>}<br><br>onmessage = function(event) {<br>  const n = event.data;<br>  const result = calculateFactorial(n);<br>  postMessage(result);<br>};</pre><p>In this file, we define a function that calculates the factorial of a given number. We then listen for messages from the main thread using the onmessage event handler. When we receive a message, we calculate the factorial and send the result back to the main thread using the postMessage() method.</p><p>To use this worker in our main script, we need to create a new instance of the Worker constructor and pass it the path to our worker file:</p><pre>// index.js<br><br>const factorialWorker = new Worker(&#39;worker.js&#39;);<br><br>factorialWorker.postMessage(10);<br><br>factorialWorker.onmessage = function(event) {<br>  const result = event.data;<br>  console.log(`The factorial of 10 is ${result}`);<br>};</pre><p>In this script, we create a new instance of the Worker constructor and pass it in the file path to our worker file.</p><blockquote>Note: Workers need a hosted service to run, and it cannot be run in an html page by only running “[fileName].html”. To make workers work the import statements need to be added the the method needs to be changed</blockquote><pre>const customWorker = new Worker(<br>    new URL(&#39;./worker.js&#39;, import.meta.url),<br>    { type: &#39;module&#39; }<br>);<br><br></pre><p>We then send a message to the worker using the postMessage() method, and listen for messages from the worker using the onmessage event handler. When we receive a message, we log the result to the console.</p><p>Running the above script will output the result to the console: “The factorial of 10 is 3628800”.</p><h4>Limitations of Web Workers</h4><p>While web workers are useful for offloading heavy computational tasks from the main thread, they do have some limitations. For example, web workers cannot access the DOM or any other APIs that are available to the main thread. They also cannot share memory with the main thread, which means that we need to use message passing to communicate between the two threads.</p><p>In addition, <a href="https://caniuse.com/?search=Workers">web workers are not supported in some older browsers</a>. Before using web workers in your application, it’s important to check if they are supported in all the browsers you are targeting.</p><h3>Conclusion</h3><p>Web workers are a powerful feature of JavaScript that allows us to perform long-running tasks in the background without blocking the main thread. They are easy to create and use, and can significantly improve the performance of our applications. However, web workers do have some limitations, and it’s important to keep these in mind when using them in your application.</p><p>I hope this introduction to web workers has been helpful and informative for readers over the world.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36acf8d6b17f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Working in a Product Based Startup]]></title>
            <link>https://aniketbatabyal.medium.com/working-in-a-product-based-startup-1b51f0b7e1f?source=rss-15df93944557------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b51f0b7e1f</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[experience]]></category>
            <category><![CDATA[life]]></category>
            <category><![CDATA[stories]]></category>
            <dc:creator><![CDATA[Aniket Batabyal]]></dc:creator>
            <pubDate>Mon, 13 Apr 2020 12:21:29 GMT</pubDate>
            <atom:updated>2020-04-13T12:21:29.467Z</atom:updated>
            <content:encoded><![CDATA[<h4>A software development engineer trainee version</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gNUu9cV1egYM_ZcxkIDNyA.jpeg" /></figure><p>Hey guys,<br>Those who are just passing out their college or who have their placements starting, trust me! I can feel what you are going through. Those skipping heartbeats, your friends getting placed before you even had the time to blink, well it was a helluva ride!.</p><p>Finally I was there, in the economic capital of India, Mumbai ( or Bombay, as my dad likes to call it) just as excited as ever to join my first ever company, so many questions came to my mind, some answered some better left unspoken…</p><p>Finally the day came and trust me, a startup is all what I always longed for,<br>a cool office , a cool C.T.O and two really talented reporting managers, one was the V.P of the company and another was the director, so be jealous guys!</p><figure><img alt="Feels !!" src="https://cdn-images-1.medium.com/max/450/1*t5jwFhnNbRSefjJSuPrMIQ.gif" /></figure><p>So moving on to the juicy part what every software engineer wants to know,<br>#The_Tech_Stack, well it gets as better with every increasing day, gone were the days when we used R.E.S.T to make API endpoints, where with each project you end up with a hell lot of unnecessary code and came the new hero GraphQl,which follows a simple rule “Just take what you need, i have everything”, along with postgre as its db and hasura as the glue which sticks these two together.</p><p><em>React.js</em> was a hot topic then and still it’s increasing it’s community to the next level, got to learn how to use these to the next level. Got to learn things by doing and not by sitting around and reading about it, after just 2 weeks we were given the responsibility to make a whole dashboard from scratch where we had to make the schema, server side codes and as well as the front-end of it. As nerve racking as it was, we finally produced results after figuring out some things by ourselves and a great help from our mentors.</p><p>And then we got the most awaited, launch party for the v1.0.0 release of our dashboard. We were thrilled, ready to work harder, smarter and stronger and we danced like CRAZYYY!!!</p><p>Guys, trust me, working in a start up has its pros and cons but its pros outweigh the cons by ten folds. At first i was overwhelmed by the sheer learning curve of all the technologies, i was the slowest to learn and that had many setbacks in a fast moving startup like ours. But trust me guys <br>“slow and steady wins the race”, this is always true.<br>Never did I stop believing in myself and worked hard and stuck to learning one thing at a time and after some time hard work started showing it’s colors and after that the learning curve didn’t stop, I make mistakes everyday, i learn from it and i become better everyday.</p><p>P.s Never alter production database schema’s without your higher ups knowing, caused a 6 hour production failure due to that, well there were many other reasons but DO NOT.</p><p>Had a mini heart attack that day :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*anTjEB671b9oKRzjh2AW1Q.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b51f0b7e1f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>