<?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: Utsav</title>
    <description>The latest articles on DEV Community by Utsav (@utsavdhall).</description>
    <link>https://dev.to/utsavdhall</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%2F1079643%2Ff84e04da-1702-447f-a782-30882465c20d.png</url>
      <title>DEV Community: Utsav</title>
      <link>https://dev.to/utsavdhall</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/utsavdhall"/>
    <language>en</language>
    <item>
      <title>Django Basics</title>
      <dc:creator>Utsav</dc:creator>
      <pubDate>Fri, 16 Jun 2023 12:29:02 +0000</pubDate>
      <link>https://dev.to/utsavdhall/django-basics-j6o</link>
      <guid>https://dev.to/utsavdhall/django-basics-j6o</guid>
      <description>&lt;h1&gt;
  
  
  Django
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;A brief technical paper describing the workings of The Django framework.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pre-requisites:&lt;/strong&gt; Strong understanding of python. &lt;/p&gt;

&lt;h2&gt;
  
  
  The Settings File
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;What is secret key?&lt;/p&gt;

&lt;p&gt;A secret key is an  important security setting used for cryptographic signing and hashing. It helps protect sensitive information, such as user passwords and session data. The secret key should be kept confidential and should not be shared publicly.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;What are the default Django apps inside it? Are there more?&lt;/p&gt;

&lt;p&gt;You can find them listed in the &lt;code&gt;INSTALLED_APPS&lt;/code&gt; setting in the project's settings module.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;django.contrib.admin&lt;/code&gt;: provides the Django administration interface, which allows you to manage your project's data through a web-based interface.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;django.contrib.auth&lt;/code&gt;:  handles user authentication and provides the necessary models, views, and forms for managing user accounts, passwords, and permissions.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;django.contrib.contenttypes&lt;/code&gt;:  provides a framework for creating, retrieving, and managing content types. It's used by other apps to associate models with permissions and generic relations.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;django.contrib.sessions&lt;/code&gt;: enables session management and allows you to store and retrieve session data for visitors.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;django.contrib.messages&lt;/code&gt;: provides a messaging framework that allows you to store messages for users and display them in a user-friendly way.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;django.contrib.staticfiles&lt;/code&gt;: handles static files (e.g., CSS, JavaScript, images) and collects them in a single location for deployment.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;In addition to these default apps, Django also includes other optional apps that you can choose to include based on your project's requirements. Some of these optional apps include:

`django.contrib.gis`: This app adds geographic information system (GIS) support to Django, allowing you to work with spatial data.

`django.contrib.postgres`: This app includes various features for working with PostgreSQL databases, such as advanced querying capabilities and specific model fields.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;What is middleware? What are different kinds of middleware? Read up a little on each security issue.&lt;/p&gt;

&lt;p&gt;Middleware in Django is a component that sits between the web server and the view function, allowing you to process requests and responses globally. It provides a way to modify or analyze HTTP requests and responses before they reach the view and after they leave the view, respectively&lt;/p&gt;

&lt;p&gt;Django provides several built-in middleware classes, and you can also create your own custom middleware. Here are some of the common types of middleware in Django:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Authentication Middleware&lt;/code&gt;: responsible for associating the user with the request by authenticating the user based on the provided credentials. It sets the request.user attribute, allowing you to identify the user making the request.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Session Middleware&lt;/code&gt;: manages the session data for each visitor and provides the ability to store and retrieve session variables. It enables you to maintain state across multiple requests.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;CSRF Middleware&lt;/code&gt;: Cross Site Request Forgery middleware adds protection against CSRF attacks. It validates that the requests made to your site originate from your forms and protects against unauthorized form submissions.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Security Middleware&lt;/code&gt;: Django provides security middleware classes to enforce various security measures. Some of these classes include XFrameOptionsMiddleware (sets the X-Frame-Options header to prevent clickjacking attacks), ContentSecurityPolicyMiddleware (configures Content Security Policy headers), and SecureReferrerPolicyMiddleware (sets the Referrer-Policy header to control referrer information).&lt;/li&gt;
&lt;/ul&gt;


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

&lt;h2&gt;
  
  
  Django Security
&lt;/h2&gt;

&lt;p&gt;This is a set of measures implemented in Django, to protect web applications from various security threats and vulnerabilities. Here are some key aspects of Django security:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;CSRF protection&lt;/p&gt;

&lt;p&gt;Django provides built-in protection against CSRF attacks. CSRF attacks occur when an attacker tricks a user's browser into making unintended requests on a targeted website. Django includes a CSRF token mechanism that validates requests, ensuring they come from trusted sources.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Cross Site scripting protection&lt;/p&gt;

&lt;p&gt;Django provides built-in protection against CSRF attacks. CSRF attacks occur when an attacker tricks a user's browser into making unintended requests on a targeted website. Django includes a CSRF token mechanism that validates requests, ensuring they come from trusted sources.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Clickjacking protection&lt;/p&gt;

&lt;p&gt;Django includes measures to prevent clickjacking, where an attacker tricks a user into clicking on something malicious without their knowledge. Django supports setting X-Frame-Options headers to control framing of web pages, mitigating clickjacking risks.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  WSGI
&lt;/h2&gt;

&lt;p&gt;The Web Server Gateway Interface is a simple calling convention for web servers to forward requests to web applications.&lt;/p&gt;

&lt;h1&gt;
  
  
  Models
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;ON DELETE CASCADE&lt;/p&gt;

&lt;p&gt;Cascade is used to define the behavior of related records when the referenced record in a parent table is deleted.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;OnDelete&lt;/code&gt; is one of the options available which specifies that if the parent element of the foreign key is deleted, all the related data should be deleted as well, this is done to maintain referential integrity.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Fileds and Validators&lt;/p&gt;

&lt;p&gt;Fields and validators are integral parts of building and managing the database schema and data validation for web applications.&lt;/p&gt;

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

&lt;p&gt;Fields in Django represent the columns or attributes of database tables. They define the type of data that can be stored in a particular column and provide additional metadata about the data. Django offers a wide range of field types, including:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;CharField&lt;/code&gt;: Used for storing strings of a specific length.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;IntegerField&lt;/code&gt;: Stores integer values.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;TextField&lt;/code&gt;: Suitable for storing larger amounts of text.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;BooleanField&lt;/code&gt;: Represents boolean values (True/False).&lt;/p&gt;

&lt;p&gt;&lt;code&gt;DateTimeField&lt;/code&gt;: Stores date and time information.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ForeignKey&lt;/code&gt;: Establishes a relationship between tables, representing a one-to-many relationship.&lt;/p&gt;

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

&lt;p&gt;Validators in Django are functions or classes used to validate user input or data before it is stored in the database. They enforce specific constraints or rules on the data, ensuring its integrity and consistency. Django provides several built-in validators, example:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;RequiredValidator:&lt;/code&gt; Ensures that a field is not empty or null.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;MaxValueValidator/MinValueValidator&lt;/code&gt;: Validates that a numeric value is within specified maximum or minimum limits.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;RegexValidator&lt;/code&gt;: Validates that a field matches a specified regular expression pattern.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;EmailValidator&lt;/code&gt;: Verifies that an input string is a valid email address.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;URLValidator&lt;/code&gt;: Checks that a given string is a valid URL.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Modules vs Classes&lt;/p&gt;

&lt;p&gt;A module in Python is a file that contains Python code, typically with a .py extension. It serves as a container for related functions, classes, and variables that can be reused in different parts of a program.&lt;/p&gt;

&lt;p&gt;A class in Python is a blueprint for creating objects. It is a code template that defines the attributes (data) and methods (functions) that an object of that class can have.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Django ORM
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Using ORM queries in Django Shell&lt;/p&gt;

&lt;p&gt;You can use ORM queries within the django shell to experiment with data.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Activate the Django shell:&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python manage.py shell
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Import necessary models:&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from utsav.models import Whatever
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Perform queries:&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;all_products = Product.objects.all()
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;Turning ORM to SQL in Django Shell&lt;/p&gt;

&lt;p&gt;You can perform the ORM queries and convert them to SQL using the query method. Example:&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    query = Product.objects.filter(price__gte=10).query

    sql=query.get_compiler(using=Product.objects.db).as_sql()

    print(sql)
&lt;/code&gt;&lt;/pre&gt;


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

&lt;p&gt;Aggregation&lt;/p&gt;

&lt;p&gt;Aggregation queries are equivalent to aggregate functions in SQL, they simply perform aggregation on all the records and return a singular value.&lt;/p&gt;


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

&lt;p&gt;Annotate&lt;/p&gt;

&lt;p&gt;Annotations are equivalent to group by statements in SQL, it is used to perform  aggregations on fields based on the same or other fields, For example: Getting the sum of total revenue generated by each employee, where we have a table consisting of each sale by employee.&lt;/p&gt;


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

&lt;p&gt;What is a migration file? Why is it needed?&lt;/p&gt;

&lt;p&gt;Migration file in Django is an autogenerated Python script that defines the changes to be made to the database schema&lt;/p&gt;

&lt;p&gt;Migrations enable version control of your database schema changes. Each migration file represents a specific set of changes to the schema, allowing you to track and revert changes if needed.&lt;/p&gt;


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

&lt;p&gt;What are SQL transactions?&lt;/p&gt;

&lt;p&gt;SQL transactions are units of work performed within a relational database management system. A transaction is a sequence of one or more SQL statements that are executed as a single logical unit. These statements can include queries, updates, inserts, and deletes.&lt;/p&gt;


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

&lt;p&gt;What are atomic transactions?&lt;/p&gt;

&lt;p&gt;If an error occurs during any step of the transaction, the changes made in the previous steps may or may not be rolled back, leaving the database in an inconsistent state.&lt;/p&gt;

