<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Satej Bidvai</title>
    <description>The latest articles on DEV Community by Satej Bidvai (@satejbidvai).</description>
    <link>https://dev.to/satejbidvai</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%2F415888%2F5b8333ba-c205-46ad-aeda-97667e7678ee.jpeg</url>
      <title>DEV Community: Satej Bidvai</title>
      <link>https://dev.to/satejbidvai</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/satejbidvai"/>
    <language>en</language>
    <item>
      <title>Search on steroids: Using regex in VS Code</title>
      <dc:creator>Satej Bidvai</dc:creator>
      <pubDate>Tue, 11 Nov 2025 18:21:43 +0000</pubDate>
      <link>https://dev.to/satejbidvai/search-on-steroids-using-regex-in-vs-code-1698</link>
      <guid>https://dev.to/satejbidvai/search-on-steroids-using-regex-in-vs-code-1698</guid>
      <description>&lt;p&gt;We've all used &lt;code&gt;Command&lt;/code&gt; + &lt;code&gt;Shift&lt;/code&gt; + &lt;code&gt;F&lt;/code&gt;  to search across our codebases. There's a hidden gem here which helps us supercharge our search queries — regex (&lt;strong&gt;Reg&lt;/strong&gt;ular &lt;strong&gt;Ex&lt;/strong&gt;pression) search:&lt;/p&gt;

&lt;p&gt;&lt;a href="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%2Farticles%2Fdk1kwd8o7s3jqjd38o06.png" class="article-body-image-wrapper"&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%2Farticles%2Fdk1kwd8o7s3jqjd38o06.png" alt="Search with regex" width="800" height="132"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's take a look at how can leverage regex to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Find&lt;/strong&gt; (locate patterns that normal search can't detect)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Find &amp;amp; Replace&lt;/strong&gt; (Use &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions/Groups_and_backreferences" rel="noopener noreferrer"&gt;groups and backreferences&lt;/a&gt; in regex to replace patterns)&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Scenario 1: Find
&lt;/h2&gt;

&lt;p&gt;Everything a normal text search can do &lt;strong&gt;+&lt;/strong&gt; stuff like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Find &lt;code&gt;TODO&lt;/code&gt; comments mentioning a specific user - &lt;code&gt;\/\/\s*TODO:.*username&lt;/code&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="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%2Farticles%2Fnopb46p0ce4hu88l8qbi.png" class="article-body-image-wrapper"&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%2Farticles%2Fnopb46p0ce4hu88l8qbi.png" alt="Find TODO comments" width="800" height="315"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Locate all console logs - &lt;code&gt;console\.(log|warn|error)\(&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;and many more…&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Time for an interesting example:&lt;/p&gt;

&lt;h3&gt;
  
  
  Find incorrect usages of dynamic classes in Tailwind
&lt;/h3&gt;

&lt;p&gt;One day you stumble upon this code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;`text-&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;red&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;green&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;-600 text-sm`&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At first glance, it looks fine — but Tailwind can’t understand it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why?&lt;/strong&gt; Tailwind scans your files for exact string matches like &lt;code&gt;text-red-600&lt;/code&gt;, not expressions that dynamically generate class names. It won't see &lt;code&gt;text-${…}&lt;/code&gt; at all and those styles will be ignored. (&lt;a href="https://tailwindcss.com/docs/detecting-classes-in-source-files#dynamic-class-names" rel="noopener noreferrer"&gt;more context&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Here's what the correct code should look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;text-red-600&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;text-green-600&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; text-sm`&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Being a good developer, you decide to find and fix all the instances in your codebase… But how !?&lt;/p&gt;

&lt;h4&gt;
  
  
  Here's what we can do:
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Identify the pattern: The problem boils down to finding all classes which contain "&lt;code&gt;-${&lt;/code&gt;"(which is a hyphen, followed by &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals" rel="noopener noreferrer"&gt;template literals&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use AI to quickly generate a regex&lt;/strong&gt; - &lt;code&gt;"className=\{&lt;/code&gt;[^&lt;code&gt;]*-\$\{[^&lt;/code&gt;]*&lt;code&gt;"&lt;/code&gt; (&lt;em&gt;Apologies to all the 10x devs, sorry, it's hard to remember the syntax&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;Enable regex search (press &lt;code&gt;.*&lt;/code&gt; beside your search input) and search. (_I sometimes forget to do this and wonder what went wrong!)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="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%2Farticles%2F9jy1rf8rwz5zx5ti0q7w.png" class="article-body-image-wrapper"&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%2Farticles%2F9jy1rf8rwz5zx5ti0q7w.png" alt="Search for dynamic classes" width="800" height="226"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Scenario 2: Find and Replace
&lt;/h2&gt;

&lt;p&gt;When you think about  "replacing" text with regex, you may wonder:&lt;/p&gt;

&lt;h3&gt;
  
  
  How is it possible to replace pattern-matched text correctly?
&lt;/h3&gt;

&lt;p&gt;Say you want to find all function names in your code that start with &lt;code&gt;handle&lt;/code&gt;.&lt;br&gt;
You could use this regex: &lt;code&gt;\bhandle\w*\b&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="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%2Farticles%2Fxvwddaaeloi8lw3lb00p.png" class="article-body-image-wrapper"&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%2Farticles%2Fxvwddaaeloi8lw3lb00p.png" alt="Search for " width="800" height="351"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This matches words like &lt;code&gt;handleConnect&lt;/code&gt;, &lt;code&gt;handleDownload&lt;/code&gt;, &lt;code&gt;handleSubmit&lt;/code&gt;, etc.&lt;/p&gt;

&lt;p&gt;Now, suppose you want to rename all these to start with &lt;code&gt;on&lt;/code&gt; instead of &lt;code&gt;handle&lt;/code&gt; —&lt;br&gt;
so &lt;code&gt;handleConnect&lt;/code&gt; becomes &lt;code&gt;onConnect&lt;/code&gt;, &lt;code&gt;handleDownload&lt;/code&gt; becomes &lt;code&gt;onDownload&lt;/code&gt;, etc.&lt;/p&gt;

&lt;p&gt;If you just try replacing everything with &lt;code&gt;"on"&lt;/code&gt; or &lt;code&gt;"onDownload"&lt;/code&gt;, it won’t work.&lt;br&gt;
It’ll overwrite every match with the same thing:&lt;/p&gt;

&lt;p&gt;&lt;a href="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%2Farticles%2Fdqr7meoqgkqj2df05gz8.png" class="article-body-image-wrapper"&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%2Farticles%2Fdqr7meoqgkqj2df05gz8.png" alt="Replace " width="800" height="415"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's not what we want. We need a way to capture and reuse the rest of the word after “handle”.&lt;br&gt;
Let's see how to do that.&lt;/p&gt;

&lt;h3&gt;
  
  
  Groups and Backreferences in Regex
&lt;/h3&gt;

&lt;p&gt;Groups let us capture parts of a pattern which we can then reuse while replacing our text.&lt;br&gt;
We define a group by wrapping the pattern in a parentheses &lt;code&gt;()&lt;/code&gt; .&lt;/p&gt;

&lt;p&gt;Here's how we can use this in our example above:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Find:&lt;/strong&gt; &lt;code&gt;\bhandle(\w+)\b&lt;/code&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This captures whatever comes after &lt;code&gt;handle&lt;/code&gt; (like &lt;code&gt;Connect&lt;/code&gt;, &lt;code&gt;Download&lt;/code&gt;, etc.) inside the parentheses.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Replace:&lt;/strong&gt; &lt;code&gt;on$1&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;$1&lt;/code&gt; refers to the first captured group — the part matched by &lt;code&gt;(\w+)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;(If you had multiple groups, you could access them as &lt;code&gt;$2&lt;/code&gt;, &lt;code&gt;$3&lt;/code&gt;, and so on)&lt;/p&gt;

&lt;p&gt;&lt;a href="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%2Farticles%2Fxus5qdtw1eo8vjn6pa4h.png" class="article-body-image-wrapper"&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%2Farticles%2Fxus5qdtw1eo8vjn6pa4h.png" alt="Replace " width="800" height="411"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is EXACTLY what we wanted!&lt;/p&gt;

&lt;p&gt;I hope this was interesting and you found a way to save a teeny-tiny bit of your time which you can now use to scroll reels :)&lt;/p&gt;

</description>
      <category>vscode</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Why ACID properties matter in database transactions</title>
      <dc:creator>Satej Bidvai</dc:creator>
      <pubDate>Tue, 21 Feb 2023 08:31:00 +0000</pubDate>
      <link>https://dev.to/satejbidvai/why-acid-properties-matter-in-database-transactions-5a65</link>
      <guid>https://dev.to/satejbidvai/why-acid-properties-matter-in-database-transactions-5a65</guid>
      <description>&lt;p&gt;👋 Hey! You might have come across the term 'ACID properties' in your studies. While it's commonly regarded as a topic to mug up for interviews 😶, there's actually a lot more to understand. &lt;/p&gt;

&lt;p&gt;I have tried to provide an overview and touch upon some key concepts that will help you understand the significance of these properties for a database system ⚡️.&lt;/p&gt;




&lt;h3&gt;
  
  
  What is a Transaction? 💰
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A transaction is a group of queries that together make up a unit of work in a database system.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Eg.&lt;/strong&gt; Transferring funds from one bank account to another.&lt;/p&gt;

&lt;p&gt;(Query 1) Deduct money from the source account&lt;br&gt;
(Query 2) Add money to the destination account&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Atomicity 🎯
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A transaction should be all or nothing - if any part of the transaction fails, the entire transaction should fail and roll back 🚫&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Consistency 🤝
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The correctness of data should be maintained both before and after a transaction is completed ✅&lt;/li&gt;
&lt;li&gt;There are different types of consistency in database systems. Some of them are:

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Data Consistency:&lt;/strong&gt; This is the correctness of the actual data stored in the database. The data should follow a set of rules and constraints. This can be achieved via foreign key constraints, unique constraints, data type constraints, etc.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Application Consistency:&lt;/strong&gt; This is the consistency for the application using the database. It refers to the data displayed to the users, data passed between different systems, etc. This ensures that the application’s output is always correct and reliable.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Eventual Consistency:&lt;/strong&gt; Data stored across multiple nodes and servers will eventually have the same value, but may experience temporary inconsistencies. This is because when data is modified, the change needs to be communicated to all copies of the data.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Isolation  🚧
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Transactions should be executed in isolation from one another, so that each transaction appears to be the only one executing on the database at a given time 👥&lt;/li&gt;
&lt;li&gt;Depending on the isolation level, a transaction may read uncommitted changes which may lead to inconsistencies. Some of these read phenomena are:

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Dirty Reads:&lt;/strong&gt; When a transaction reads data that has not been committed yet. This creates a problem when the uncommitted data is rolled back.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Non-Repeatable Read:&lt;/strong&gt; When a transaction reads the same piece of data multiple times and gets different results each time. This may occur due to modification of data between the reads (Unlike dirty reads, the data has been committed). &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Phantom Read:&lt;/strong&gt; When a transaction reads rows satisfying a condition (e.g. &lt;code&gt;100 &amp;lt; balance &amp;lt; 200&lt;/code&gt;), but a second transaction inserts or deletes a row that also meets the condition, the result may be inconsistent when the same set of rows is read again.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lost Updates:&lt;/strong&gt; When multiple transactions attempt to update the same piece of data concurrently, the updates may be overridden and the data may be lost.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;To fix these read phenomena, various isolation levels are used in database systems:

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Read Uncommitted:&lt;/strong&gt; Transactions can read all changes, even those that have not been committed yet. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Read Committed:&lt;/strong&gt; Transactions can only read committed changes. This solves the “dirty read” phenomena.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Repeatable Read:&lt;/strong&gt; Transactions can read the same piece of data multiple times and get the same results each time. This solves the “non-repeatable read” phenomena, but “phantom reads” may still occur.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Snapshot:&lt;/strong&gt; Transactions read data from a snapshot of the database taken at the start of each transaction. This prevents any modifications by other transactions to be visible in the current transaction. This solves all read phenomena.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Serializable:&lt;/strong&gt; Concurrent transactions are executed in a manner as if they were executed serially, one after the other. This is the highest isolation level.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Durability 💪
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The changes made to the database after a successfull transaction should be persisted even in case of system failures 📉&lt;/li&gt;
&lt;li&gt;Durability can be achieved by WAL (Write Ahead Logging). In this method, the changes to the database are written into a log file before writing to the disk.&lt;/li&gt;
&lt;li&gt;When data needs to be written to a disk, the Operating System (OS) stores it in cache first, then does a bulk write to reduce the number of I/O operations. However, this approach is risky for database systems. To guarantee durability, databases use the &lt;code&gt;fsync()&lt;/code&gt; system call, which forces a write to the disk instead of the OS cache.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>bug</category>
      <category>help</category>
      <category>support</category>
    </item>
    <item>
      <title>Using async-await with arr.map()</title>
      <dc:creator>Satej Bidvai</dc:creator>
      <pubDate>Thu, 12 Jan 2023 19:25:10 +0000</pubDate>
      <link>https://dev.to/satejbidvai/using-async-await-with-arrmap-587f</link>
      <guid>https://dev.to/satejbidvai/using-async-await-with-arrmap-587f</guid>
      <description>&lt;p&gt;While working on a task today, I had to populate my array of objects using my database.&lt;/p&gt;

&lt;p&gt;Instinctively, I used the &lt;code&gt;map&lt;/code&gt; function. The code looked something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;dataList&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;test__1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;test__2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;test__3&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;test__4&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;modifiedList&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;dataList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Get additional properties from DB&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;dataFromDB&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;DataModel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findOne&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;dataFromDB&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;❗️ Did you spot the error?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;👉🏽  In &lt;code&gt;dataList.map()&lt;/code&gt;, we are returning an array of promises and not an array.&lt;br&gt;
👉🏽  Hence, the &lt;code&gt;modifiedList&lt;/code&gt; will look something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="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%2Farticles%2Fyloyomwt0lwwg358aevr.png" class="article-body-image-wrapper"&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%2Farticles%2Fyloyomwt0lwwg358aevr.png" alt="console.log(modifiedList)" width="500" height="212"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  ⚡️ &lt;strong&gt;The Solution?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Simple! We just need to wrap our function with &lt;code&gt;await Promise.all&lt;/code&gt; so that our array of promises is resolved to the desired &lt;code&gt;modifiedList&lt;/code&gt; .&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;modifiedList&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nx"&gt;dataList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Get additional properties from DB&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;dataFromDB&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;DataModel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findOne&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
            &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;
        &lt;span class="p"&gt;});&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;dataFromDB&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>node</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Operating System Notes for Interviews</title>
      <dc:creator>Satej Bidvai</dc:creator>
      <pubDate>Mon, 12 Dec 2022 03:30:42 +0000</pubDate>
      <link>https://dev.to/satejbidvai/operating-system-notes-for-interviews-42n3</link>
      <guid>https://dev.to/satejbidvai/operating-system-notes-for-interviews-42n3</guid>
      <description>&lt;p&gt;These are just for revision and are not exhaustive. You should learn the concepts in depth before following the notes! Do let me know if I have missed any topics :)&lt;/p&gt;

&lt;h1&gt;
  
  
  Overview
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Kernel v/s OS
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Kernel:&lt;/strong&gt; A bridge between the software and hardware of the system.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;OS: A&lt;/strong&gt; system program to provide an interface to the computer user so that they can easily operate on the computer.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Types of OS
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Batch Operating System&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;An operator takes similar jobs and groups them into batches.&lt;/li&gt;
&lt;li&gt;The next job gets assigned only after the previous job is executed.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multiprogramming&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;When the current job is waiting for I/O, another process is assigned to the CPU.&lt;/li&gt;
&lt;li&gt;The CPU is never idle.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multitasking / Time-Sharing&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Fixed time slice for different processes.&lt;/li&gt;
&lt;li&gt;Quick response time.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Distributed Operating System&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Remote access is enabled within the network.&lt;/li&gt;
&lt;li&gt;User has access to files not on his system.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real-Time Operating System&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Complete set of tasks within deadlines.&lt;/li&gt;
&lt;li&gt;eg. Airline traffic control systems&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  Process Management
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Types of Processing
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Preemptive:&lt;/strong&gt; CPU is allocated to processes for a limited time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Non Preemptive:&lt;/strong&gt; CPU is allocated to processes till the process terminates or waits for I/O.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Types of Schedulers
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Long Term Schedulers:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Loads processes from secondary memory to ready queue.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Short Term Scheduler:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Assigns a process from ready queue to the CPU.&lt;/li&gt;
&lt;li&gt;Selects processes according to a scheduling algorithm.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mid Term Scheduler&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Swaps process from main memory to secondary memory.&lt;/li&gt;
&lt;li&gt;It can again swap the process to resume execution.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  System call:  &lt;code&gt;fork()&lt;/code&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Creates a child process&lt;/li&gt;
&lt;li&gt;For ‘n’ &lt;code&gt;fork()&lt;/code&gt; calls:  &lt;code&gt;2^n - 1&lt;/code&gt; child processes are created&lt;/li&gt;
&lt;li&gt;Returns an integer

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;0:&lt;/strong&gt; Child Process&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;+ve:&lt;/strong&gt; Parent Process&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;-ve:&lt;/strong&gt; Error; No process created&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Context Switching
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Saving the context of one process and loading another process.&lt;/li&gt;
&lt;li&gt;Allows multiple processes to share CPU.&lt;/li&gt;
&lt;li&gt;Interrupts cause CPU to switch to a kernel routine from the current task. (Switch done by OS)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Process v/s Threads
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Processes&lt;/th&gt;
&lt;th&gt;User Level Threads&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;System calls&lt;/td&gt;
&lt;td&gt;No System calls&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Own memory space&lt;/td&gt;
&lt;td&gt;Use the memory of parent process&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Do no share data or code&lt;/td&gt;
&lt;td&gt;Share same copy of code and data&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Can be divided into multiple threads&lt;/td&gt;
&lt;td&gt;Smallest unit of execution&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Blocking one process does not affect the other&lt;/td&gt;
&lt;td&gt;Blocking a thread blocks the entire process&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Slow context switching&lt;/td&gt;
&lt;td&gt;Fast context switching&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  User Level v/s Kernel Level Threads
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;User Level Threads&lt;/th&gt;
&lt;th&gt;Kernel Level Threads&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Managed by user level library&lt;/td&gt;
&lt;td&gt;Managed by OS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fast context switching&lt;/td&gt;
&lt;td&gt;Slow context switching&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Blocking a thread blocks the entire process&lt;/td&gt;
&lt;td&gt;Blocking a thread has no affect on other threads&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h1&gt;
  
  
  CPU Scheduling
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Key terms
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Throughput:&lt;/strong&gt; The number of processes that are completed per time unit.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Turnaround Time:&lt;/strong&gt; Sum of the periods spent waiting to get into memory,
waiting in the ready queue, executing on the CPU, and doing I/O.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Arrival Time:&lt;/strong&gt; Time at which a process arrives in the ready queue.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Waiting Time:&lt;/strong&gt; Sum of periods spent waiting in the ready queue.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Burst Time:&lt;/strong&gt; Time required for a process to get executed on the CPU.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Completion Time:&lt;/strong&gt; Time at which a process completes its execution.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Response Time:&lt;/strong&gt; Time from submission of a request till the first response is produced.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;Turn Around Time = Completion Time - Arrival Time&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Waiting Time = Turn Around Time - Burst Time&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Scheduling Algorithms
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;First Come First Serve (FCFS)&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;The process that requests CPU first is allocated the CPU first (FIFO).&lt;/li&gt;
&lt;li&gt;Non preemptive.&lt;/li&gt;
&lt;li&gt;Avg. waiting time varies substantially according to the burst times of the processes.&lt;/li&gt;
&lt;li&gt;Not ideal for for time-sharing systems.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Shortest Job First Scheduling (SJFS)&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;em&gt;Shortest Next CPU Burst Algorithm&lt;/em&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;When the CPU is available, the process that has the smallest CPU burst is assigned first.&lt;/li&gt;
&lt;li&gt;Preemptive or non preemptive&lt;/li&gt;
&lt;li&gt;Preemptive SJFS is also called &lt;em&gt;**Shortest Remaining Time First Scheduling&lt;/em&gt;&lt;em&gt;.&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Problems:

&lt;ul&gt;
&lt;li&gt;Knowing the length of next CPU request.&lt;/li&gt;
&lt;li&gt;Although optimal, cannot be implemented at level of short term scheduling.&lt;/li&gt;
&lt;li&gt;There is no way to know the length of the next CPU burst.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;We expect the next CPU burst to be similar in length to the previous ones.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;3. Priority Scheduling&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A priority is associated with each process, and the CPU is allocated to the process with the highest priority.&lt;/li&gt;
&lt;li&gt;Equal priority processes are scheduled in FCFS order.&lt;/li&gt;
&lt;li&gt;Preemptive or nonpreemptive&lt;/li&gt;
&lt;li&gt;Problem of Indefinite Blocking (Starvation)

&lt;ul&gt;
&lt;li&gt;Solution: Aging (Gradually increasing the priority of processes that wait in the system for a long time)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Round Robin Scheduling (RR)&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Similar to FCFS scheduling, but preemption is added to switch between processes.&lt;/li&gt;
&lt;li&gt;The CPU scheduler goes around the ready queue, allocating the CPU to each process for a time interval of up to 1 time quantum.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Multilevel Queue Scheduling&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Partitions the ready queue into several separate queues.&lt;/li&gt;
&lt;li&gt;The processes are permanently assigned to one queue, generally based on some
property of the process, such as memory size, process priority, or process type.&lt;/li&gt;
&lt;li&gt;Each queue has its own scheduling algorithm.&lt;/li&gt;
&lt;li&gt;In addition, there must be scheduling among the queues, which is commonly
implemented as fixed-priority preemptive scheduling.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Multilevel Feedback Queue Scheduling&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Allows a process to move between queues.&lt;/li&gt;
&lt;li&gt;Separates processes according to the characteristics of their CPU bursts.&lt;/li&gt;
&lt;li&gt;If a process uses too much CPU time, it will be moved to a lower-priority queue.&lt;/li&gt;
&lt;li&gt;This scheme leaves I/O-bound and interactive processes in the higher-priority queues.&lt;/li&gt;
&lt;li&gt;In addition, a process that waits too long in a lower-priority queue may be moved to a higher-priority queue.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h1&gt;
  
  
  Processes Synchronization
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Interprocess Communication (IPC)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Types of Processes
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Independent Process:&lt;/strong&gt; Do not affect / get affected by other processes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cooperating Processes:&lt;/strong&gt; Affect and get affected by other processes.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Shared Memory&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Processes can exchange information by reading and writing to the shared region.&lt;/li&gt;
&lt;li&gt;Memory resides in address space of the process creating the shared memory.&lt;/li&gt;
&lt;li&gt;Other process that want to communicate must attach this to their address space.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Message Passing&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Communication takes place by exchanging messages.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Types of Messages&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fixed:&lt;/strong&gt; Easy &lt;strong&gt;s&lt;/strong&gt;ystem level implementation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Variable:&lt;/strong&gt; Complex system level implementation.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Direct Communication&lt;/strong&gt;

&lt;ol&gt;
&lt;li&gt;Explicitly name the sender or receiver.

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;send(P, message)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;receive(Q, message)&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Explicitly naming only the receiver.

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;send(P, message)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;receive(id, message)&lt;/code&gt; : id is set to name of process with which it is communicating&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Indirect Communication&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Messages are sent and received from a mailbox.&lt;/li&gt;
&lt;li&gt;Mailbox may be owned by a process or the OS.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;send(A, message)&lt;/code&gt; : Send to mailbox A&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;receive(A, message)&lt;/code&gt; : Receive from mailbox A&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Synchronous Communication&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Blocking Send:&lt;/strong&gt; Sending process is blocked until message is received by the mailbox.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Blocking Receive:&lt;/strong&gt; Receiver is blocked until the message is available.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Asynchronous Communication&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Non-blocking Send:&lt;/strong&gt; Sending process sends the message and resumes operation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Non-blocking Receive:&lt;/strong&gt; Receiver retrieves a valid message or NULL. &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Buffers (Queue) can be implemented in 3 ways:

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Zero capacity:&lt;/strong&gt; Blocking send&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bounded capacity:&lt;/strong&gt; Blocking send if queue is full&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unbounded capacity:&lt;/strong&gt; Sender is never blocked&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Synchronization
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Terms
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Race Condition:&lt;/strong&gt; A situation where several processes access and manipulate the same data concurrently and the outcome of the execution depends on the particular order in which the access takes place.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Critical Section Problem
&lt;/h3&gt;

&lt;p&gt;Critical section is a code segment where the shared data can be accessed. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Requirements for solution:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Mutual exclusion:&lt;/strong&gt; Only one process can access the critical section at any time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Progress:&lt;/strong&gt; If a process is not using the critical section, then it should not stop any other process from accessing it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bounded waiting:&lt;/strong&gt; Each process must have a limited waiting time. It should not wait endlessly to access the critical section.&lt;/li&gt;
&lt;/ol&gt;

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

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Lock Variable&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Executed in user mode.&lt;/li&gt;
&lt;li&gt;Applicable for more than two processes also.&lt;/li&gt;
&lt;li&gt;No gurantee for mutual exclusion.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lock&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;lock&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Critical section&lt;/span&gt;

&lt;span class="n"&gt;lock&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Test and Set Lock&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Satisfies mutual exclusion.&lt;/li&gt;
&lt;li&gt;Does not satisfy bounded waiting.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;while&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;TestAndSet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;lock&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

&lt;span class="c1"&gt;// critical section&lt;/span&gt;

&lt;span class="n"&gt;lock&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="n"&gt;boolean&lt;/span&gt; &lt;span class="nf"&gt;TestAndSet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;boolean&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;boolean&lt;/span&gt; &lt;span class="n"&gt;rv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;rv&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Turn Variable&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Runs in user mode.&lt;/li&gt;
&lt;li&gt;Applicable only for two processes.&lt;/li&gt;
&lt;li&gt;Strict Alteration (Alternate turns to execute critical section)
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;turn&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// Critical section.&lt;/span&gt;
&lt;span class="n"&gt;turn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;turn&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// Critical section.&lt;/span&gt;
&lt;span class="n"&gt;turn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Semaphores&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Integer variable used by cooperative processes for synchronization.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Counting Semaphore&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;-∞ to +∞&lt;/li&gt;
&lt;li&gt;Value of semaphore &amp;lt; 0: No. of processes in suspend list&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Value of semaphore ≥ 0: No. of processes that can enter critical section&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Entry Code: P / Wait / Down &lt;/span&gt;
&lt;span class="n"&gt;Wait&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Semaphore&lt;/span&gt; &lt;span class="n"&gt;S&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;S&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;S&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="c1"&gt;// Put process in suspend list&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Exit Code: V / Release / Up / Signal &lt;/span&gt;
&lt;span class="n"&gt;Signal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Semaphore&lt;/span&gt; &lt;span class="n"&gt;S&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="n"&gt;S&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;S&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="c1"&gt;// Wake one process in suspend list&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Binary Semaphore (Mutex)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;0 / 1
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Entry Code: P / Wait / Down &lt;/span&gt;
&lt;span class="n"&gt;Wait&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Semaphore&lt;/span&gt; &lt;span class="n"&gt;S&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;S&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;S&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="c1"&gt;// Put process in suspend list&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Exit Code: V / Release / Up / Signal &lt;/span&gt;
&lt;span class="n"&gt;Signal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Semaphore&lt;/span&gt; &lt;span class="n"&gt;S&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Suspend&lt;/span&gt; &lt;span class="n"&gt;List&lt;/span&gt; &lt;span class="n"&gt;is&lt;/span&gt; &lt;span class="n"&gt;empty&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;S&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="c1"&gt;// Wake one process in suspend list     &lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;/ol&gt;

&lt;h2&gt;
  
  
  Deadlock
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Necessary Conditions&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Mutual Exclusion&lt;/strong&gt; - At least one resource must be in a non sharable mode; that is only one process at a time can use the resource.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No preemption&lt;/strong&gt; - A resource can be released only voluntarily by the process holding it, after that process has completed its task.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hold &amp;amp; Wait&lt;/strong&gt; - A process holding at least one resource is waiting to acquire additional resources held by other processes.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Circular Wait&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;In a single instance RAG (Resource Allocation Graph):

&lt;ul&gt;
&lt;li&gt;Circular wait ⇒ &lt;strong&gt;&lt;em&gt;Deadlock.&lt;/em&gt;&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;No cycle ⇒ &lt;strong&gt;&lt;em&gt;No deadlock.&lt;/em&gt;&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Methods of prevention
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Deadlock Ignorance (Ostrich Method)&lt;/strong&gt; - Ignore the problem and pretend that deadlocks never occur in the system.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Deadlock Prevention&lt;/strong&gt; - At least one of the 4 necessary conditions is prevented.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mutual Exclusion: Make resources shareable&lt;/li&gt;
&lt;li&gt;No preemption: Allow preemption&lt;/li&gt;
&lt;li&gt;Hold and Wait:

&lt;ul&gt;
&lt;li&gt;Must guarantee that whenever a process requests a resource, it does not hold any other resources.&lt;/li&gt;
&lt;li&gt;Require process to request and be allocated all its resources before it begins execution.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Circular Wait: Impose a total ordering of all resource types, and require that each process requests resources in an increasing order of enumeration.&lt;/p&gt;

&lt;p&gt;Eg. A process cannot request resource no. 2 after resource no. 3.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Deadlock Avoidance&lt;/strong&gt; - A decision is made dynamically whether the current resource allocation request will, if granted, potentially lead to a deadlock.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Low device Utilisation&lt;/li&gt;
&lt;li&gt;Reduced system throughput&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Deadlock Detection&lt;/strong&gt; - Deadlock situation may occur. The system may provide:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An algorithm that examines the state of the system to determine whether
a deadlock has occurred.&lt;/li&gt;
&lt;li&gt;An algorithm to recover from the deadlock.&lt;/li&gt;
&lt;li&gt;Banker's Algo (Columns: Allocated, Maximum, Remaining)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Deadlock Free condition:&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;Total Resources + Total Processes &amp;gt; Total Demand&lt;/code&gt; &lt;br&gt;
&lt;code&gt;R &amp;gt; (d1) + (d2 - 1) + ... + (dn - 1)&lt;/code&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Memory Management
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Terms
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Degree of Multiprogramming -&lt;/strong&gt; The number of processes currently in memory.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Internal Fragmentation -&lt;/strong&gt; The memory allocated to a process may be slightly larger than the requested memory. The difference between these two numbers is ***&lt;em&gt;**internal fragmentation *&lt;/em&gt;&lt;em&gt;-&lt;/em&gt;** unused memory that is internal to a partition.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;External fragmentation -&lt;/strong&gt; It exists when there is enough total memory space to satisfy a request but the available spaces are not contiguous: storage is fragmented into a large number of small holes.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Memory Management Techniques
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Contiguous Partitioning
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Fixed Partitioning (Static)&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;No. of partitions are fixed.&lt;/li&gt;
&lt;li&gt;Size of each partition may/may not be same.&lt;/li&gt;
&lt;li&gt;Spanning is not allowed.&lt;/li&gt;
&lt;li&gt;Problems:

&lt;ul&gt;
&lt;li&gt;Limit in process size.&lt;/li&gt;
&lt;li&gt;Limit in degree of multiprogramming.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Internal Fragmentation:&lt;/strong&gt; Diff. between allocated and requested memory.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;External Fragmentation: P&lt;/strong&gt;rocess’s memory request cannot be fulfilled because the memory offered is in a non-contiguous manner.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Variable Partitioning (Dynamic)&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;No internal fragmentation.&lt;/li&gt;
&lt;li&gt;No limit in degree of multiprogramming.&lt;/li&gt;
&lt;li&gt;No limit in process size.&lt;/li&gt;
&lt;li&gt;Problems:

&lt;ul&gt;
&lt;li&gt;External Fragmentation - Must use compaction to shift processes so
they are contiguous and all free memory is in one block.&lt;/li&gt;
&lt;li&gt;Allocation/Deallocation is complex.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dynamic Partitioning Placement Algorithm&lt;/strong&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;First Fit -&lt;/strong&gt; Allocate the first hole that is big enough.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Next Fit -&lt;/strong&gt; Same as first fit but start search from last allocated hole.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Best Fit -&lt;/strong&gt; Allocate the smallest hole that is big enough.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Worst Fit -&lt;/strong&gt;  Allocate the biggest hole. &lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;/li&gt;

&lt;/ol&gt;

&lt;h2&gt;
  
  
  Paging
&lt;/h2&gt;

&lt;p&gt;Memory management technique that allows OS to retrieve processes from secondary storage into main memory.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Logical Address = Page No. + Page Size (Offset)&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Physical Address = Frame no. + Frame Size&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Frame Size = Page Size&lt;/li&gt;
&lt;li&gt;No. of entries in page table = No. of Pages&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Page Table Entry:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Frame No.&lt;/th&gt;
&lt;th&gt;Valid(1) / Invalid(0)&lt;/th&gt;
&lt;th&gt;Protection (RWX)&lt;/th&gt;
&lt;th&gt;Reference (0/1)&lt;/th&gt;
&lt;th&gt;Caching&lt;/th&gt;
&lt;th&gt;Dirty (Modified)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Inverted Paging:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Frame No.&lt;/th&gt;
&lt;th&gt;Page No.&lt;/th&gt;
&lt;th&gt;Process ID&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Some Important Topics
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Thrashing
&lt;/h3&gt;

&lt;p&gt;CPU spends more time swapping or paging activities rather than its execution.&lt;/p&gt;

&lt;h3&gt;
  
  
  Segmentation v/s Paging
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Paging&lt;/th&gt;
&lt;th&gt;Segmentation&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Invisible to programmer&lt;/td&gt;
&lt;td&gt;Visible to programmer&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fixed page size&lt;/td&gt;
&lt;td&gt;Segment sizes may vary&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Faster&lt;/td&gt;
&lt;td&gt;Slower&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;OS need to maintain list of free frames&lt;/td&gt;
&lt;td&gt;OS needs to maintain a list of free holes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Internal fragmentation&lt;/td&gt;
&lt;td&gt;External Fragmentation&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Overlays
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Running a program that is bigger than the size of the physical memory by keeping only those instructions and data that are needed at any given time.&lt;/li&gt;
&lt;li&gt;Divide the program into modules in such a way that not all modules need to be in the memory at the same time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Advantages&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Reduce memory requirement&lt;/li&gt;
&lt;li&gt;Reduce time requirement&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Disadvantages&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Overlap map must be specified by programmer&lt;/li&gt;
&lt;li&gt;Overlapped module must be completely disjoint&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h1&gt;
  
  
  Important Terms
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Zombie Process&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;A process whose execution is completed but it still has an entry in the process table.&lt;/li&gt;
&lt;li&gt;Child processes becomes a zombie before being removed from the process table.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Orphan Process :&lt;/strong&gt; A process whose parent process no more exists i.e. either finished or terminated without waiting for its child process to terminate is called an orphan process.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cascading Termination:&lt;/strong&gt; If the parent process is exiting or terminating then the children process will also get terminated.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Starvation&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;When a process has not been able to get the required resources it needs for progress with its execution for a long period of time.&lt;/li&gt;
&lt;li&gt;Low priority processes get blocked and only high priority processes are executed.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Aging:&lt;/strong&gt; To overcome starvation, increase the priority of processes that wait in the system for resources for a long period of time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Virtual Memory:&lt;/strong&gt; Storage allocation scheme in which secondary memory can be addressed as though it were part of the main memory.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;GeeksForGeeks&lt;/li&gt;
&lt;li&gt;Gate Smashers - &lt;a href="https://www.youtube.com/c/GateSmashers" rel="noopener noreferrer"&gt;YouTube&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Neso Academy - &lt;a href="https://www.youtube.com/c/nesoacademy" rel="noopener noreferrer"&gt;YouTube&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;InterviewBit&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.tutorialspoint.com/" rel="noopener noreferrer"&gt;TutorialsPoint&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>deepseek</category>
      <category>coding</category>
      <category>ai</category>
    </item>
    <item>
      <title>JavaScript for Interviews</title>
      <dc:creator>Satej Bidvai</dc:creator>
      <pubDate>Wed, 07 Dec 2022 22:01:45 +0000</pubDate>
      <link>https://dev.to/satejbidvai/javascript-for-interviews-4k6e</link>
      <guid>https://dev.to/satejbidvai/javascript-for-interviews-4k6e</guid>
      <description>&lt;p&gt;This is my first post/blog/article of any sort, so any feedback will be appreciated.&lt;/p&gt;

&lt;p&gt;These are my notes which I prepared to revise for JavaScript interviews. Some of the topics are advanced but are a must-know for a intermediate JavaScript developer.&lt;/p&gt;




&lt;h2&gt;
  
  
  💪 Basics
&lt;/h2&gt;

&lt;h4&gt;
  
  
  JavaScript is a dynamically typed language
&lt;/h4&gt;

&lt;p&gt;Data type of variables can be changed during runtime&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;justAVariable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;justAVariable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;I am a string now&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="cm"&gt;/* Does not throw any error */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Variables
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Scope&lt;/th&gt;
&lt;th&gt;Can be updated?&lt;/th&gt;
&lt;th&gt;Can be redeclared?&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;var&lt;/td&gt;
&lt;td&gt;FUNCTIONAL&lt;/td&gt;
&lt;td&gt;YES&lt;/td&gt;
&lt;td&gt;YES&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;let&lt;/td&gt;
&lt;td&gt;BLOCK&lt;/td&gt;
&lt;td&gt;YES&lt;/td&gt;
&lt;td&gt;NO&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;const&lt;/td&gt;
&lt;td&gt;BLOCK&lt;/td&gt;
&lt;td&gt;NO&lt;/td&gt;
&lt;td&gt;NO&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  Data Types
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Primitive Values&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Boolean, String, Number, BigInt, Symbol, Null, Undefined&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Objects&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Everything except primitives are of type Object in JS.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  == v/s ===
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;==&lt;/code&gt; checks only for &lt;strong&gt;value&lt;/strong&gt; (type coersion may occur)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;===&lt;/code&gt; checks for both &lt;strong&gt;value&lt;/strong&gt; and &lt;strong&gt;type&lt;/strong&gt; (no type coersion)&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Spread Operator
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Spreads an array into elements.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Spreads an object into key value pairs.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;copyArr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt; &lt;span class="c1"&gt;// copyArr = [1, 2, 3]&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(...&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Equivalent to sum(1, 2, 3)&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;copyObj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt; &lt;span class="c1"&gt;// copyObj = { x: 10 }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Rest Parameter
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Condense elements into an array.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Function can be called using variable no. of arguments.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;condense&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(...&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;condense&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// prints [1, 2, 3, 4]&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;condense&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// prints [1, 2]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🫡 Array Methods
&lt;/h2&gt;

&lt;h4&gt;
  
  
  map() method
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;arr.map((element, index, array) ⇒ { /* Modify element */ })&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="cm"&gt;/* returns a new array with modified elements */&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;double&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;ele&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;ele&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// [2, 4, 6, 8]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  filter() method
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;arr.filter((element, index, array) ⇒ { /* Condition */ })&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="cm"&gt;/* returns a new array whose elements satisfy the condition */&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;evenNumbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;ele&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;ele&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// [2, 4]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  find() method
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;arr.find((element, index, array) ⇒ { /* Condition */ })&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="cm"&gt;/* returns the first element satisfying the condition */&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;greaterThanTwo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;ele&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;ele&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  reduce() method
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;arr.reduce((prevEle, currEle, currIndex, array) ⇒ { /* Code */ }, initialVal)&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="cm"&gt;/* returns a single value - the accumulated result of calling the callback function on each element */&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;prev&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;curr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;prev&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;curr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  ☝️ Hoisting
&lt;/h2&gt;

&lt;p&gt;Function,  variable and class declarations are moved to the top of the scope.&lt;/p&gt;

&lt;h4&gt;
  
  
  Variable Hoisting
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;var&lt;/code&gt; is hoisted and initialized with &lt;code&gt;undefined&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// prints "undefined"&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; are hoisted, but not initialized.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// ReferenceError: b is not defined&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;No hoisting for variables that are not declared.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// ReferenceError: c is not defined&lt;/span&gt;
&lt;span class="nx"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Function Hoisting
&lt;/h4&gt;

&lt;p&gt;Function declarations are hoisted. &lt;strong&gt;(! Arrow functions are not hoisted)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nf"&gt;helloWorld&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Works&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;helloWorld&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello World&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Class Hoisting
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Class declarations are hoisted, but not initialised.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;⚠️ Function and Class expressions are not hoisted.&lt;/p&gt;

&lt;h2&gt;
  
  
  🤝 Closure
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A function and it’s lexical scope together form a closure.&lt;/li&gt;
&lt;li&gt;Due to closures, we can access the outer scope of our function.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If we return a function, it stores the reference to variables and functions in the outer scope even after the outer function is executed.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;outerFunc&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello World&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;str&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;testClosure&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;outerFunc&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nf"&gt;testClosure&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// prints "Hello World"&lt;/span&gt;

&lt;span class="cm"&gt;/* The returned function still remembers the value of str" */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; Only a reference to the variables is stored and not the actual value. So, if you mutate the variable before calling the returned function, it will reflect the updated value.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;outerFunc&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;testClosure&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;outerFunc&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;testClosure&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// prints [2, 1]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  😮‍💨 IIFE (Immediately Invoked Function Expression)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Do not have a name ⇒ &lt;strong&gt;Anonymous&lt;/strong&gt; &lt;strong&gt;function&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Executed just after it is defined.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="cm"&gt;/* Syntax */&lt;/span&gt;

&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){}&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="p"&gt;)();&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){}&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="p"&gt;)();&lt;/span&gt;
&lt;span class="o"&gt;!**&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){}&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="o"&gt;+**&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){}&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="o"&gt;-**&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){}&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Used for keeping data private and exposing selected functions.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;iife&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;getVal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;setVal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;})();&lt;/span&gt;

&lt;span class="nx"&gt;iife&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setVal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;iife&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getVal&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  👩‍👦 Prototypal Inheritance
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;All objects inherit properties with the help of the prototype object.&lt;/p&gt;

&lt;p&gt;eg. Arrays inherit from Array prototype&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The prototype object has a prototype of it’s own. This forms a prototype chain with the last object being null.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The prototype object: &lt;code&gt;__proto__&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;When we try to access something in an object, it first checks the object, then in it’s prototype, then in the prototype’s prototype, etc.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;

&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// We can acces this due to the arr.__proto__.push() method&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  👌 Event Loop
&lt;/h2&gt;

&lt;p&gt;A writeup will take too much time to explain 😅 &lt;br&gt;
&lt;strong&gt;Checkout this video:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/8aGhZQkoFbQ" rel="noopener noreferrer"&gt;What the heck is the event loop anyway? | Philip Roberts | JSConf EU&lt;/a&gt;&lt;/p&gt;

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