&lt;p&gt;Atomic transactions ensure that all operations within a transaction are treated as a single unit, and they are either all successfully applied or none of them are. If any operation within the transaction fails, the changes made in all previous steps are automatically rolled back, maintaining data integrity and consistency.&lt;/p&gt;


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

&lt;h1&gt;
  
  
  References
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://www.geeksforgeeks.org/django-basics/"&gt;Geeks for Geeks&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.djangoproject.com/en/4.2/"&gt;Django Documentation&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>interview</category>
      <category>django</category>
    </item>
    <item>
      <title>JavaScript</title>
      <dc:creator>Utsav</dc:creator>
      <pubDate>Mon, 29 May 2023 07:22:44 +0000</pubDate>
      <link>https://dev.to/utsavdhall/javascript-28mk</link>
      <guid>https://dev.to/utsavdhall/javascript-28mk</guid>
      <description>&lt;p&gt;The aim of this paper is to help the reader understand basic JavaScript concepts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Loops
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;for&lt;/code&gt;: A simple for loop that iterates through elements based on index.&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for(int i=0;i&amp;lt;size;i++){
    //do something here
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;forEach&lt;/code&gt;: This is a "Higher order function" in JavaScript, does not return anything, makes changes within the array.&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;numbers.forEach(function(number) {
console.log(number);
});
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;for .. in&lt;/code&gt; and &lt;code&gt;for .. of&lt;/code&gt;: Both of these loop iterate over things in different ways, &lt;code&gt;for .. in&lt;/code&gt; iterates over the enumerable properties of an object, while &lt;code&gt;for .. of&lt;/code&gt; iterates over the values that the object defines to be iterated over.&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//print key/value pairs of an object.

for(let property in object){
    console.log(property,object[property]);
}
//you won't be able to use "for .. of" loop for a single object
//iterating over an array of objects

for(let value of array){
    console.log(value);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;while&lt;/code&gt;: the while loop is an alternative to standard for loops, both can be used interchangeably.&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let i=0;
while(i&amp;lt;10){
    console.log(i);
    i++;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Mutable and Immutable Methods (in strings and arrays)
&lt;/h3&gt;

&lt;p&gt;Mutable methods modify the original string or array.  Immutable methods return a new string or array, leaving the original unchanged.&lt;br&gt;
 &lt;br&gt;&lt;br&gt;&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Mutable Methods:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;concat&lt;/code&gt;: Concatenates two or more strings and returns the result.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;slice&lt;/code&gt;: Extracts a portion of the string and returns a new string.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;replace&lt;/code&gt;: Replaces specified substring(s) with a new substring and returns a new string.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;toUpperCase&lt;/code&gt; and &lt;code&gt;toLowerCase&lt;/code&gt;: Converts the case of the string and returns a new string.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;trim&lt;/code&gt; and other trimming methods: Removes whitespace characters from the string and returns a new string.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Immutable Methods:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;charAt&lt;/code&gt; and &lt;code&gt;charCodeAt&lt;/code&gt;: Accesses a character or its Unicode value at a specified index.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;substring&lt;/code&gt; and &lt;code&gt;substr&lt;/code&gt;: Extracts a substring from the original string.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;indexOf&lt;/code&gt; and &lt;code&gt;lastIndexOf&lt;/code&gt;: Searches for a substring within the string and returns its index.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Mutable Methods:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;push&lt;/code&gt; and &lt;code&gt;pop&lt;/code&gt;: Add and remove elements from the end of an array.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;shift&lt;/code&gt; and &lt;code&gt;unshift&lt;/code&gt;: Add and remove elements from the beginning of an array.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;splice&lt;/code&gt;: Modifies an array by adding, removing, or replacing elements at specified positions.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;reverse&lt;/code&gt;: Reverses the order of elements in an array.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;sort&lt;/code&gt;: Sorts the elements of an array in place.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Immutable Methods:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;concat&lt;/code&gt;: Concatenates two or more arrays and returns a new array.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;slice&lt;/code&gt;: Extracts a portion of an array and returns a new array.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;filter&lt;/code&gt;: Creates a new array with elements that satisfy a filtering condition.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;map&lt;/code&gt;: Creates a new array by applying a transformation function to each element.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Pass by Reference and Pass by Value
&lt;/h3&gt;

&lt;p&gt;It provides an in-depth analysis of how JavaScript handles variable assignment and function parameter passing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pass by Value&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  In pass by value, a copy of the value is passed to a function or assigned to a new variable.&lt;/li&gt;
&lt;li&gt;  Changes made to the copied value do not affect the original value.&lt;/li&gt;
&lt;li&gt;  Primitive data types (numbers, booleans, strings) are passed by value in JavaScript.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let num = 10;

function increment(num) {
  num += 1;
  console.log(num); // Output: 11
}

increment(num);
console.log(num); // Output: 10
&lt;/code&gt;&lt;/pre&gt;




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

&lt;p&gt;&lt;strong&gt;Pass by Reference&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  In pass by reference, a reference to the original value is passed to a function or assigned to a new variable.&lt;/li&gt;
&lt;li&gt;  Changes made to the referenced value affect the original value.&lt;/li&gt;
&lt;li&gt;  Objects and arrays are passed by reference in JavaScript.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    let arr = [1, 2, 3];

function modifyArray(arr) {
  arr.push(4);
  console.log(arr); // Output: [1, 2, 3, 4]
}

modifyArray(arr);
console.log(arr); // Output: [1, 2, 3, 4]
&lt;/code&gt;&lt;/pre&gt;

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

&lt;h3&gt;
  
  
  Array Methods:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Basics&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;   Array.pop&lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;The &lt;code&gt;pop&lt;/code&gt; method removes the last element from an array and returns that element.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;```
const fruits = ["apple", "banana", "orange"];

const removedFruit = fruits.pop();

console.log(fruits); // Output: ["apple", "banana"]

console.log(removedFruit); // Output: "orange"
```
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

    The `push` method adds one or more elements to the end of an array and returns the new length of the array.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;```
    const fruits = ["apple", "banana"];
    const newLength = fruits.push("orange", "grape");
    console.log(fruits); // Output: ["apple", "banana",   "orange", "grape"]
    console.log(newLength); // Output: 4
```
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

    The `concat` method combines two or more arrays and returns a new array.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;```
const arr1 = [1, 2, 3];
const arr2 = [4, 5];
const combinedArray = arr1.concat(arr2);
console.log(combinedArray); // Output: [1, 2, 3, 4, 5]

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

&lt;/div&gt;



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

    The `slice` method extracts a portion of an array into a new array.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;```
const numbers = [1, 2, 3, 4, 5];
const slicedArray = numbers.slice(1, 4);
console.log(slicedArray); // Output: [2, 3, 4]

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

&lt;/div&gt;



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

    The `splice` method changes the content of an array by removing, replacing, or adding elements.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;```
const numbers = [1, 2, 3, 4, 5];
const removedElements = numbers.splice(2, 2, 6, 7);
console.log(numbers); // Output: [1, 2, 6, 7, 5]
console.log(removedElements); // Output: [3, 4]

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

&lt;/div&gt;



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

    The `join` method combines all elements of an array into a string.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;```
const fruits = ["apple", "banana", "orange"];
const joinedString = fruits.join(", ");
console.log(joinedString); // Output: "apple, banana, orange"

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

&lt;/div&gt;



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

    The `flat` method creates a new array with all sub-array elements concatenated recursively up to the specified depth.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;```
const nestedArray = [1, 2, [3, 4, [5, 6]]];
const flattenedArray = nestedArray.flat(2);
console.log(flattenedArray); // Output: [1, 2, 3, 4, 5,]

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Searching Functions:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Array.find:&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;find&lt;/code&gt; method returns the first element in an array that satisfies a provided testing function.If a matching element is found, &lt;code&gt;find&lt;/code&gt; returns the element itself; otherwise, it returns &lt;code&gt;undefined&lt;/code&gt;.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
`   const numbers = [1, 2, 3, 4, 5];
const foundNumber = numbers.find((num) =&amp;gt; num &amp;gt; 3);
console.log(foundNumber); // Output: 4` 
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Array.indexOf:&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;indexOf&lt;/code&gt; method returns the first index at which a specified element is found in an array.&lt;br&gt;
If the element is not found, it returns -1.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const fruits = ["apple", "banana", "orange"];
const index = fruits.indexOf("banana");
console.log(index); // Output: 1` 
&lt;/code&gt;&lt;/pre&gt;

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


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

&lt;p&gt;Array.includes:&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;includes&lt;/code&gt; method determines whether an array includes a certain element, returning a boolean value.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt; ```
`const numbers = [1, 2, 3, 4, 5];
const includesThree = numbers.includes(3);
console.log(includesThree); // Output: true` 
```
&lt;/code&gt;&lt;/pre&gt;




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

&lt;p&gt;Array.findIndex:&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;findIndex&lt;/code&gt; method returns the index of the first element in an array that satisfies a provided testing function.&lt;br&gt;
Example:&lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
    `const numbers = [1, 2, 3, 4, 5];
    const index = numbers.findIndex((num) =&amp;gt; num &amp;gt; 3);
    console.log(index); // Output: 3` 
    ```

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


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

&lt;p&gt;&lt;strong&gt;Higher Order Function&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Array.forEach:&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;forEach&lt;/code&gt; method executes a provided callback function once for each element in an array.&lt;br&gt;
The callback function takes three arguments: the current element, the index, and the array itself.&lt;br&gt;
 Example:&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const numbers = [1, 2, 3, 4, 5];
numbers.forEach((num) =&amp;gt; {
  console.log(num * 2);
});
// Output:
// 2
// 4
// 6
// 8
// 10
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Array.filter:&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;filter&lt;/code&gt; method creates a new array with all elements that pass a provided filtering function.&lt;br&gt;
The filtering function takes three arguments: the current element, the index, and the array itself.&lt;br&gt;
&lt;br&gt;&lt;br&gt;
  Example:&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    const numbers = [1, 2, 3, 4, 5];
    const evenNumbers = numbers.filter((num) =&amp;gt; num % 2 ===  0);
    console.log(evenNumbers); // Output: [2, 4]
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Array.map:&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;map&lt;/code&gt; method creates a new array with the results of calling a provided function on every element in the array.&lt;br&gt;
The mapping function takes three arguments: the current element, the index, and the array itself.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const numbers = [1, 2, 3, 4, 5];
const doubledNumbers = numbers.map((num) =&amp;gt; num * 2);
console.log(doubledNumbers); // Output: [2, 4, 6, 8, 10]
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Array.reduce:&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;reduce&lt;/code&gt; method applies a provided function to reduce the array to a single value.&lt;br&gt;
The reducing function takes four arguments: the accumulator, the current element, the index, and the array itself.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const numbers = [1, 2, 3, 4, 5];
const sum = numbers.reduce((accumulator, num) =&amp;gt; accumulator + num, 0);
console.log(sum); // Output: 15` 
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Array.sort:&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;sort&lt;/code&gt; method sorts the elements of an array in place and returns the sorted array.&lt;br&gt;
  Example:&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const fruits = ["banana", "apple", "orange"];
fruits.sort();
console.log(fruits); // Output: ["apple", "banana", "orange"]
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Advanced&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;   Array methods chaining&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can chain up methods instead of calling them separately.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const numbers = [1, 2, 3, 4, 5];

const result = numbers
.filter(num =&amp;gt; num % 2 === 0)  // Filter even numbers
.map(num =&amp;gt; num * 2)           // Double each number
.reduce((sum, num) =&amp;gt; sum + num, 0);  // Calculate the sum

console.log(result);  // 18
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  String Methods
&lt;/h3&gt;

&lt;p&gt;Mutable Methods (Modify the original string):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;concat&lt;/code&gt;: Concatenates one or more strings with the original string and returns a new string.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;slice&lt;/code&gt;: Extracts a portion of the string into a new string based on the specified indices.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;splice&lt;/code&gt;: Changes the content of the string by adding, removing, or replacing characters.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;replaceAll&lt;/code&gt;: Replaces all occurrences of a specified substring with another substring.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;toUpperCase&lt;/code&gt;: Converts the string to uppercase characters.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;toLowerCase&lt;/code&gt;: Converts the string to lowercase characters.&lt;br&gt;
&lt;br&gt;&lt;br&gt;
Example:-&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let char = str.charAt(0);
console.log(char); // Output: "H"

let substring = str.substring(0, 5);
console.log(substring); // Output: "Hello"

let replacedFirstOccurrence = str.replace("o", "x");
console.log(replacedFirstOccurrence); // Output: "Hxllo World"

let splittedArray = str.split(" ");
console.log(splittedArray); // Output: ["Hello", "World"]

let trimmedStr = str.trim();
console.log(trimmedStr); // Output: "Hello World"

let startsWithHello = str.startsWith("Hello");
console.log(startsWithHello); // Output: true

let endsWithWorld = str.endsWith("World");
console.log(endsWithWorld); // Output: true
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Immutable Methods (Create a new string without modifying the original string):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;charAt&lt;/code&gt;: Returns the character at a specified index in the string.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;substring&lt;/code&gt;: Extracts a portion of the string into a new string based on the specified indices.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;replace&lt;/code&gt;: Replaces the first occurrence of a specified substring with another substring.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;split&lt;/code&gt;: Splits the string into an array of substrings based on a specified delimiter.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;trim&lt;/code&gt;: Removes whitespace from both ends of the string.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;startsWith&lt;/code&gt;: Checks if the string starts with a specified substring.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;endsWith&lt;/code&gt;: Checks if the string ends with a specified substring.&lt;br&gt;
Example:-&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let char = str.charAt(0);
console.log(char); // Output: "H"

let substring = str.substring(0, 5);
console.log(substring); // Output: "Hello"

let replacedFirstOccurrence = str.replace("o", "x");
console.log(replacedFirstOccurrence); // Output: "Hxllo World"

let splittedArray = str.split(" ");
console.log(splittedArray); // Output: ["Hello", "World"]

let trimmedStr = str.trim();
console.log(trimmedStr); // Output: "Hello World"

let startsWithHello = str.startsWith("Hello");
console.log(startsWithHello); // Output: true

let endsWithWorld = str.endsWith("World");
console.log(endsWithWorld); // Output: true
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Object Methods and Opertions
&lt;/h3&gt;

&lt;p&gt;Adding or Modifying Key-Value Pairs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;object[key] = value&lt;/code&gt;: Assigns a value to a specific key in the object. If the key already exists, the value will be updated; otherwise, a new key-value pair will be added.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Accessing Values:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;object[key]&lt;/code&gt;: Retrieves the value associated with a specific key from the object.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Checking for Key Existence:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;key in object&lt;/code&gt;: Returns &lt;code&gt;true&lt;/code&gt; if the object contains the specified key; otherwise, returns &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;object.hasOwnProperty(key)&lt;/code&gt;: Returns &lt;code&gt;true&lt;/code&gt; if the object directly contains the specified key (ignores keys from the prototype chain); otherwise, returns &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Removing Key-Value Pairs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;delete object[key]&lt;/code&gt;: Removes the key-value pair associated with the specified key from the object.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Getting All Keys:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;Object.keys(object)&lt;/code&gt;: Returns an array containing all the keys of the object.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Getting All Values:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;Object.values(object)&lt;/code&gt;: Returns an array containing all the values of the object.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Getting Key-Value Pairs as Arrays:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;Object.entries(object)&lt;/code&gt;: Returns an array of key-value pairs, where each pair is represented as an array &lt;code&gt;[key, value]&lt;/code&gt;.&lt;br&gt;
Example:-&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    const hashmap = {};

    // Adding key-value pairs
    hashmap["name"] = "John";
    hashmap["age"] = 30;
    hashmap["city"] = "New York";

    // Accessing values
    console.log(hashmap["name"]); // Output: John

    // Checking for key existence
    console.log("age" in hashmap); // Output: true
    console.log(hashmap.hasOwnProperty("gender")); // Output: false

    // Removing key-value pair
    delete hashmap["city"];

    // Getting all keys
    const keys = Object.keys(hashmap);
    console.log(keys); // Output: ['name', 'age']

    // Getting all values
    const values = Object.values(hashmap);
    console.log(values); // Output: ['John', 30]

    // Getting key-value pairs as arrays
    const entries = Object.entries(hashmap);
    console.log(entries); // Output: [['name', 'John'], ['age', 30]]
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;Hoisting is a mechanism in JavaScript that allows variable and function declarations to be moved to the top of their respective scopes during the compilation phase, before the code is executed.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Only function declarations and variable declarations using &lt;code&gt;var&lt;/code&gt; are hoisted.&lt;/li&gt;
&lt;li&gt;  Variables declared with &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; are not hoisted.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Example:-&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(x); // Output: undefined
var x = 10;
console.log(x); // Output: 10
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Scopes
&lt;/h3&gt;

&lt;p&gt;Scopes in JavaScript determine the accessibility and visibility of variables, functions, and objects within your code. JavaScript has three main types of scopes:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Global Scope&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  The global scope is the outermost scope in JavaScript.&lt;/li&gt;
&lt;li&gt;  Variables declared in the global scope are accessible throughout the entire codebase, including within functions and other scopes.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var globalVariable = "I'm in the global scope";

function globalFunction() {
    console.log(globalVariable); // Output: "I'm in the global scope"
}

globalFunction();
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Function Scope&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;Variables declared within a function are only accessible within that function and any nested functions.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function outerFunction() {
        var outerVariable = "I'm in the outer function";

        function innerFunction() {
        console.log(outerVariable); // Output: "I'm in the outer function"
        }

        innerFunction();
    }

    outerFunction();
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Block Scope (Introduced in ES6):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Block scope is created by curly braces (&lt;code&gt;{}&lt;/code&gt;) in statements such as &lt;code&gt;if&lt;/code&gt;, &lt;code&gt;for&lt;/code&gt;, &lt;code&gt;while&lt;/code&gt;, and &lt;code&gt;let&lt;/code&gt;/&lt;code&gt;const&lt;/code&gt; variable declarations.&lt;/li&gt;
&lt;li&gt;  Variables declared with &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; are block-scoped and are only accessible within the block where they are defined.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function blockScopeExample() {
    if (true) {
    let blockVariable = "I'm in the block scope";
    console.log(blockVariable); // Output: "I'm in the block scope"
    }

    console.log(blockVariable); // Output: ReferenceError: blockVariable is not defined
}

blockScopeExample();
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;A closure is a function along with its preserved lexical environment.&lt;br&gt;
Here are some key points about closures:&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;  A closure is created when a nested function (inner function) accesses variables from its outer function, even after the outer function has completed execution.&lt;/li&gt;
&lt;li&gt;  The inner function "closes over" the variables it references, hence the term "closure".&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Lexical Scope:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Closures rely on lexical scoping, which means that functions are executed using the variable scope they were defined in.&lt;/li&gt;
&lt;li&gt;  The inner function has access to the variables in its own scope, the scope of the outer function, and the global scope.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Preserved Environment:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Closures preserve the variables and their values at the time of creation, allowing the inner function to access and manipulate them even outside of the original scope.&lt;/li&gt;
&lt;li&gt;  This allows for data encapsulation and private variables in JavaScript.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Examples&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    function outerFunction() {&lt;br&gt;
        var outerVariable = 'I am from the outer function';
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    function innerFunction() {
    console.log(outerVariable); // Accesses outerVariable from the outer function's scope
    }

    return innerFunction;
}

var closure = outerFunction(); // Assigns the inner function to the closure variable
closure(); // Invokes the inner function, which logs "I am from the outer function"
&lt;/code&gt;&lt;/pre&gt;

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

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Higher Order Functions&lt;br&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Higher-order functions can accept other functions as parameters.&lt;/li&gt;
&lt;li&gt;  The passed function is often referred to as a "callback" function.&lt;/li&gt;
&lt;li&gt;  This allows for the implementation of customizable behavior or logic.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function higherOrder(callback) {
callback();
}

function callbackFunction() {
console.log("I'm a callback function");
}

higherOrder(callbackFunction); // Outputs: "I'm a callback function"
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  References
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.geeksforgeeks.org/javascript/"&gt;JavaScript(GeeksForGeeks)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.w3schools.com/js/js_object_definition.asp"&gt;JavaScript Objects(W3 Schools)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript"&gt;Mozilla Documentation&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>HTML and CSS</title>
      <dc:creator>Utsav</dc:creator>
      <pubDate>Thu, 18 May 2023 09:05:52 +0000</pubDate>
      <link>https://dev.to/utsavdhall/html-and-css-12hm</link>
      <guid>https://dev.to/utsavdhall/html-and-css-12hm</guid>
      <description>&lt;p&gt;This paper on HTML and CSS aims to help the reader understand various concepts required for effective and efficient use of css&lt;/p&gt;

&lt;h2&gt;
  
  
  Basic concepts in HTML
&lt;/h2&gt;

&lt;p&gt;Let's go through all the major tags in HTML:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;&amp;lt;html&amp;gt;&lt;/code&gt;: Defines the root of an HTML document.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;&amp;lt;title&amp;gt;&lt;/code&gt;: Used to define the title of the HTML document, it is displayed on the title bar of the page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;&amp;lt;h1&amp;gt; to &amp;lt;h6&amp;gt;&lt;/code&gt;: Define headings for the webpage, &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; is the largest of them, &lt;code&gt;&amp;lt;h6&amp;gt;&lt;/code&gt; is the smallest.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;&amp;lt;br&amp;gt;&lt;/code&gt;: Defines a line break in the webpage.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;: Defines paragraphs in the webpage.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;&amp;lt;link&amp;gt;&lt;/code&gt;: Defines the relationship between a document and an external file (most used to link to style sheets).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt;: Defines CSS within the HTML file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt;: Defines JavaScript code within the HTML file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt;: The &lt;strong&gt;Anchor tag&lt;/strong&gt; is used to define hyperlinks, linking one page to another. It has several attributes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;download&lt;/code&gt;: Specifies that the provided target will be downloaded upon being clicked.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;href&lt;/code&gt;: Clicking will redirect you to the specified webpage.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;target&lt;/code&gt;: Specifies where to open the link (target="__blank" will open the link in a new tab).&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;&amp;lt;ul&amp;gt;, &amp;lt;ol&amp;gt; and &amp;lt;li&amp;gt;&lt;/code&gt;: These tags are used to define lists, &lt;code&gt;&amp;lt;ol&amp;gt;&lt;/code&gt; is for ordered lists while &lt;code&gt;&amp;lt;ul&amp;gt;&lt;/code&gt; defines unordered lists, &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt; are individual elements in the the defined list.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;: Defines a division or section in an HTML document. It is a versatile tag used to group and style other elements together. The user can give it properties via classes or ids.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt;: Used to define images in HTML webpage, The &lt;code&gt;src&lt;/code&gt; attribute is used to link the image.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;&amp;lt;label&amp;gt;&lt;/code&gt;: Used to define name/label for input elements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt;: defines a span of text within a document. It is typically used to apply styles or target specific sections of content for scripting purposes.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The HTML document describes the skeleton of our webpage, the design responsibility lies with CSS.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Box Model
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Every element on a page is a rectangle&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---W1YNcL1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://media.gcflearnfree.org/content/5ef2084faaf0ac46dc9c10be_06_23_2020/box_model.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---W1YNcL1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://media.gcflearnfree.org/content/5ef2084faaf0ac46dc9c10be_06_23_2020/box_model.png" alt="Box Model Representation" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The image above is a representation of the box model, as you can see, the total size of the box is much more than what you'd expect.&lt;/p&gt;

&lt;p&gt;Formula for total width of the box:-&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;padding= (padding-left+padding-right)
border= (border-left+border-right)
margin=(margin-left+margin-right)

total width=width+padding+border+margin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You can further intuit what the the formula for height would be.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Padding:&lt;/strong&gt; is to adjust the contents within a container.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Margin&lt;/strong&gt; is used to adjust the container with respect to its sibling elements.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Inline vs Block Elements
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Block Elements:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A block-level element always starts on a new line, and the browsers automatically add some margin before and after the element.&lt;/li&gt;
&lt;li&gt;Block elements always occupy the maximum available width by default.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Inline Elements:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Inline elements don't start in a newline.&lt;/li&gt;
&lt;li&gt;These elements only take up the necessary amount of width.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Positioning: Relative/Absolute
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;position&lt;/code&gt; attribute has a lot of possible values, we'll just be talking about &lt;code&gt;relative&lt;/code&gt; and &lt;code&gt;absolute&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;relative&lt;/code&gt;: positioned elements allow us to use &lt;code&gt;left&lt;/code&gt;,&lt;code&gt;top&lt;/code&gt;,&lt;code&gt;right&lt;/code&gt; and &lt;code&gt;bottom&lt;/code&gt; attributes, these attributes adjust the position of the element relative to it's normal position.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;absolute&lt;/code&gt;: same as relative, but this time the object is positioned relative to its nearest relative or absolute ancestor.&lt;/p&gt;

&lt;h2&gt;
  
  
  In the flow / Out of flow.
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It is important to understand the flow of elements within a container when you're adjusting them.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Elements that are in the flow change their surrounds(sibling elements) when they are adjusted in position, and they're also affected when their surroundings change.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Out of flow elements are unaffected by their surroundings as they are positioned relatively to their ancestor, they overlap other elements and can be individually placed anywhere. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Fixed and absolute positions take an element out of flow.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;absolute&lt;/code&gt; is very useful when you're dealing with overlapping elements.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Common CSS pseudo classes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;In this section we'll be dealing with &lt;strong&gt;pseudo selectors&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Pseudo selectors are used to select child elements based on a pattern.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;:first-child&lt;/code&gt; selects the first child within an element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;:nth-child[n]&lt;/code&gt;: used to select a sequence of child elements based on a pattern. for example:&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.class:nth-child[2n+1]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The code above will select 3&lt;sup&gt;rd&lt;/sup&gt;,5&lt;sup&gt;th&lt;/sup&gt;,7&lt;sup&gt;th&lt;/sup&gt;....(2n+1)&lt;sup&gt;th&lt;/sup&gt; child elements from a class/element.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;:last-child&lt;/code&gt; selects the last child.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;:nth-last-child[n]&lt;/code&gt;: same as &lt;code&gt;nth-child&lt;/code&gt; but selects the elements in reverse order.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;:nth-of-type[n]&lt;/code&gt; selects elements of the same type based on a given expression.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Common CSS structures
&lt;/h2&gt;

&lt;p&gt;CSS classes can be added to any element in an html, let's explore some common usages:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; etc.&lt;/p&gt;

&lt;p&gt;You can select structres from specific classes:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    class-1 p{
        text-align:center;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The code above only applies to all the &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; elements within &lt;code&gt;class-1&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSS Specificity
&lt;/h2&gt;

&lt;p&gt;If we have two or more rules that we're applying to the same element, then the webpage will use the &lt;strong&gt;specifity value&lt;/strong&gt; of a rule to decide which one will be applied to the element.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Priority 1:&lt;/strong&gt; Inline styles, the rules declared inline will override all the previous styles that would've been applied using classes or ids.&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1 style="color:pink;"&amp;gt; Hi&amp;lt;/h1&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Priority 2:&lt;/strong&gt; IDs, IDs are like classes but they're unique for every element whereas one class can be applied to several elements.&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#example-id{
    color:pink;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Priority 3:&lt;/strong&gt; Classes, pseudo-classes and attribute selectors:&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.class-1{
    color:pink;
}
.class-1:hover{
    color:blue;
}
[target]{}
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Priority 4:&lt;/strong&gt; Elements and pseudo elements:&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;h1{
    color:grey;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  CSS responsive queries
&lt;/h2&gt;

&lt;p&gt;Responsive queries are used to adjust the design of a website according to a certain property (usually width and orientation).&lt;br&gt;
We use the &lt;code&gt;@media&lt;/code&gt; rule to manage these queries. Example:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     @media only screen and (max-width: 600px) {
    body {
        background-color: lightblue;
        }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;The code above changes the the background color if the width dips below 601px.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Flexbox
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kixAVrgN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/hy2oqjvsbk60ef92nktg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kixAVrgN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/hy2oqjvsbk60ef92nktg.png" alt="FlexBox" width="800" height="372"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Flexbox is a useful way to structure your HTML code, It has useful attributes that allow you to place elements within the container with a lot of freedom.&lt;/p&gt;

&lt;p&gt;Some commonly used flex-box properties:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;flex-direction&lt;/code&gt;: specifies the direction of the flow of elements, row displays elements row-wise, column; column-wise. The value of this attribute is row by default.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;justify-content&lt;/code&gt;: used to position elements horizontally(vertically is the flex-direction is column), center brings everything to center.space-around,space-between and space-evenly spread out the data with varying spaces between them.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;align-items&lt;/code&gt;: used to align the items within a container vertically(horizontally if the flex-direction is column).flex-start and end bring the elements to opposite sides of the container, while center brings everything to center.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;flex-wrap&lt;/code&gt;: wraps the container so elements are not stuck in a single line, instead they're spread out throughout the container.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;order&lt;/code&gt;: can change the order in which elements appear in the container, this property is &lt;code&gt;0&lt;/code&gt; by default.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;grow and shrink&lt;/code&gt; increases or decreases the size of the flex-item based on the size of the flex-container.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Grids
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fkgc3ieJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.freecodecamp.org/news/content/images/size/w2000/2022/05/CSS-GRID-3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fkgc3ieJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.freecodecamp.org/news/content/images/size/w2000/2022/05/CSS-GRID-3.png" alt="Grid" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Grids have a lot of similar properties as flex, we'll just be talking about what sets grid apart.&lt;/p&gt;

&lt;p&gt;Defining a container as a grid of multiple boxes:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    .class-1{
        display:grid;
        grid-template-rows: 1fr 1fr 1fr;
        grid-template-columns:1fr 1fr;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The code above splits container into three rows and two columns. we can use the repeat function to automate the process.&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.class-1{
    display:grid;
    grid-template-rows: repeat(100,1fr);
    grid-template-rows: repeat(100,1fr);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The code above splits it into 100 rows and columns.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Precisely placing grid items withing a grid container:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    grid-item-1{
        grid-column: 1/10;
        grid-row:1/5;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;The item above will cover the first 10 column items and first 5 row items.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;row-gap&lt;/code&gt; and &lt;code&gt;column-gap&lt;/code&gt;: used to define a gap between grid items.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    .class-1{
        display:grid;
        grid-template-rows: 1fr 1fr 1fr;
        grid-template-columns:1fr 1fr;
        row-gap:20px;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Places a gap of &lt;code&gt;20px&lt;/code&gt; between all containers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Common meta header tags
&lt;/h2&gt;

&lt;p&gt;Metadata is used by browsers (how to display content or reload page), search engines (keywords), and other web services.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    &amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="description" content="Free Web tutorials"&amp;gt;
    &amp;lt;meta name="keywords" content="HTML, CSS, JavaScript"&amp;gt;
    &amp;lt;meta name="author" content="John Doe"&amp;gt;
    &amp;lt;meta name="viewport" 
    content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;/head&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;code&gt;charset&lt;/code&gt; defines the character encoding of the document.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Keywords&lt;/code&gt; is used by search engines to display your webpages in results.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;viewport&lt;/code&gt; is used to define the scale of the viewport width and height for the website.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element"&gt;HTML elements reference&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.w3schools.com/css/css_positioning.asp"&gt;CSS Layout - The position Property&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://blog.hubspot.com/website/what-is-css-class"&gt;The Beginner's Guide to CSS Classes&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.freecodecamp.org/news/how-to-use-css-grid-layout/"&gt;How to Use CSS Grid Layout&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.freecodecamp.org/news/css-flexbox-tutorial-with-cheatsheet/"&gt;CSS Flexbox Tutorial&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.web4college.com/css/web4-css-structural-classes.php"&gt;CSS structural classes&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.w3schools.com/html/html_blocks.asp"&gt;HTML Block and Inline Elements&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.w3schools.com/css/css_rwd_mediaqueries.asp"&gt;Responsive Web Design - Media Queries&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>html</category>
      <category>css</category>
      <category>webdev</category>
    </item>
    <item>
      <title>SOLID Principles</title>
      <dc:creator>Utsav</dc:creator>
      <pubDate>Mon, 15 May 2023 08:48:20 +0000</pubDate>
      <link>https://dev.to/utsavdhall/solid-principles-4plj</link>
      <guid>https://dev.to/utsavdhall/solid-principles-4plj</guid>
      <description>&lt;p&gt;The aim of this paper is to make the readers familiar with the concepts of SOLID principles. They are essentially a set of practices that leads to well designed software (Readable,Modular,Scalable)&lt;/p&gt;

&lt;h2&gt;
  
  
  Single Responsibility Principle
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Basic gist :
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Every class must have a single responsibility to fulfill&lt;/li&gt;
&lt;li&gt;If a class is performing too many tasks, especially if the tasks are logically unrelated, then you would be better off writing another class.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How it plays out :
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;A bad example :&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    #Class below is reponsilble for user properties and user database management
    class  User:
        def __init__(self, name: str):
            self.name = name

        def get_name(self) -&amp;gt; str:
            pass

        def save(self, user: User):
            pass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;If some changes are passed to the database management system, all the classes working with user properties will have to be recompiled to compensate for new changes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The correct way :&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    #Simply split the classes.
    class User:
        def __init__(self, name: str):
                self.name = name

        def get_name(self):
            pass


    class UserDB:
        def get_user(self, id) -&amp;gt; User:
            pass

        def save(self, user: User):
            pass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Open/Closed principle
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;This principle states that classes should be open to extension, not to modification. If you want to add some functionality to a class, you are better off extending it, avoiding violating the Single responsibility principle.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;A bad example:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    class Discount:
        def __init__(self, customer, price):
            self.customer = customer
            self.price = price

        def give_discount(self):
            if self.customer == 'fav':
                return self.price * 0.2

            if self.customer == 'vip':
                return self.price * 0.4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The above class is responsible for giving out discounts, however modifying the class to add the vip discount condition violates the open/closed principle, instead do this:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The correct way:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    class Discount:
        def __init__(self, customer, price):
            self.customer = customer
            self.price = price

        def get_discount(self):
            return self.price * 0.2

    class VIPDiscount(Discount):
        def get_discount(self):
            return super().get_discount() * 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Here, we create a new class that handles the vip discount method.&lt;/p&gt;

&lt;h2&gt;
  
  
  Liskov Substitution principle
&lt;/h2&gt;

&lt;p&gt;The objects of a sub class should be able to replace the objects of its parent class without any changes in behavior.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    class Bird():
        def fly():
            pass

    class Duck(Bird):
        pass

    class Ostrich(Bird):
        pass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The above example is a bad implementation, Considering ostriches can't actually fly, We need our subclasses to be able to replace parent classes while still being logically consistent.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    class Bird():
        pass

    class FlyingBirds(Bird):
        def fly():
            pass

    class Duck(FlyingBirds):
        pass

    class Ostrich(Bird):
        pass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The example above is a good implementation of the concept.&lt;/p&gt;

&lt;h2&gt;
  
  
  Interface Segregation principle
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;An interface can be imagined as a contract, if you decide to implement an interface, you have to do so in its entirety&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;So what if you have interfaces with too many functions, all the classes will have&lt;br&gt;
to implement all the functions even if it just needs one or two of them.&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class IShape:
    def draw(self):
        raise NotImplementedError

class Circle(IShape):
    def draw(self):
        pass

class Square(IShape):
    def draw(self):
        pass

class Rectangle(IShape):
    def draw(self):
        pass
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can implement multiple interfaces, so its better to have smaller and more specific interfaces.&lt;/p&gt;

&lt;h2&gt;
  
  
  Dependency Injection principle
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Imagine a scenario where you're directly instantiating classes into other classes. Everytime a class needs to be instantiated, all the classes that its dependent on will need to be instantiated as well, incurring a massive overhead.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;This is solvable by simply giving the responsinbility of instantiation of objects to another entity.&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class AuthenticationForUser():
    def __init__(self, connector:Connector):
        self.connection = connector.connect()

    def authenticate(self, credentials):
        pass
    def is_authenticated(self):
        pass    
    def last_login(self):
        pass

class AnonymousAuth(AuthenticationForUser):
    pass

class GithubAuth(AuthenticationForUser):
    def last_login(self):
        pass

class FacebookAuth(AuthenticationForUser):
    pass

class Permissions()
    def __init__(self, auth: AuthenticationForUser)
        self.auth = auth #Object is injected here.

    def has_permissions():
        pass

class IsLoggedInPermissions (Permissions):
    def last_login():
        return auth.last_log
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;code&gt;AuthenticationForUser&lt;/code&gt; object is passed into the constructor instead of being instantiated inside the class&lt;/p&gt;

</description>
      <category>python</category>
    </item>
    <item>
      <title>Database management systems</title>
      <dc:creator>Utsav</dc:creator>
      <pubDate>Fri, 12 May 2023 12:42:02 +0000</pubDate>
      <link>https://dev.to/utsavdhall/database-management-systems-1b52</link>
      <guid>https://dev.to/utsavdhall/database-management-systems-1b52</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;DBMS is perhaps one of the most important concepts that every back-end engineer needs to have a reasonable level of mastery of. This paper aims to help readers understand all the basic concepts, We won't touch on the details considering there is a lot to cover here, But i'll try to make it comprehensive&lt;/p&gt;

&lt;h2&gt;
  
  
  Transactions
&lt;/h2&gt;

&lt;p&gt;Transactions are a series of logically related operations. They are a fundamental part of DBMS.&lt;/p&gt;

&lt;p&gt;Operations involving transactions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Read operation:&lt;/strong&gt; This operation is used to read data from the database and store it in the buffer memory&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Write operation:&lt;/strong&gt; This operation is used to write data to the database from the buffer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Commit:&lt;/strong&gt; This operation is used to save the work done permanently&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Rollback:&lt;/strong&gt; Used to rollback the work done, in case of failures.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  ACID Properties
&lt;/h2&gt;

&lt;p&gt;This is an important principle if you want to have a robust database.&lt;/p&gt;

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

&lt;p&gt;One transaction must occur in its entirety, if the transaction fails, No changes should be reflected in the database. It should either be a complete success or a complete failure.&lt;/p&gt;

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

&lt;p&gt;The changes must remain consistent throughout the database, i.e. the data must remain correct after the transaction.&lt;/p&gt;

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

&lt;p&gt;Every transaction must be independent of other concurrent transactions, It can be a huge problem if transactions are allowed to interfere with each other.&lt;/p&gt;

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

&lt;p&gt;This property ensures that the data in the database perists even after system failures.&lt;/p&gt;

&lt;h2&gt;
  
  
  CAP Theorem
&lt;/h2&gt;

&lt;p&gt;This theorem is used by system desginers working with distributed systems to manage trade offs while desgining shared-data systems(over networks). The theorem states that it is not possible to guarantee all three desriable properties from a distributed system. It consists of three properties:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Consistency:&lt;/strong&gt; Please do not confuse this consistency with the one in ACID properties, consistency in this context refers to maintaining the consistency of all copies of the database across all nodes in the distrubuted system.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Availability:&lt;/strong&gt; This property means that the database should always be available for operations and all nodes in the network should be able to respond in reasonable time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Partition Tolerance:&lt;/strong&gt; Partition tolerance can be applied over a network if the nodes are separated into clusters (It's kind of like strongly connected components in a graph), So when a fault occurs in a cluster, the outage is restricted to that cluster.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Joins
&lt;/h2&gt;

&lt;p&gt;Joins are used in SQL when you require data from two tables. Let me demonstrate with an example:&lt;/p&gt;

&lt;p&gt;Let's say you need permanent address and bank account details of an employee, but they're located in two different tables, here you'd need to join the two tables.&lt;/p&gt;

&lt;p&gt;You'll start to realise you need some common attribute for these employees to connect these two tables, It can't be &lt;code&gt;names&lt;/code&gt; because two people can have the same names, it needs to be something that is guaranteed to be unique for all employees. Here comes the concept of primary keys and foreign keys. If you have a number that is unique for all records, you can use that attribute to match the records from the two tables and get the desired attributes. Now, lets get into joins, there's all kinds of them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Inner join:&lt;/strong&gt; Essentially gets all the data that's common for both of the tables, discards everything else.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Left join:&lt;/strong&gt; Gets all the data from the table that's been joined on and the data that's common for both.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Right join:&lt;/strong&gt; The opposite of the left join.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Outer join:&lt;/strong&gt; Gets everything&lt;/p&gt;

&lt;h2&gt;
  
  
  Aggregation functions
&lt;/h2&gt;

&lt;p&gt;Aggregate functions are usually used in conjunction with the group by clause. It applies the function on fields based on the attributes mentioned in the group by clause. For example&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    SELECT employees, sum(transactions) AS revenue
    FROM profits GROUP BY employees
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The query above will get the sum of transactions for each employee, which in turn tells you the total amount of revenue brought in by every single employee.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;count()&lt;/code&gt;: this function aggregates the count of an attribute.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;sum()&lt;/code&gt;: gets the sum of attributes&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;avg()&lt;/code&gt;: gets the average of given attributes&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;max()&lt;/code&gt;: gets the max of given attributes&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;min()&lt;/code&gt;: gets the min of given attributes.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Normalizations
&lt;/h2&gt;

&lt;p&gt;This property defines constraints for the database to follow in order to make it more robust, fault tolerant and accurate. There are a lot of normal forms but we'll only go through the ones that are practically used.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First Normal Form:&lt;/strong&gt;  Requires the tables to have primary keys, so each record can be identified uniquely and every column should have a unique as well.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Second Normal Form:&lt;/strong&gt; First normal form eliminates repeated data, this normal form deals with redundancies, there's a fine distinction between the two.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;ID&lt;/th&gt;
&lt;th&gt;Course&lt;/th&gt;
&lt;th&gt;Fee&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;C1&lt;/td&gt;
&lt;td&gt;199&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;C2&lt;/td&gt;
&lt;td&gt;299&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;C1&lt;/td&gt;
&lt;td&gt;199&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;In the table above, &lt;code&gt;ID&lt;/code&gt; is the primary key, but the attribute &lt;code&gt;Fee&lt;/code&gt; is directly dependent on the course, not the primary key of the table, you can see "199" appearing twice, this is the redundancy that the second normal form aims to eliminate.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;ID&lt;/th&gt;
&lt;th&gt;Course&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;C1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;C2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;C1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Course&lt;/th&gt;
&lt;th&gt;Fee&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;C1&lt;/td&gt;
&lt;td&gt;199&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;C2&lt;/td&gt;
&lt;td&gt;299&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This would be the state of the table after applying the second normal form.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Third Normal Form:&lt;/strong&gt; In the example above, The Fee attribute had a transitive dependency on the course attribute, our example eliminates that as well.&lt;/p&gt;

&lt;h2&gt;
  
  
  Indexes
&lt;/h2&gt;

&lt;p&gt;Indexes are special lookup tables that databases use to speed up data retrieval. They're automatically created for primary and unique key constraints.&lt;/p&gt;

&lt;p&gt;In the background, the working of indexing is quite complex so we won't get into too much detail here, Let's scratch the surface:&lt;/p&gt;

&lt;p&gt;Indexes are essentially a data structure designed for faster data retrieval, it involves a key and a reference to the data. There are multiple types of indexing methods, we'll discuss the primary indexes here;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Primary Index:&lt;/strong&gt; The indexes created on the basis of primary key constraints, these indexes are automatically created and require no explicit invocation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Locking mechanisms
&lt;/h2&gt;

&lt;p&gt;Locking mechanisms are crucial for concurrency control.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Concurrency control:&lt;/strong&gt; Essentially means that concurrent transactions must not interfere with each other. It can be hard to maintain consistency and integrity if you don't have mechanisms in place to protect transactions.&lt;/p&gt;

&lt;p&gt;Now let's talk about different locking protocols:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Simplistic Locks:&lt;/strong&gt; This mechanism locks the data that is being operated on, the lock is released when the transaction is complete.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pre-Claiming Locks:&lt;/strong&gt; This mechanism lists out all the data that needs to be operated on, and requests the database for locks on that data, If the locks are granted, the transaction will proceed, otherwise it will wait until the locks are granted.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Two-Phase Locks:&lt;/strong&gt; This mechanism divides the process into two phases of Aquiring and releasing locks.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Growing phase&lt;/code&gt;: In the growing phase, the transaction only acquires locks on data items but cannot release locks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Shrinking phase&lt;/code&gt;: In this phase, the transaction may release locks, but no new locks can be acquired.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Database Isolation Levels
&lt;/h2&gt;

&lt;p&gt;Isolation levels are essentially levels of strictness by which isolation is enforced by the system.&lt;/p&gt;

&lt;p&gt;Lets look at some levels in the order of their strictness:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Read Uncommited:&lt;/strong&gt; This is the lowest level, Concurrent transactions can read uncommited changes by other ongoing transactions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Read Commited:&lt;/strong&gt; In this isolation level, the transactions can only read the commited changes by other transactions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Repeatable Read:&lt;/strong&gt; This level is mostly isolated but phantom reads are still possible, i.e. if the transaction calls the read operation twice and a commited transaction happens in between those calls, The output of the two queries can differ.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Serilizable:&lt;/strong&gt; This is completely isolated, the transactions read like they were serialized.&lt;/p&gt;

&lt;h2&gt;
  
  
  Triggers
&lt;/h2&gt;

&lt;p&gt;A trigger is a stored procedure that is invoked when a special event occurs, this "special event" can be defined by the user. Let's look at an example:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;create trigger stud_marks 
before INSERT 
on 
Student 
for each row 
set Student.total = Student.subj1 + Student.subj2 + Student.subj3, Student.per = Student.total * 60 / 100;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Above SQL statement will create a trigger in the student database so that, whenever marks are entered before inserting this data into the database, trigger will compute those two values and insert with the entered values.&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Dictionaries in Python</title>
      <dc:creator>Utsav</dc:creator>
      <pubDate>Thu, 11 May 2023 07:02:31 +0000</pubDate>
      <link>https://dev.to/utsavdhall/dictionaries-in-python-105g</link>
      <guid>https://dev.to/utsavdhall/dictionaries-in-python-105g</guid>
      <description>&lt;h2&gt;
  
  
  Description
&lt;/h2&gt;

&lt;p&gt;This paper is meant to help readers get familiar with the concepts of dictionaries in python and the methods that go along with them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Defining a dictionary:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#A dictionary that maps players of a video
#game to their respective high scores
high_scores={"Utsav": 234, "Siddarth": 898}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;dictionaries are contained in curly brackets: &lt;code&gt;{}&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Using dictionaries to represent complex data structures
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Hash map:&lt;/strong&gt;&lt;br&gt;
One of the most common ways dictionaries in python are used is as a hash map&lt;br&gt;
Hash maps are used to map certain keys to their corresponding values, they're usually used as a way to reduce time complexities of algorithms, However there's a trade-off because they end up increasing the space complexity of the code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Graphs (Adjacency Lists):&lt;/strong&gt;&lt;br&gt;
Dictionaries are also used to store Adjacency lists, which are essentially a way to represent graphs, It maps a key to a list of values, where a key represents a node and the subsequent list of values represent all the connected nodes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;graph={ 1: [2,3,4] ,
    2 : [ 6,7 ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Adding an element in a dictionary
&lt;/h3&gt;

&lt;p&gt;Suppose we have to increment the value for &lt;code&gt;1&lt;/code&gt; in the given dictionary&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;frequency={}
if 1 not in frequency:
    frequency[1]=1
else:
    frequency[1]+=1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Iterating through a dictionary
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;The intuitive way&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for i in dictionary:
    print(i, dictionary[i])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The way listed above prints the keys and their corresponding values, It's simple and easy to understand especially for people from non python backgrounds.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The pythonic way&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for keys,values in dictionary.items():
    print(keys, values)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;.items()&lt;/code&gt; function returns a tuple of two elements: &lt;code&gt;(keys, values)&lt;/code&gt; . This way is easier on the eyes and looks much more readable. This way of iterating is also in line with the PEP8 standards.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Sorting a dictionary
&lt;/h3&gt;

&lt;p&gt;Dictionaries do not have a &lt;code&gt;.sort()&lt;/code&gt; function like lists do in python, but fear not! The gods of programming are not that merciless.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;sorted()&lt;/code&gt; function essentially works the same way. However, make sure you pass the dictionaries using the &lt;code&gt;.items()&lt;/code&gt; method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dictionary={1:3,2:2,3:1}
print(sorted(dictionary))
#The code above will sort and print
#The list of keys by default
#output: [1,2,3]
print(sorted(dictionary.items))
#Now that we're passing both items
#output: {1:3,2:2,3:1}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;But what if you want to sort this dictionary by it's values instead ? Let's take a short detour to &lt;strong&gt;lambda functions&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fun= lambda x:x+5
#To easiest way to explain this is to
#show you how you can achieve this
#without lambda
def fun(x):
    return x+5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;These functions save us from needing to type out small functions that will never be used again, do not use lambda if you need to type it out a lot of times in your code, Make it a separate function instead. Now let's get back to where we were:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dictionary={1:3,2:2,3:1}
ans=sorted(dictionary.items(), key= lamda x: x[1]) 
print(ans) #output: {3:1,2:2,1:3}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;since &lt;code&gt;.items()&lt;/code&gt; returns a tuple of key value pairs, specifying &lt;code&gt;x[1]&lt;/code&gt; notifies the function that the dictionary needs to be values.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Miscellaneous functions
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;.update()&lt;/code&gt;: This function is used in between dictionaries, let's say you have a &lt;code&gt;current_dictionary&lt;/code&gt; and an &lt;code&gt;updated_dictionary&lt;/code&gt; , if you want to update the values in your current dictionary using the corresponding keys in the new dictionary, you can use this function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;current_dictionary.update(new_dictionary)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;.pop()&lt;/code&gt;: This function removes elements from a dictionary based on the keys provided.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;age={"utsav":23, "siddarth":6}
age.pop("siddarth")
print(age) #output: {"utsav":23}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The function above removes items in dictionary based on their keys&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>python</category>
    </item>
    <item>
      <title>Object Oriented Programming</title>
      <dc:creator>Utsav</dc:creator>
      <pubDate>Thu, 11 May 2023 06:52:29 +0000</pubDate>
      <link>https://dev.to/utsavdhall/object-oriented-programming-5cee</link>
      <guid>https://dev.to/utsavdhall/object-oriented-programming-5cee</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;The aim of this paper is to help the reader get familiar with the concepts of object oriented programming , syntax for demonstrations will be in Python.&lt;/p&gt;

&lt;h2&gt;
  
  
  Basic Concepts
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Polymorphism:&lt;/strong&gt; This concept can be broken down into two different categories, &lt;code&gt;Run time polymorphism&lt;/code&gt; and &lt;code&gt;Compile time polymorphism&lt;/code&gt;, However, The basic gist of the concept is that a function can behave differently given different circumstances, Python does not support compile time polymorphism. so we'll just look at some examples for run time polymorphism.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Parent():
    def __init__(self):
        pass
    def show(self):
        print("This is parent class")

class Child(Parent):
    def __init__(self):
        pass
    def show(self):
        super().show()
        print("This is child class")


child=Child()
parent=Parent()
child.show()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;In the example above, The &lt;code&gt;show&lt;/code&gt; method in the child class overrides the show method derived from the parent class. However, if you still wish to use the parent method, you can use the &lt;code&gt;super()&lt;/code&gt; method as shown in the example. It instead invokes the overriden function.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Encapsulation:&lt;/strong&gt; This is the idea of wrapping data and the methods that work on data within one unit. When you look at the definitions of &lt;code&gt;Encapsulation&lt;/code&gt; and &lt;code&gt;Data Hiding&lt;/code&gt; online, you might find a lot of redundancies for the explanations of these two concepts. We'll just talk about encapsulation here.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class getArea():
    def __init__(self):
        self.length=0
        self.breadth=0

    def set_sides(self,l,b):
        self.length=l
        self.breadth=b

    def get_area(self):
        return self.length*self.breadth
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The above snippet is a good example of encapsulation, bundling up all variables and functions inside a single unit.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Data Hiding:&lt;/strong&gt; We talked about &lt;code&gt;Encapsulation&lt;/code&gt; before, the gist of this concept is similar. This concept deals with the security of the software. Let me demonstrate with an example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class User():
    def __init__(self):
        self.username="Utsav"
        self.password="xwru3"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The example above demonstrates the dangers of not hiding data that needs to stay secret, since the &lt;code&gt;username&lt;/code&gt; and &lt;code&gt;password&lt;/code&gt; in the above snippet are public variables anyone can change them. Let me demonstrate a better way of doing this:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class User():
    def __init__(self):
        self.__username="Utsav"
        self.__password="xwru3"
    def change_password(self,new_password,old_password):
        if old_password!=self.__password:
            print("The password you entered is incorrect")
            return
        self.__password=new_password
        print("Password changed successfully")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The code above demonstrates how you can increase security using private methods when needed. Now you can only change the password if you know your old password.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Abstraction:&lt;/strong&gt; This is the concept of only displaying the essential details to the user.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from abc import ABC, abstractmethod   
class Car(ABC):   
    def mileage(self):   
        pass  

class Tesla(Car):   
    def mileage(self):   
        print("The mileage is 30kmph")   
class Suzuki(Car):   
    def mileage(self):   
        print("The mileage is 25kmph ")   
class Duster(Car):   
    def mileage(self):   
          print("The mileage is 24kmph ")   
class Renault(Car):   
    def mileage(self):   
        print("The mileage is 27kmph ")   
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The class &lt;code&gt;Car&lt;/code&gt; above is a generic class with no implementation of its functions, its essentially a skeleton class that gives out the structure of the class.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Inheritance
&lt;/h2&gt;

&lt;p&gt;Now lets talk about one of the most important concepts in OOP, inheriting different classes functionalities into your own class. There are a lot of different kinds of functionalities&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Simple Inheritance&lt;/strong&gt;: Simply inheriting a single class into your own.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class parent():
    def show():
        print("parent")
class child(parent):
    def showchild():
        print("child")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This is a pretty straight forward example of inheritance, one class inheriting another class.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Multilevel Inheritance:&lt;/strong&gt; You can layer inheritance as well, let me demonstrate:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class GrandParent():
    def show():
        print("This is the grandparent)
class Parent(GrandParent):
    def show():
        print("This is the parent")
class Child(Parent):
    def show():
        print("This is the child")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;See? you can chain inheritance as much as you want.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Hierarchical Inheritance:&lt;/strong&gt; You can inherit a class multiple times:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Dad():
    def show():
        print("this is dad")
class Son(Dad):
    def show():
        print("this is son")
class daughter(Dad):
    def show():
        print("this is daughter")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Multiple children can inherit the same parent.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Multiple Inheritance&lt;/strong&gt;: Kind of the opposite of Hierarchical Inheritance. Let me demonstrate:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Dad():
    def show():
        print("this is dad")
class Mom():
    def show():
        print("This is mom")
class Child(Dad,Mom):
    def show():
        super().show()
        print("This is child")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;A child can inherit two classes, However you should be familiar with the &lt;code&gt;Method Resolution order&lt;/code&gt; when you're working with this. The order is how you inherit the classes, here &lt;code&gt;class X(Y,Z)&lt;/code&gt;, Y will take precedence over Z in the order.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Static Variables
&lt;/h2&gt;

&lt;p&gt;Python doesn't have a &lt;code&gt;static&lt;/code&gt; keyword, but that doesn't mean we can't have static variables, the trick is to define the variable outside of any function, without using the &lt;code&gt;self&lt;/code&gt; attribute, self is used to define instance variables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class X():
    static_var=0
    def __init__(self):
        self.not_static_var=0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Here, The &lt;code&gt;static_var&lt;/code&gt; variable will behave just like a static variable in any other language.&lt;/li&gt;
&lt;li&gt;Static variables are the same for all objects, They belong to the class, if you change this variable in an object, the change will be reflected for all other objects.&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>String Methods</title>
      <dc:creator>Utsav</dc:creator>
      <pubDate>Thu, 11 May 2023 05:42:44 +0000</pubDate>
      <link>https://dev.to/utsavdhall/string-methods-pg2</link>
      <guid>https://dev.to/utsavdhall/string-methods-pg2</guid>
      <description>&lt;ul&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;The aim of this paper is to help the reader get familiar with the standard functions of strings in Python.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;h2&gt;
  
  
  Functions
&lt;/h2&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;1 . &lt;code&gt;.count()&lt;/code&gt;: This function returns the count of a specific value inside a string , the value is passed as an argument. &lt;strong&gt;Syntax:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    s="aabbzzz"
    character_to_be_counted='z'
    frequency=s.count(character_to_be_counted) #This is the generic syntax
    print(frequency)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;The snippet above prints the number of time &lt;strong&gt;"z"&lt;/strong&gt; appears in the string &lt;strong&gt;"s"&lt;/strong&gt; which is &lt;code&gt;3&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;2 . &lt;code&gt;.find() and .index()&lt;/code&gt;: The reason I have grouped these two together is because they serve almost the same functionality, both of these functions will return the first index of where a specified value is found , however when they fail to find the value, &lt;code&gt;.index()&lt;/code&gt; raises a &lt;strong&gt;ValueError&lt;/strong&gt; exception and &lt;code&gt;.find()&lt;/code&gt; returns -1. &lt;strong&gt;Syntax:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    s="aabbcc"
    answer=s.find("a")
    answer2=s.index("a")
    print(answer,answer2)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Both of these functions will return &lt;code&gt;0&lt;/code&gt; (The first occurrence of &lt;strong&gt;"a"&lt;/strong&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;3 . &lt;code&gt;.format()&lt;/code&gt;: This function places text inside given string, The user needs to define a  placeholder inside the string so the function knows where to place specific values. &lt;strong&gt;Syntax:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    text="The price of {fruit} is {price}"
    modified_string=text.format(fruit="mango",price=35")
    print(modified_string)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The output for the snippet above is &lt;code&gt;The price of mango is 35&lt;/code&gt; &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;format&lt;/code&gt; maps the values to their respective placeholders.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;4 .  &lt;code&gt;.isalpha()&lt;/code&gt;: This function returns a boolean value after checking if all characters in a string are alphabets or not. &lt;strong&gt;Syntax:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    text1="Company"
    text2="Company10"
    check_alpha1=text1.isalpha()
    check_alpha2=text2.isalpha()
    print(check_alpha1,check_alpha2)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;The above snippet prints &lt;code&gt;True&lt;/code&gt; and &lt;code&gt;False&lt;/code&gt; respectively.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;5 . &lt;code&gt;.replace&lt;/code&gt;: This function replaces a given character or a phrase with another one. An optional argument can be added , specifying the number of existing phrases the user wants to remove. &lt;strong&gt;Syntax:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    text="I like Bananas"
    current_phrase="Bananas"
    new_phrase="Oranges"
    modified_text=text.replace(current_phrase,new_phrase) #This is the generic syntax
    print(modified_text)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;6 . &lt;code&gt;.upper() and .lower()&lt;/code&gt;: Both of these functions have similar functionality, &lt;code&gt;.upper()&lt;/code&gt; changes all characters in a string to uppercase and &lt;code&gt;.lower()&lt;/code&gt; changes all the characters to lowercase. &lt;strong&gt;Syntax:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    text="AaAbC"
    upper_text=text.upper()
    lower_text=text.lower()
    print(upper_text,lower_text)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;The snippet above prints &lt;code&gt;AAABC&lt;/code&gt; and &lt;code&gt;aaabc&lt;/code&gt; respectively.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;7 . &lt;code&gt;.split()&lt;/code&gt;: This function splits the string on the basis of the given argument which is space by default. &lt;strong&gt;Syntax:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    text1="This is a sentence"
    new_list=text1.split()
    print(new_list)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;The above snippet will print &lt;code&gt;["This","is","a","sentence"]&lt;/code&gt; splitting the above string by space&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;8 . &lt;code&gt;.strip()&lt;/code&gt;: This function removes the leading and trailing occurrences of a specified string, the default argument is space.  &lt;strong&gt;Syntax:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    text1="  abcd    "
    new_text1=text1.strip()
    print(new_text1)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;The above snippet will print &lt;code&gt;abcd&lt;/code&gt; removing all instances of spaces from the right and the left end.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;9 . &lt;code&gt;.join()&lt;/code&gt;: This function is the polar opposite of the &lt;code&gt;.split()&lt;/code&gt; function , This function will help you out if you want to join a list to make a string based on a separator.  &lt;strong&gt;Syntax:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    list=["This","is","a","sentence"]
    separator="  "
    answer=separator.join(list)
    print(answer)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;The snippet above will print &lt;code&gt;This is a sentence&lt;/code&gt; creating a space will adding the specified separator between the words.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;10 . &lt;code&gt;isdigit()&lt;/code&gt;: Returns &lt;code&gt;True&lt;/code&gt; if all characters in the given string are digits , else returns &lt;code&gt;False&lt;/code&gt;. &lt;strong&gt;Syntax:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    digit="10273"
    non_digit="adefre13"
    print(digit.isdigit())
    print(non_digit.isdigit())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;The snippet above prints &lt;code&gt;True&lt;/code&gt; and &lt;code&gt;False&lt;/code&gt; respectively.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>python</category>
    </item>
    <item>
      <title>List Methods</title>
      <dc:creator>Utsav</dc:creator>
      <pubDate>Tue, 09 May 2023 14:40:07 +0000</pubDate>
      <link>https://dev.to/utsavdhall/list-methods-21bm</link>
      <guid>https://dev.to/utsavdhall/list-methods-21bm</guid>
      <description>&lt;ul&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;The aim of this paper is to help the reader get familiar with the standard functions of lists in Python.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;h2&gt;
  
  
  Functions
&lt;/h2&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;.append()&lt;/code&gt; : This function adds an element at the end of the list, since Python allows the user to add multiple data types to the same list, you can append an element of any data type without any errors. &lt;strong&gt;Syntax:&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    list=[1,3]
    new_element=3
    list.append(new_element) #This is the generic syntax
    print(list)
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;The output for the snippet above will be &lt;code&gt;[1,3,3]&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;.clear()&lt;/code&gt; : This function will remove all elements from the list, be careful while using it. &lt;strong&gt;Syntax:&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    list=[1,2,3]
    list.clear() #This is the generic syntax
    print(list)
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;The output for the snippet above will be &lt;code&gt;[]&lt;/code&gt; (Empty list)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;.copy()&lt;/code&gt; : This function will simply return a copy of a list. &lt;strong&gt;Syntax:&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    old_list=[1,2,3]
    new_list=old_list.copy() #This is the generic syntax
    print(new_list)
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;The output for the code above will be &lt;code&gt;[1,2,3]&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;.count()&lt;/code&gt;: Returns the frequency of a given element that is passed as an argument. &lt;strong&gt;Syntax:&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    list=[1,1,1,4]
    element_to_be_counted=1
    frequency=list.count(element_to_be_counted) #This is the generic syntax.
    print(frequency)
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;The output for the snippet above will be &lt;code&gt;3&lt;/code&gt; (The number of time &lt;code&gt;1&lt;/code&gt; appears in the list)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;.extend()&lt;/code&gt;: This function essentially concatenates one list with another. &lt;strong&gt;Syntax:&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    list1=[1,2,3]
    list2=[4,5,6]
    list1.extend(list2) # This is the generic syntax
    print(list1)
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;The output for the code above will be &lt;code&gt;[1,2,3,4,5,6]&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;.index()&lt;/code&gt;: Returns the first index of the element that's passed in the argument. &lt;strong&gt;Syntax&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; list1=[1,2,3,3,3,4]
 index=list1.index(3)
 print(index)
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;The snippet above will print: &lt;code&gt;2&lt;/code&gt; (The first  "3" appears in the list)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;.insert()&lt;/code&gt;: This function will help you out if you want to place a certain element at a certain index, but be careful because it will obviously shift the indexes of all subsequent elements by "1". &lt;strong&gt;Syntax:&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;list=[1,2,3,4]
index=1
element=6
list.insert(index,element) #This is the generic syntax.
print(list)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;-The above snippet will add &lt;code&gt;6&lt;/code&gt; at index &lt;code&gt;1&lt;/code&gt;. The output will be:&lt;code&gt;[1,6,2,3,4]&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;.pop()&lt;/code&gt;: This function will remove an element from a specified index, however the argument is optional, The default value is &lt;code&gt;-1&lt;/code&gt; , which means the function will remove the last element by default. &lt;strong&gt;Syntax:&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;list=[1,2,3,4]
index_to_be_removed=2
list.pop(index_to_be_removed) #This is the generic syntax
print(list)
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The output for the above snippet is: &lt;code&gt;[1,2,4]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;list.pop()&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;The code above will further remove the last element , Output: &lt;code&gt;[1,2]&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;9 . &lt;code&gt;.remove()&lt;/code&gt;: This function has the similar functionality as &lt;code&gt;.pop()&lt;/code&gt; but this function removes by value instead of index, This removes the first occurrence of the specified value. &lt;strong&gt;Syntax:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    list=[1,2,2,2,3,4]
    element_to_be_removed=2
    list.remove(element_to_be_removed) #This is the generic syntax
    print(list)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt; The output for the above code will be: &lt;code&gt;[1,2,2,3,4]&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;10 . &lt;code&gt;.reverse()&lt;/code&gt;: This function will simply reverse the given list. &lt;strong&gt;Syntax&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    list=[1,2,3,4,5]
    list.reverse() #This is the generic syntax.
    print(list)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;The output for the snippet above will be: &lt;code&gt;[5,4,3,2,1]&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;11 . &lt;code&gt;.sort()&lt;/code&gt;: This function will sort the given list,It sorts by ascending order by default , However you can specify the order as an optional argument. You can also customize this function by specifying a key according to which you want the function to sort the elements. &lt;strong&gt;Syntax:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;           list=[3,4,2,1,5]
           list.sort() #This is the generic syntax
           print(list)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The snippet above will sort the list by ascending order, Output: &lt;code&gt;[1,2,3,4,5]&lt;/code&gt;&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    list.sort(reverse=True)
    print(list)
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The snippet above will sort the list by descending order, Output: &lt;code&gt;[5,4,3,2,1]&lt;/code&gt;&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    def function(s):
        return len(s)
    list=["aaaa", "bb" , "c"]
    list.sort(key=function)
    print(list)
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The code above will sort the list of strings by their lengths instead of their lexicographical order.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  List as stacks
&lt;/h2&gt;

&lt;p&gt;Stacks follow the Last In First Out (LIFO) structure, files are appended and popped from the same location, they are used to track "states" in algorithms, but that's a topic for another paper.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;stack=[1,2,3,4]
def push(x):
    stack.append(x)
def pop():
    return stack.pop()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This successfully emulates the concept of stacks&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  List as queues
&lt;/h2&gt;

&lt;p&gt;We can emulate queues using lists as well, queues follow the First In First Out (FIFO) structure.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;queue=[1,2,3,4]
def push(x):
    queue.append(x)
def pop():
    return queue.pop(0)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;.pop(0)&lt;/code&gt; removes the first element, successfully imitating the concept of queues&lt;/p&gt;

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