Web Application 3rd Sem
Web Application 3rd Sem
Prepared By:
Mr. Santosh Kumar Pandit
Lecture of Dept. of Computer Science and Engineering
GCE Ambapua, Berhampur-10
Module 1: Introduction to Web Development with HTML, CSS, JavaScript [13 Hours]
This starter course is designed for individuals aiming to become Web Developers, offering an introduction to the roles of front-
end, back-end, and full-stack developers in development projects. It also familiarizes learners with the terminology and skills
essential for a web development career. The focus is given to the languages needed for website or application development with a
comprehensive understanding of HTML and CSS for creating the structure and style of websites. JavaScript is introduced to
enable dynamic page features like interactive forms, dynamic content modification, and sophisticated menu systems. On
completing this course, learners will be able to create a basic structure for a website, format and layout for web applications,
enhance websites with rich, interactive applications, increase user interactivity and experience, and provide their websites with a
unique appeal. Hands-on labs provide practical application opportunities, and a final portfolio-worthy project involves creating a
webpage to showcase the skills learned.
Sub-Topic
Introduction to Application Development
CSS Overview & HTML5 Elements
HTML Overview
JavaScript Programming for Web Applications
Formative Assessments:
4 graded quizzes and 1 Peer-review assignment.
Module 2: Getting Started with Git and GitHub [18 Hours]
This self-paced introductory course provides an in-depth understanding of Git and GitHub, essential tools for collaboration and
social coding in modern software engineering and DevOps culture. Starting with Git and GitHub fundamentals, it covers key Git
concepts such as branching and repositories, along with the use of Git commands. The course includes hands-on labs, augmenting
understanding of Git concepts including forking, cloning, and merging workflows, and fostering team productivity on GitHub. It
concludes with a final project that allows students to begin building their portfolio with a public/open-source GitHub project, thus
demonstrating their Git and GitHub skills and providing a valuable addition to their resume. All activities are browser-based,
negating any need for specialized software installation on the learner's computer.
Sub-Topic
Git and GitHub Fundamentals
Using Git Commands and Managing GitHub Projects
Cloning and Forking GitHub Projects
Formative Assessments:
2 graded quizzes and 1 Peer-review assignment.
Module 3: Developing Front-End Apps with React [14 Hours]
This course provides comprehensive instruction on React, a popular framework for web and front-end application development.
The curriculum includes building rich front-end applications with React and ES6, connecting React components using data and
state, and writing advanced React components using Hooks and Redux. Learners will gain access to the React web framework UI
library and learn to run rich React applications, modify their properties and states, and connect to an external server from a React
page. The course also introduces various testing tools to verify components without manual checking. Hands-on labs and a final
portfolio-worthy project form part of the course, demonstrating learners' acquired React skills. This course is beneficial for those
looking to further their IT career as front-end or full-stack developers. Prior knowledge of HTML, CSS, JavaScript, and
Git/GitHub is required.
Sub-Topic
Advanced React
Building Rich Front-End Applications with React and ES6
React Components
Introduction to TypeScript
Passing Data and States Between Components
Formative Assessments:
3 graded quizzes and 1 Peer-review assignment.
Module 4: Developing Back-End Apps with Node js and Express [12 Hours]
This course primarily focuses on [Link] and Express, two popular web technologies. [Link], the most commonly used server-
side technology, and Express, the most prevalent server-side web framework, are vital for developing modern web applications. In
this course, you will concentrate on crafting applications using asynchronous callbacks and promises, creating REST APIs, and
performing CRUD operations. You will also learn to implement authentication and session management. Ample hands-on labs
provide practical experience, and a final project allows you to demonstrate your [Link] skills and add to your portfolio. This
course equips you to thrive as a back-end or full-stack developer and is perfect for IT professionals aspiring for career
advancement, new graduates looking to refine their server-side skills, and those managing cloud-centric projects. Prerequisites
include knowledge of JavaScript and Git.
Sub-Topics
Introduction to Server-Side JavaScript
Asynchronous I/O with callback programming
Express Web Application Framework
Formative Assessments:
3 graded quizzes and 1 Peer-review assignment.
Module 1
Introduction to HTML-
HTML stands for Hyper Text Markup Language. It is a language of World Wide Web. It is a
standard text formatting language which is used to create and display pages on the Web. It makes the text
more interactive and dynamic. It can turn text into images, tables, and [Link] is the most used language
for developing the web pages.
HTML was created by Berners-Lee in late 1991 but "HTML 2.0" was the first standard HTML
specification which was published in 1995. HTML 4.01 was a major version of HTML and it was
published in late 1999. Now we are having HTML-5 version which is an extension to HTML 4.01, and this
version was published in 2012.
A Markup Language is a set of instructions often called TAGS which can be added to text files. HTML is only a
formatting language are not a programming language. The idea behind hypertext is that instead of reading text in a
right linear structure we can easily jump from one point to another [Link] is all about specifying the structure
and format of our webpage i.e, it is mainly used for describing the structure document.
HTML is platform independent i.e, for example if we can access internet, we can access WORLD WIDE WEB
(WWW) irrespective of client OS and OS of the web server are accessing. So, we can view one download HTML
files on www through browser.
Elements of a web document are labeled through the usage of HTML tags. It is the tags that describe the document.
Anything that is not a tag will be displayed in the document itself. HTML does not describe any page layout i.e, for
example, word for windows have different styles for headings, font size etc. But HTML doesn’t have all these. Based
on the Platforms, appearance of any element will change. The formatted text will appear differently on different
machines / Platforms. By separating the Structure of the document and appearance, a Program that reads and
Understands HTML can make formatting decision based on capabilities of individual Platform. Web Browsers are
best examples of HTML formatters.
Advantages of HTML:-
A HTML document is small and hence easy to send over the net. It is small because it doesn’t include
format information.
HTML documents are cross platform compatible and device independent. We need a HTML readable
browser to view them.
<body>
body related tags
</body>
</html>
HTML Tag
Tag Description
<!DOCTYPE...> This tag defines the document type and HTML version.
<html> This tag encloses the complete HTML document and mainly comprises of document
header which is represented by <head>...</head> and document body which is
represented by <body>...</body> tags.
<head> This tag represents the document's header which can keep other HTML tags like
<title>, <link> ,<style>,<meta>,<script>etc.
<title> The <title> tag is used inside the <head> tag to mention the document title.
<body> This tag represents the document's body which keeps other HTML tags like <h1>,
<div>, <p> etc.
<h1>to <h6> Any Description starts with a heading. You can use different sizes for your headings.
HTML also has six levels of headings, which use the elements <h1>, <h2>, <h3>,
<h4>, <h5>, and <h6>. <h1> tag is large size and <h6> is small size
<p> The <p> tag offers a way to structure your text into different paragraphs. Each
paragraph of text should go in between an opening <p> and a closing </p> tags.
<br/> Whenever you use the <br /> element, anything following it starts from the next line.
<hr/> Horizontal lines are used to visually break up sections of a document. The <hr/> tag
creates a line from the current position in the document to the right margin and breaks
the line accordingly.
<!--> HTML comments are placed in between <!-- ... --> tags. So any content placed with-in
<!-- ... --> tags will be treated as comment and will be completely ignored by the
browser.
<b> Anything that appears within <b>...</b> element, is displayed in bold.
<i> Anything that appears within <i>...</i> element is displayed in italicized.
<mark> Anything that appears with-in <mark>...</mark> element, is displayed as marked
with yellow ink.
<center> You can use <center> tag to put any content in the center of the page or any table cell.
<big> The content of the <big>...</big> element is displayed one font size larger than the
rest of the text surrounding
<small> The content of the <small>...</small> element is displayed one font size smaller than
the rest of the text surrounding
<sup> The content of a <sup>...</sup> element is written in superscript; the font size used is
the same size as the characters surrounding it but is displayed half a character's height
above the other characters.
<sub> The content of a <sub>...</sub> element is written in subscript; the font size used is
the same as the characters surrounding it, but is displayed half a character's height
beneath the other characters.
<blockquote> Text inside a <blockquote> element is usually indented from the left and right edges of
the surrounding text, and sometimes uses an italicized font.
<q> The <q>...</q> element is used when you want to add a double quote within a
sentence. / Short Quotations
<s>/<del> Anything that appears within <strike>...</strike> element is displayed with
strikethrough, which is a thin line through the text
<u>/<ins> Anything that appears within <u>...</u> element, is displayed with underline
<pre> Any text between the opening <pre> tag and the closing </pre> tag will preserve the
formatting of the source document
<em> Anything that appears within <em>...</em> element is displayed as emphasized text.
<spam> The <samp>...</samp> element indicates sample output from a program, and script
etc. Again, it is mainly used when documenting programming or coding concepts.
<font> Fonts play very important role in making a website more user friendly and increasing
content readability. Font face and color depends entirely on the computer and browser
that is being used to view your page but you can use HTML <font> tag to add style,
size, and color to the text on your website.
<iframe> You can define an inline frame with HTML tag <iframe>. The <iframe> tag is not
somehow related to <frameset> tag, instead, it can appear anywhere in your
document. The <iframe> tag defines a rectangular region within the document in
which the browser can display a separate document, including scrollbars and borders.
<marquee> An HTML marquee is a scrolling piece of text displayed either horizontally across or
vertically down your webpage depending on the settings. This is created by using
HTML <marquees> tag.
<caption> The <caption> tag in HTML is used to provide a title or brief description for
a <table> element.
<address> The <address>...</address> element is used to contain any address.
<kbd> When you are talking about computers, if you want to tell a reader to enter some text,
you can use the <kbd>...</kbd> element to indicate what should be typed
<div> The <div> and <span> elements allow you to group together several elements to
create sections or subsections of a page.
<span> The <div> and <span> elements allow you to group together several elements to
create sections or subsections of a page.
<header> The <header> tag in HTML is a semantic element used to define the introductory
content or navigational links for a document or a section within a document.
<nav> The <nav> tag is used in HTML to define a section of a webpage that contains
navigation links. Its primary purpose is to provide semantic meaning and improve the
accessibility and search engine optimization (SEO) of a website.
<section> The <section> tag in HTML is a semantic element used to define a generic
standalone section of a document. Its primary purpose is to provide a logical grouping
of related content within a webpage.
<footer> The <footer> tag in HTML is used to define the footer section of an HTML
document or a specific section within it. Its primary purpose is to semantically group
content that typically appears at the end of a page or a content block.
<picture> The <picture> tag in HTML is used to provide responsive images, allowing
developers to specify different image sources for various screen sizes, resolutions, and
other media conditions. This addresses the challenge of displaying images optimally
across a wide range of devices, from small mobile phones to large desktop monitors.
<map> The <map> tag in HTML is used to define a client-side image map. An image map is
an image with clickable areas, where different parts of the image can be linked to
different destinations or trigger specific actions.
<svg> The <svg> tag in HTML is used to embed Scalable Vector Graphics (SVG) directly
within an HTML document. SVG is an XML-based vector image format, meaning that
images are defined using mathematical descriptions of shapes, paths, and text, rather
than a grid of pixels.
Its use for word space
Definition List:-
These lists include both definition terms as well as their definition. To create the definition lists we
use <dl> tag. For creating definition terms we use <dt> tag and for data definitions we use <dd>tag.
Example:
<html>
<head>
<title>Creating Definition List</title>
</head>
<body bgcolor="pink">
<h1 align="center">Definition List</h1>
<dl>
<dt>CSE</dt><dd>Computer Science & Engineering</dd>
<dt>ME</dt><dd>Mechanical Engineering</dd>
<dt>AI</dt><dd>Artificial Intelligence</dd>
<dt>EEE</dt><dd>Electrical & Electronics Engineering</dd>
<dt>CE</dt><dd>Civil Engineering</dd>
</dl>
</body>
</html>
Output
Attributes-:
<tag name att name=”value”>……</tag name>
1) Align
Left , right , center
2) Direction
Ltr , Rtl
HTML Color coding system-Color Names
There are 3 different methods to set color.
o We can set color using three methods.
a. Using color name
<body bgcolor=”red”>
<font color=”red”>
b. Using RGB(Red, Green, Blue)value abs (0to255) & %(0to100)
<body bgcolor=”rgb(72,0,0)”>
<font color=”rgb(72,0,0)”>
<body bgcolor=”rgb(72%,0%,0%)”>
HTML– Images
o Use the <img/> tag to place an image on your webpage.
<imgsrc="[Link]"/>
Image src
o Above we have defined the src attribute.
o Src stands for source, the source of the image or more appropriately, where the picture file is
located.
o There are two ways to define the source of an image. First you may use a standard URL.
(src=[Link] As your second choice, you may copy or upload
the file onto your web server and access it locally using standard directory tree methods.
(src="../[Link]")
o The location of this picture file is in relation to your location of [Link] file.
HTML Comments
Comment is a piece of code which is ignored by any web browser. It is a good practice to
add comments into your HTML code, especially in complex documents, to indicate sections of a
document, and any other notes to anyone looking at the code. Comments help you and others
understand your code and increases code readability.
HTML comments are placed in between <!-- ... --> tags. So any content placed with-in <!-- ... -->
tags will be treated as comment and will be completely ignored by the browser.
HTML Iframes
You can define an inline frame with HTML tag <iframe>. The <iframe> tag is not somehow
related to <frameset> tag, instead, it can appear anywhere in your document. The <iframe> tag
defines a rectangular region within the document in which the browser can display a separate
document, including scrollbars and borders.
The src attribute is used to specify the URL of the document that occupies the inline frame.
<iframe src="/html/[Link]">
your browser is support inline frames.
</iframe>
HTML Marquees
An HTML marquee is a scrolling piece of text displayed either horizontally across or vertically
down your webpage depending on the settings. This is created by using HTML <marquees> tag.
<marquee>
One or more lines or text message or image
</marquee>
HTML TABLE
An HTML table is a structured way to display data in rows and columns on a web page. It is
created using the <table> element and its associated elements for defining rows, header cells, and data
cells.
A HTML table arranges data/information in terms of rows and columns. Tables are defined in HTML
using <table> tag. A table is divided into rows and each row each divided into data cells (columns). The
rows of table are created using <tr> tag and data cells are created by <td> tag.
<tr>-Table row
<td>-Table data
Key HTML elements for creating a table:
<table>: The main container for the entire table.
<tr>: Defines a table row. Each <tr> element represents a new row in the table.
<th>: Defines a table header cell. These cells typically contain headings for the columns and are often
displayed in bold by default.
<td>: Defines a standard table data cell. These cells contain the actual data within the table.
Optional elements for enhanced structure:
<thead>: Groups the header content in a table.
<tbody>: Groups the body content in a table.
<tfoot>: Groups the footer content in a table.
<caption>: Provides a short description or title for the table.
Example
<table>
<caption>Monthly Sales Data</caption>
<thead>
<tr>
<th>Month</th>
<th>Product A Sales</th>
<th>Product B Sales</th>
</tr>
</thead>
<tbody>
<tr>
<td>January</td>
<td>150</td>
<td>200</td>
</tr>
<tr>
<td>February</td>
<td>180</td>
<td>220</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="3">Total sales data for the first two months.</td>
</tr>
</tfoot>
</table>
Attributes of <table> tag:
align: specifies the horizontal alignment of the table in the browser window, set to ”left, center,
right”.
background: specifies the URL of a background image to be used as background for the table.
bgcolor: sets the background color of the table cells.
border: sets the border width.
bordercolor: sets the external border color of the entire table.
cellpadding: sets the spacing between cell walls and content.
cellspacing: sets the spacing between table cells.
height: sets the height of the whole table.
width: sets the width of the table.
</form>
</div>
</table>
</body>
</html>
Introduction to CSS
CSS
Css stands for Cascading Style Sheets CSS describes how HTML elements are to be displayed on
screen, paper, or in other media. CSS saves a lot of work. It can control the layout of multiple web
pages all at once.
Style sheets represent the World Wide Web consortium's effort to improve on the tag and attribute based
style of formatting. Style sheets provide a way of customizing whole pages all at once and in much richer
detail than the simple use of tags and attributes. The format of style sheet will be:
<style type=”text/css”>
selector{property:value;property:value;}
selector{property:value;property:value;}
</style>
Every line in<style> tag is called as a „Rule‟ and a style rule has two parts:
a. Selector.
b. Set of declarations.
A selector is used to create a link between the rule and the HTML tag. The declaration has two parts
again:
a. Property.
b. Value.
A property specifies additional information and value specifies property value. For example:
<style type=”text/css”>
body{background-color:#d0e4fe;}
h1 {color:orange; text-align:center;}
p {font-family:"TimesNewRoman"; font-size: 20px;}
</style>
If we add above code in the <head> element of webpage, entire webpage will be displayed in various styles
given in style element.
CSS can be added to HTML elements in 3 ways:
Inline- by using the style attribute in HTML elements
Internal/Embedded -by using a <style>element in the <head>section
External-by using an external CSS file
Inline Style Sheets:
Inline style sheets mix content with presentation. To use inline styles we use style attribute in the relevant
tag.
Example:
<!DOCTYPE html>
<html>
<head>
<title>HTML Tables</title>
</head>
<body bgcolor="pink">
<center>
<h1>Creating HTML Tables</h1><br/>
<table border="2"cellpadding="4"cellspacing="4">
<tr>
<th colspan="2"style="background-color:red">WebSites</th>
</tr>
<tr>
<th style="background-color:blue">MailSites</th>
<th style="background-color:green">JobSites</th>
</tr>
<tr>
<td style="background-color:grey">Gmail</td>
<td style="background-color:aqua">Naukri</td>
</tr>
<tr>
<td style="background-color:yellow">Yahoo</td>
<td style="background-color:purple">JobStreet</td>
</tr>
</table>
</center>
</body>
</html>
Output:
<!DOCTYPE html>
<html>
<head>
<title>ExternalStyle Sheets</title>
<link rel="stylesheet" href="[Link]">
</head>
<body>
<h1 class="h1">External Style Sheets</h1><br/>
<p class="p">Comment is a piece of code which is ignored by any web browser.
It is a good practice to add comments into your HTML code, especially in complex documents,
to indicate sections of a document, and any other notes to anyone looking at the code.
Comments help you and others understand your code and increases code readability.</p>
</body>
</html>
[Link]
body {
background-color: aqua;
}
.h1 {
color:olive;
text-align: center;
font-size:32px;
}
.p {
font-family:"Times New Roman";
font-size:20px;
}
Output:
h4{font-family:sans-serif;}
h5{font-family:serif;}
h6 { font-family: arial;}
3. CSS Font Size
o The font-size property sets the size of the text.
p{font-size:120%;}
ol{font-size:10px;}
ul{font-size:x-large;}
4. CSSFontStyle
o The font-style property is mostly used to specify italic text.
o This property has three values:
normal-The text is shown normally
italic-The text is shown in italics
oblique-The text is "leaning" (oblique is very similar to italic, but less supported)
p{font-style:italic;}
h4{font-style:oblique;}
5. CSS Font Weight
o The font-weight property sets how thick or thin characters in text should be displayed.
p{font-weight:100;}
ul{font-weight:bolder;}
6. CSS Font Variant
o The font-variant property specifies whether or not a text should be displayed in a small-caps font.
p{font-variant:small-caps;}
Explain CSS Text with all its attributes.
While CSS Font covers most of the traditional ways to format your text, CSS Text allows you to control the
spacing, decoration, and alignment of your text.
1. Text Decoration
o The text-decoration property is used to set or remove decorations from text.
o The text-decoration property is mostly used to remove underlines from links for design purposes.
h4{text-decoration:line-through;}
h5{ text-decoration: overline; }
h6{text-decoration:underline;}
a { text-decoration: none; }
2. Text Indent
o The text-indentation property is used to specify the indentation of the first line of a text.
p{text-indent:20px;}
h5{text-indent:30%;}
3. Text Align
o The text-align property is used to set the horizontal alignment of a text.
p { text-align: right; }
h5{text-align:justify;}
4. Text Transform
o The text-transform property is used to specify upper case and lower case letters in a text.
p{text-transform:capitalize;}
h5{text-transform:uppercase;}
5. CSS White Space
o The white-space attribute allows you to prevent text from wrapping until you place a break <br /> into your text.
p{white-space:nowrap;}
6. CSS Word Spacing
o With the CSS attribute word-spacing you are able to specify the exact value of the spacing between your words.
Word-spacing should be defined with exact values.
p{word-spacing:10px;}
7. CSS Letter Spacing
o With the CSS attribute letter-spacing you areable to specify the exact value of the spacing between your letters.
Letter-spacing should be defined with exact values.
p{letter-spacing:3px;}
Task-1
<!DOCTYPE html>
<html>
<head>
<title>assignment9</title>
<style>
.topbar
{
background-color: blue;
background-size: 100%;
height: 35px;
}
.ctopbar
{
width:50%;
float:left;
}
.right
{
float:right;
}
.nav
{
background-color: bisque;
width:100%;
height:130px;
}
.navimg
{
width:30%;
float:left;
}
.height
{
height:90px;
}
.navbar
{
width:70%;
float:left;
}
.img
{
width:100%;
height:450px;
}
.bd
{
background-color: burlywood;
width:100%;
height:170px;
}
.p,h1
{
text-align:center;
color: brown;
}
</style>
</head>
<body>
<div class="topbar">
<div class="ctopbar"><p>+91 7978685395</p></div>
<div class="ctopbar"><p class="right">panditsantosh666@[Link]</p></div>
</div>
<div class="nav">
<div class="navimg">
<img src="food corner [Link]" class="height"/>
</div>
<div class="navbar">
<div class="right">
<a href="[Link]">home</a>
<a href="[Link]">menu</a>
<a href="[Link]">add cart</a>
<a href="[Link]">about</a>
<a href="[Link]">contact</a>
</div>
</div>
</div>
<div class="img">
<img src="food [Link]" class="img"/>
</div>
<div class="bd">
<br/>
<h1 class="h1,p">welcome to food corner</h1>
<p class="h1,p"> your diet is a bank account.
<br/>
good food choices are good investments.
Food is any substance consumed to provide nutritional support for an organism.
Food is usually of plant, animal, or fungal origin, and contains essential nutrients,
such as carbohydrates, fats, proteins, vitamins, or minerals.
The substance is ingested by an organism and assimilated by
the organism's cells to provide energy, maintain life, or stimulate growth.
</p>
</div>
</body>
</html>
Explain BOX MODEL.
All HTML elements can be considered as boxes. In CSS, the term "box model" is used when talking about
design and layout.
The CSS box model is essentially a box that wraps around HTML elements, and it consists of: margins, borders,
padding, and the actual content.
The box model allows us to place a border around elements and space elements in relation to other elements.
The image below illustrates the box model
CSS Frameworks
CSS Frameworks are pre-written libraries that simplify and speed up the process of designing responsive, visually
consistent web interfaces. They offer ready-to-use components and grid systems, helping developers avoid repetitive
CSS from [Link] provides a solid foundation for buiding modern UIs with less code and better cross-browser
compatiblity. They promote clean design standards, enabling faster prototyping and consistent styling across projects.
CSS frameworks offer several features that make the development process more efficient and effective:
Efficiency: Pre-designed components and utility classes reduce the time spent writing CSS from scratch.
Responsive Design: Frameworks are built to adapt to various screen sizes, ensuring your design looks great on
all devices.
Cross-Browser Compatibility: Ensures consistent appearance across different browsers.
Customisation: Allows for tailored designs while maintaining a consistent structure.
Community Support: Large, active communities provide resources and support.
1. Bootstrap
Bootstrap is a popular CSS framework with strong community support, offering pre-designed layouts such
as buttons and navbars, along with utility classes. It is known for its strong community, pre-designed
layouts, and responsive features. The current version is 5.3.2, released on 14 September 2023.
Bootstrap is the most popular CSS framework, developed by Twitter. It is used for responsive grid system
and extensive components. Bootstrap allows for fast and responsive web development. It includes a 12-
column grid, pre-built components like modals, dropdowns, navigation, and more, along with JavaScript-
based elements.
Key Features
Responsive grid system
Pre-designed UI components
Cross-browser compatibility
JavaScript plugins for interactive elements
2. Tailwind CSS
Tailwind CSS is a utility-first framework that is highly customizable. Instead of offering pre-designed
components, Tailwind provides a set of utility classes that can be used to build custom designs without
writing much CSS.
Key Features
Utility-first approach for custom designs
Fully customizable with a configuration file
No predefined components, offering more control
3. Semantic UI
Semantic UI is an open-source CSS framework with good community support, using classes to add styles
to elements. It offers various components that can be easily integrated into applications to create beautiful
web pages quickly.
Key Features
Intuitive, human-readable class names
Pre-built UI components
Customizable theming system
4. Bulma
Bulma is an open-source CSS framework based on Flexbox, known for its responsiveness and for
minimizing the use of media queries. It is popular for being responsive and cost-effective. The current
version is 0.9.4, released on 8 May [Link] is a modern CSS framework based on Flexbox. It is a
lightweight, easy to use, and customizable. It provides a clean syntax and focuses on making responsive
design easier.
Key Features
Flexbox-based layout system
Lightweight and modular
Clean, simple syntax
5. Skeleton
Skeleton is a minimal CSS framework that focuses on responsive design. It’s small and lightweight,
making it ideal for quick prototyping.
Key Features
Lightweight, under 400 lines of code
Simple grid system
Ideal for quick prototypes
JavaScript:
INTRODUCTIONTO JAVASCRIPT:
Static web pages are useful and can be informative. A number of technologies have been developed
that enable the creation of web applications rather than static web pages. The java programming language
is probably the best known such technology. Few programming languages other than java have been
adapted for use in client-side web applications. One such language that is used in programming client-side
web applications is JavaScript.
JavaScript originates from a language called Live Script and was developed by Sun micro systems
and Netscape navigator. Scripts are small pieces of code which accomplish a single relatively simple task.
JavaScript is a scripting language that is used for the development of Client- side-in-browser applications.
JavaScript is a simple script based language which is only suitable for fairly simple tasks. JavaScript is a
language that is best suited to tasks that run for a short time. Most of the developers experience problems
when they try to build web pages which have embedded javascript.
What is JavaScript?
HTML and CSS concentrate on a static rendering of a page; things do not change on the page overtime, or because
of events.
To do these things, we use scripting languages, which allow content to change dynamically.
Not only this, but it is possible to interact with the user beyond what is possible with HTML.
Scripts are programs just like any other programming language; they can execute on the client side or the server.
Embedded JavaScript
JavaScript can be embedded in an HTML document.
To embed it in HTML you must write:
<script type=”text/java script”>
</script>
The script tag has effect of the stopping the JavaScript being printed out as well as indentifying the code
enclosed.
The Java Script can be placed in the head section of your HTML or the body.
<html>
<body>
<script type=”text/java script”> document. Write ("<h1>this is a heading </h1>");
</script>
</body>
</html>
The Scripts placed in the body section are executed as the page loads and can be used to generate the content
of the page.
As well as the body section, JavaScript can also be placed in the head part.
The advantages of putting a script in there are that it loads before the main body.
External JavaScript
If you want to use the same script on several pages it could be a good idea to place the code in a separate file,
rather than writing it on each.
That way if you want to update the code, or change it, you only need to do it once.
Simply take the code you want in a separate file out of your program and save it with the extension
.js.
<html>
<body>
<script src="[Link]"></script>
</body>
</html>
JavaScript Variables
Variables in JavaScript behave the same as variables in most popular programming languages(C, C++,
etc) do, but in JavaScript you don't have to declare variables before you use them.
A variable's purpose is to store information so that it can be used later. A variable is a symbolic name
that represents some data that you set.
When using a variable for the first time it is not necessary to use "var" before the variable name.
Variable names must begin with a letter.
Variable names are case sensitive (y and Y are different variables).
var x=5;
var y=6;
var z=x+y;
You can declare many variables in one statement. Just start the statement with var and separate the
variables by comma:
Var name="Doe",age=30,job="carpenter";
var name="Doe",
age=30,
job="carpenter";
Variable declared without a value will have the value undefined.
If you re-declare a JavaScript variable, it will not lose its value.
The value of the variable car name will still have the value "Volvo" after the execution of the following
two statements.
Var carname="Volvo";
Var carname;
JavaScript Operators
Operators in JavaScript are very similar to operators that appear in other programming languages.
The definition of an operator is a symbol that is used to perform an operation.
Most often these operations are arithmetic(addition, subtraction, etc),but not always.
Operator Name
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus
= Assignment
JavaScript Array
An array is a special variable, which can hold more than one value at a time.
The Array object is used to store multiple values in a single variable.
An array can be created in three ways.
The following code creates an Array object called my Cars.
1. Regular
Var my Cars=new Array();
my Cars[0]="Saab";
my Cars[1]="Volvo";
my Cars[2]="BMW";
2. Condensed
Var my Cars=new Array("Saab","Volvo","BMW");
3. Literal
Var my Cars= ["Saab","Volvo","BMW"];
Access an Array
You refer to an element in an array by referring to the index number.
This statement access the value of the first element in my Cars.
Var name=my Cars[0];
This statement modifies the first element in my Cars:
My Cars[0]="Opel";
JavaScript Functions
A function is a section of code that is separate from the main program.
It is defined once but can be invoked many times.
A function can be passed as parameters so that they can be used and a value can be returned back.
There are some functions already built into JavaScript, such as the Math. Cos () function, which
calculates the cosine of an angle.
An example function could be:
functionmultByTen(x)
{
returnx*10;
}
This can then be invoked by using the function’s name complete with any parameters you want to pass:
My sum=mult By Ten(3)
Below is an example of JavaScript function.
<html><body>
<script type=”text/javascript”>
var z= mult X by Y(10,15);
[Link](“The result is”+z); function mult X by Y(x,y)
{
[Link](“x is”+x);
[Link](“y is ”+y);
return x*y;
}
</script>
</body></html>
JavaScript alert()
The alert() method in JavaScript is used to display a virtual alert box. It is mostly used to give a warning
message to the users. It displays an alert dialog box that consists of some specified message (which is
optional) and an OK button. The syntax is:
alert ("message");
JavaScript prompt()
The prompt() method in JavaScript is used to display a prompt box that prompts the user for the input. It is
generally used to take the input from the user before entering the page. When the prompt box pops up, we
have to click "OK" or "Cancel" to proceed. Syntax is:
prompt("message"," default");
JavaScript Statements:
Programs are composed of data and code which manipulates that data. Program instructions are
grouped into units called statements. We create programs from lot of statements.
If-else:
The JavaScript if-else statement is used to execute the code whether condition is true or false. There are
three forms of if statement in JavaScript.
if Statement
if else statement
if else if statement
If statement:
It evaluates the content only if expression is true. The signature of JavaScript if statement is:
if(expression)
{
//content to be evaluated
}
Example:
<html>
<head>
<title>If statement</title>
</head>
<body bgcolor="pink">
<script type="text/javascript">
Var age=parseInt(prompt("Enter age of the person",""));
if(age>60)
{
[Link]("<h1>Senior Citizen</h1>");
}
</script>
</body>
</html>
JavaScript If...else Statement:
It evaluates the content whether condition is true of false. The syntax of JavaScript if-else statement
is:
if(expression){
//content to be evaluated if condition is true
}
else{
//content to be evaluated if condition is false
}
Example:
<html>
<head>
<title>If statement</title>
</head>
<body bgcolor="pink">
<script language="javascript">
Var n= parseInt(prompt("Enter a value",""));
if(n%2==0){
[Link](n+"is even number");
}
else{
[Link](n+"is odd number");
}
</script>
</body>
</html>
JavaScript If...else if statement:
It evaluates the content only if expression is true from several expressions. The signature of
JavaScript if else if statement is:
if(expression1){
//content to be evaluated if expression1is true
}
Else if(expression2){
//content to be evaluated if expression2 is true
}
Else if(expression3){
//content to be evaluated if expression3 is true
}
else{
//content to be evaluated if no expression is true
}
Example
:
<html>
<head>
<title>if statement</title>
</head>
<body bgcolor="pink">
<script language="javascript">
Var m1=parseInt(prompt("EnterMarks1","0"));
Var m2=parseInt(prompt("EnterMarks2","0"));
Var m3=parseInt(prompt("EnterMarks3","0"));
var avg=parseInt((m1+m2+m3)/3);
if(avg>70){ [Link]("<h1>Distinction</h1>");
}
else if(avg<70&&avg>60){ [Link]("<h1>FirstClass</h1>");
}
else if(avg<60&&avg>50){ [Link]("<h1>Secondclass</h1>");
}
else{ [Link]("<h1>Fail</h1>");
}
</script>
</body>
</html>
JavaScript Switch:
The JavaScript switch statement is used to execute one code from multiple expressions. The signature of
JavaScript switch statement is:
Switch (expression){
casevalue1:
code to be executed; break;
casevalue2:
code to be executed; break;
......
default:
code to be executed if above values are not matched;
}
Example:
<html>
<head>
<title>Switch</title>
</head>
<body bgcolor="pink">
<script language="javascript">
Var a=parseInt(prompt("Enter a value",""));
var b=parseInt(prompt("Enter b value",""));
Var ch=parseInt(prompt("Enter your choice",""));
switch(ch){
case1: [Link]("<h1>Additionis:"+(a+b)+"<h1>");
break;
case2: [Link]("<h1>Subtractionis:"+(a-b)+"<h1>");
break;
case3: [Link]("<h1>Multiplicationis:"+(a*b)+"<h1>");
break;
case4:[Link]("<h1>Divisionis:"+(a/b)+"<h1>");
break;
default: [Link]("<h1>Invalid Choice</h1>");
}
</script>
</body>
</html>
JavaScript Loops:
The JavaScript loops are used to iterate the piece of code. Various types of loops are:
1. for loop
2. while loop
3. do-while loop
JavaScript For loop:
The JavaScript for loop iterates the elements for the fixed number of times. Syntax is:
for (initialization; condition; increment)
{
Code to be executed
}
JavaScript while loop:
The JavaScript while loop iterates the elements for the infinite number of times. Syntax is:
while (condition)
{
Code to be executed
}
JavaScript do while loop:
The JavaScript do while loop iterates the elements for the infinite number of times like while loop. But,
code is executed at least once whether condition is true or false. Syntax is:
Do
{
code to be executed
}
while (condition);
Example:
<html>
<head>
<title>Multiplication</title>
</head>
<bodybgcolor="pink">
<script language="javascript">
varn=parseInt(prompt("Enteranumber",""));
var i;
for(i=1;i<=10;i++){
[Link]("<b>"+n+"*"+i+"="+(n*i)+"<br>");
}
</script>
</body>
</html>
Simple form validation:
<html>
<head>
<title>Validation</title>
<script language="javascript">
function validate()
{
Var value= [Link][0].elements[0].value;
if(value!="abc")
{
[Link][0].reset();
}
else{
alert("Hi abc");
}
}
</script>
</head>
<body bgcolor="pink">
<form>
Name:<input type="text" name="txt 1" value=""> <br>
<input type="submit" value="Submit" onClick="validate()">
</form>
</body>
</html>
Module 2
Git and GitHub Fundamentals
In the world of software development, over 90% of developers use a version control system, with Git being
the most popular choice. Git is a distributed version control system that allows developers to track changes
in code, collaborate seamlessly, and manage projects efficiently. GitHub is built on top of Git, a cloud-based
platform that provides a user-friendly interface for hosting, reviewing, and sharing code. Together, Git and
GitHub have become essential for modern development, enabling open-source collaboration and enterprise-
level project management.
Introduction to Git
A version Control system is a system that maintains different versions of your project when working in a
team or as an individual. (System managing changes to files) As the project progresses, new features get
added to it. So, a version control system maintains all the different versions of your project for you, and you
can roll back to any version you want without causing any trouble to you for maintaining different versions
by giving names to them, like MyProject, MyProjectWithFeature1, etc.
Distributed Version control system means every collaborator (any developer working on a team
project)has a local repository of the project in his/her local machine unlike central where team members
should have an internet connection to every time update their work to the main central repository.
So, by distributed we mean: the project is distributed. A repository is an area that keeps all your project files,
images, etc. In terms of GitHub: different versions of projects correspond to commits.
Git Concepts
Repository- A directory where git monitors your project files and records their revision history.
Clone- It created a local copy of a remote repository on your machine.
Stage - It selects specific changes that you want Git to include in the next snapshot.
Commit- It records the staged changes as a permanent version in the project history.
Branch- Lets you develop new features or experiment without affecting the main project.
Merge- Integrates changes from one branch into another.
Pull- It fetches and applies updates from a remote repository to your local one.
Push- It Uploads your local commits to a remote repository
Git Repository Structure
It consists of 4 parts:
1. Working directory: This is your local directory where you make the project (write code) and make
changes to it.
2. Staging Area (or index): this is an area where you first need to put your project before committing.
This is used for code review by other team members.
3. Local Repository: this is your local repository where you commit changes to the project before
pushing them to the central repository on Github. This is what is provided by the distributed version
control system. This corresponds to the .git folder in our directory.
4. Central Repository: This is the main project on the central server, a copy of which is with every team
member as a local repository.
All the repository structure is internal to Git and is transparent to the developer.
Some commands which relate to repository structure:
// transfers your project from working directory
// to staging area.
git add .
// transfers your project from staging area to
// Local Repository.
git commit -m "your message here"
eval "$(ssh-agent -s)" -> enable information about local login session.
Now, go to github settings -> new ssh key -> create key
Another way
git rebase myBranch
This merges the branch with the master in a serial fashion. Now,
git push origin master
To remove or delete a file
To remove. a file from the Git repository we use
git rm “file name”
To remove only from the staging area
git rm –cached “ file name”
Undoing change
To change all the files to as same as the previous commit then use
git checkout -f
Git vs Github
Git and GitHub are often mentioned together, but they serve different purposes. Git is a local tool used for
tracking changes in your code, while GitHub is an online platform for hosting and sharing Git
repositories. Together, they enable powerful version control and team collaboration in software
development.
Feature Git Github
Function Tracks and manages code changes Stores Git repositories in the cloud and enables
locally collaboration
Installation Must be installed on your system Accessible through a web browser (no installation
needed)
Usage Used for local version control and Used for sharing, reviewing, and managing Git
branching projects online
Collaboration Limited to local or manual sharing Real-time collaboration with teams and
contributors
Interface Command-line tool (CLI) Web-based UI and also supports Git CLI
Main Purpose Track code history and manage Centralized hub to host, view, and contribute to
changes locally Git projects
This self paced introductory course provides an in depth understanding of git and github?
Common features of such courses include:
Git Fundamentals:
Explanation of Git's core principles, including repositories, commits, and the Git workflow.
Git Commands:
Practical instruction on essential Git commands for managing code, such as git init, git add, git
commit, git push, git pull, and git clone.
Branching and Merging:
Understanding how to create and manage branches for parallel development, and how to merge changes
back into the main codebase.
GitHub Collaboration:
Learning to use GitHub for team collaboration, including creating pull requests, reviewing code, and
managing issues.
Remote Repositories:
Working with remote repositories on platforms like GitHub to store and share code.
Hands-on Practice:
Many courses incorporate practical exercises and projects to reinforce learning and build real-world
skills.
Examples of such courses include:
Getting Started with Git and GitHub
offered by institutions like IBM on platforms such as Cognitive Class and Coursera.
Introduction to Git and GitHub
as part of professional certificates, like the Google IT Automation with Python Professional Certificate on
Coursera.
Learn Git & GitHub
from platforms like Codecademy, focusing on interactive lessons and projects.
The Ultimate Git Course
by instructors like Code with Mosh, covering both essentials and advanced techniques.
Essential tools for collaboration and social coding in modern software engineering and
devOps culture?
Essential tools for modern software engineering collaboration and social coding include version control platforms
like GitHub, GitLab, and Bitbucket; communication tools such as Slack; project management software like Jira and
Asana; and documentation and knowledge-sharing platforms like Confluence. These tools facilitate code versioning,
real-time communication, task tracking, and centralized documentation, which are critical for both social coding and
DevOps workflows.
Version Control and Code Collaboration
Git: The foundational distributed version control system.
GitHub / GitLab / Bitbucket: Platforms built on Git that provide a central hub for hosting code repositories,
managing issues, and facilitating code reviews and pull requests.
Communication and Chat
Slack / Microsoft Teams: Real-time messaging platforms that enable instant conversations, project-specific
channels, and integrations with other development tools.
Zoom: Essential for remote teams to conduct virtual meetings like stand-ups, retrospectives, and sprint reviews.
Project Management and Planning
Jira: Widely used for agile project management, bug tracking, and visualizing workflows across sprints and
iterations.
Asana / Trello: Other popular tools for project and task management, helping teams organize and visualize their
work.
Documentation and Knowledge Sharing
Confluence: A collaborative wiki and documentation platform that serves as a central knowledge base for teams.
Jira / Bitbucket: Both platforms include features for managing issues and project documentation directly within
their interfaces.
DevOps Automation and Continuous Integration/Continuous Delivery (CI/CD)
GitHub Actions / GitLab CI/CD: Integrated CI/CD capabilities within code hosting platforms to automate
workflows.
Jenkins: A popular open-source automation server that can automate parts of the build, test, and deploy process.
Terraform / Ansible: Tools for infrastructure as code and configuration management, allowing teams to version
and automate their infrastructure.
Docker / Kubernetes: Containerization tools that allow teams to package applications and their dependencies and
deploy them consistently across different environments.
The course includes hands on labs git and github?
A course that includes hands-on labs for Git and GitHub will provide practical experience in version control
and collaborative software development
Hands-on Labs:
The "hands-on labs" aspect emphasizes practical application. This means learners will actively engage with Git and
GitHub through:
Setting up Repositories: Creating and configuring both local Git repositories and remote GitHub repositories.
Committing Changes: Practicing the process of tracking and committing changes to files.
Branch Management: Creating, switching between, and merging branches in various scenarios.
Collaborative Workflows: Participating in simulated or actual collaborative projects, including creating pull
requests and resolving merge conflicts.
Real-world Scenarios: Applying Git and GitHub skills to practical problems and project management tasks.
Fostering team productivity on github
Fostering team productivity on GitHub involves leveraging its features for streamlined collaboration,
efficient workflow management, and clear communication.
1. Structure and Organization:
Utilize GitHub Organizations and Teams:
Group team members into logical teams within an organization to manage access permissions to
repositories and facilitate targeted communication and notifications.
Establish Clear Repository Structure:
Organize codebases within well-defined repositories and use branches effectively for feature
development, bug fixes, and releases.
Implement Project Boards and Issues:
Use GitHub Project boards for visual task management and tracking progress. Create detailed issues for
bugs, features, and tasks, leveraging labels, assignees, and milestones for clarity and prioritization. Sub-
issues can further break down larger tasks.
2. Workflow and Automation:
Automate with GitHub Actions:
Set up CI/CD pipelines, automate testing, code quality checks, and deployment processes using GitHub
Actions to reduce manual effort and ensure consistency.
Leverage Pull Requests (PRs) for Code Review:
Encourage thorough code reviews using PRs, providing constructive feedback and ensuring code quality
before merging.
Integrate with External Tools:
Connect GitHub with other tools used by the team (e.g., communication platforms like Slack or Microsoft
Teams) for seamless notifications and information flow.
3. Communication and Collaboration:
Foster Active Communication in Issues and PRs:
Encourage team members to discuss challenges, share updates, and make decisions directly within
issues and PRs, creating a transparent and traceable record.
Utilize Discussions for Open-Ended Brainstorming:
For broader discussions, feedback, or open-ended brainstorming not tied to specific code changes,
leverage GitHub Discussions.
Establish Clear Communication Norms:
Define expectations for response times, code review etiquette, and how different types of communication
should be handled within GitHub.
4. Continuous Improvement and Learning:
Monitor and Analyze Activity (with caution):
Track relevant metrics like pull request merge times or issue resolution rates to identify bottlenecks and
areas for improvement, but avoid using metrics for individual performance evaluation.
Encourage Knowledge Sharing:
Create internal documentation within repositories or wikis to capture best practices, architectural
decisions, and common solutions.
Provide Training and Resources:
Ensure team members are proficient with GitHub's features and best practices through training or by
providing access to relevant resources.
Building Your Stunning GitHub Portfolio: A Step-by-Step Guide
Step 1: Set Up a GitHub Account
If you don’t have a GitHub account, create one at [Link]. It’s the go-to platform for version
control and hosting projects.
Step 2: Create a New Repository
1. Click on the ‘+’ sign in the top right corner.
2. Select ‘New Repository.’
3. Name your repository as [your-username].[Link]. This is crucial for GitHub Pages to work.
Step 3: Choose a Theme
GitHub Pages supports Jekyll themes. Navigate to the ‘Settings’ tab in your repository and
scroll down to the ‘GitHub Pages’ section. Choose a theme to give your portfolio a polished look.
Step 4: Customize Your Portfolio
1. Access your repository’s code.
2. Open the _config.yml file to configure settings such as your name, bio, and social media links.
3. Add or edit Markdown files in the _posts directory to showcase your projects.
Step 5: Project Pages
Create a new directory for each project. Include an [Link] file with project details, images, and
code snippets. Link these project pages from your main portfolio page.
Step 6: Local Testing with Jekyll (Optional)
If you want to test your site locally, install Jekyll by following the official guide. Run bundle exec
jekyll serve in your project directory and access [Link] in your browser.
Step 7: Commit and Push Changes
Once satisfied with your changes, commit them to your repository and push to GitHub.
git add .
git commit -m "Add project pages and customize portfolio"
git push origin master
Step 8: Access Your Portfolio
Visit [your-username].[Link] in your browser. Voilà! Your portfolio is live.
Tips for a Standout Portfolio:
Clear Introduction: Briefly introduce yourself and your skills.
Project Showcase: Highlight key projects. Include project descriptions, technologies used,
and links to the GitHub repositories or live demos.
Blog Section (Optional): Share your insights and experiences in the tech world.
Contact Information: Make it easy for visitors to get in touch.
Providing a valuable addition to their resume github skills
1. Showcase Relevant Projects:
Highlight key projects:
Select projects that align with the target job's requirements and demonstrate proficiency in relevant technologies
and languages.
Provide clear descriptions:
Each project should have a concise and informative [Link] file explaining its purpose, technologies used, and
how to run or interact with it.
Emphasize impact and results:
If possible, quantify achievements within projects (e.g., improved performance by X%, reduced errors by Y%).
2. Demonstrate Git Proficiency:
Consistent contributions:
Maintain an active GitHub profile with regular commits, showcasing consistent engagement and development.
Branching and merging:
Utilize effective branching strategies for feature development and demonstrate clean merging practices.
Pull requests and code reviews:
Engage in pull requests, both creating and reviewing, highlighting collaboration and attention to code quality.
Issue tracking and project management:
Demonstrate experience with GitHub's issue tracking features for managing tasks and bugs.
3. Emphasize Collaboration and Open Source:
Contributions to open-source projects:
Participation in open-source projects demonstrates a willingness to collaborate and contribute to the wider
developer community.
Team projects:
Highlight projects where collaboration was a key element, showcasing teamwork and communication skills.
4. Optimize Your GitHub Profile:
Professional profile picture and bio:
Use a professional image and a concise, informative bio that reflects your skills and career aspirations.
Pinned repositories:
Pin your most impressive and relevant projects to the top of your profile for easy visibility.
Organized repositories:
Maintain clear and well-structured repositories with appropriate naming conventions and file organization.
5. Integrate GitHub into Your Resume:
Include your GitHub profile link:
Place a clear and accessible link to your GitHub profile in your contact information or a dedicated "Portfolio"
section.
Mention specific projects:
In your "Experience" or "Projects" section, briefly describe key GitHub projects and link directly to their repositories.
List "Git" and "GitHub" in your skills section:
Include these as technical skills, potentially alongside other version control systems or collaboration tools.
Module 3
Developing Front-End Apps with React
Advanced ReactJS
ReactJS is a popular library for building modern user interfaces. While many developers are familiar with
its basic concepts like components, state, and props, there are advanced features that can take your React
apps to the next level. By exploring these features, you can optimize performance, manage complex
states, and create more dynamic, efficient, and scalable applications.
Rendering and Re-rendering in React
In React, rendering and re-rendering are key concepts to understand, as they directly affect how efficiently
your app updates and displays content.
Rendering in React
Rendering is the process where React takes the component's data (state and props) and turns it into a UI that
the user can interact with. When a component is first loaded, React renders the component and displays it in
the DOM.
import React from "react";
function MyComp() {
return <h1>Hello, World!</h1>;
}
function App() {
return (
<div>
<h1>React App with Higher-Order Component (HOC)</h1>
<EnhancedDisplayMessage message="Hello, World!" />
</div>
);
}
[Link]
function withLogging(WrappedComponent) {
return function msg(props) {
[Link]
function App() {
return (
<[Link] value="Hello from Context!">
<div>
<h1>React Context API Example</h1>
<ChildComponent />
</div>
</[Link]>
);
}
[Link]
[Link]
function ChildComponent() {
const contextValue = useContext(MyContext);
[Link]('Context Value:', contextValue);
return <p>{contextValue}</p>;
}
[Link]
return (
<div>
<h1>{count}</h1>
<button onClick={() => dispatch(increment())}>Increment</button>
</div>
);
};
const initialState = {
count: 0,
theme: 'light',
};
[Link]
Error Boundaries
Error Boundaries are React components that catch JavaScript errors anywhere in their child component
tree, log those errors, and display a fallback UI instead of crashing the whole app.
[Link]
function App() {
return (
<div>
<h1>React Error Boundaries Example</h1>
static getDerivedStateFromError(error) {
// Update state to show fallback UI
return { hasError: true, errorMessage: [Link] };
}
componentDidCatch(error, info) {
// Log the error for debugging (optional)
[Link]('Error caught by ErrorBoundary:', error);
[Link]('Error information:', info);
}
render() {
if ([Link]) {
// Fallback UI if there is an error
return (
<div>
<h1>Something went wrong:</h1>
<p>{[Link]}</p>
</div>
);
}
[Link]
function BuggyComponent() {
const [count, setCount] = useState(0);
if (count === 5) {
// Simulate an error when count is 5
throw new Error('I crashed!');
}
return (
<div>
<h1>Count: {count}</h1>
<button onClick={() => setCount(count + 1)}>Increment</button>
</div>
);
}
Reconciliation Algorithm
The Reconciliation Algorithm in React is the process of comparing the new Virtual DOM with the
previous one and determining the minimal set of changes required to update the Real DOM efficiently.
This is important for React’s performance, as it allows React to make updates with minimal computational
overhead, resulting in faster rendering.
How Reconciliation Works in React?
When the state or props of a React component change, React needs to update the UI. Here’s how the
Reconciliation process works step-by-step:
Virtual DOM Creation: When a component is rendered, React first creates a Virtual DOM (an in-
memory representation of the real DOM) to describe what the UI should look like.
Change in State/Props: When the state or props of a component change (e.g., through setState() or
useState()), React triggers a re-render of that component.
New Virtual DOM Tree: React creates a new Virtual DOM based on the updated state or props. This
tree represents the desired UI after the update.
Comparison (Diffing): React compares the new Virtual DOM tree with the previous one. This process
is known as "diffing". React uses a series of heuristics to make this comparison more efficient.
Minimal Updates to Real DOM: After identifying the differences (or "diffs") between the old and
new Virtual DOM, React applies the minimal set of changes to the Real DOM. These are the "patches"
that update the actual page on the screen.
Server-Side Rendering (SSR) and Static Site Generation (SSG)
Server-Side Rendering (SSR) and Static Site Generation (SSG) are techniques that pre-render content on
the server side to improve SEO and performance. React supports SSR with frameworks like [Link],
which provides an easy-to-use setup for building applications with SSR and SSG.
1. Server-Side Rendering (SSR):
Server-Side Rendering is a technique where the HTML for a page is generated on the server at the time
the request is made by the user, rather than in the browser.
How SSR Works
When a user requests a page (for example, by visiting a URL), the server generates the HTML content
for that page on the fly.
The server sends the fully rendered HTML to the browser, which then displays the content to the user.
Once the initial HTML is loaded, JavaScript runs on the client-side to make the page interactive (by
attaching event listeners, fetching data, etc.).
2. Static Site Generation (SSG):
Static Site Generation is a technique where the HTML for a page is generated at build time instead of
runtime. The pages are pre-rendered into static HTML files that are served to the user.
How SSG Works
During build time, all pages of the website are rendered into static HTML files.
These static files are saved and served by the server or CDN (Content Delivery Network) when
requested by the user.
The user receives the static HTML immediately, and JavaScript is used for adding interactivity on the
client side.
React Hooks: Advanced Usage
useReducer: Manage complex state logic in functional components.
useCallback & useMemo: Optimize performance by memoizing functions and values.
Custom Hooks: Reuse logic across components efficiently.
Building Rich Front-End Applications with React and ES6
Building Rich Features:
State Management: For complex applications, libraries like Redux or the React Context API can be used to manage
global application state effectively.
Routing: React Router is a popular library for managing navigation and different views within a single-page
application.
API Integration: Fetching data from external APIs using fetch or libraries like Axios to populate and update the UI.
User Interface Libraries: Utilizing UI component libraries (e.g., Material-UI, Ant Design, Chakra UI) to accelerate
development and ensure consistent design.
Performance Optimization: Techniques like memoization (e.g., [Link], useMemo), code splitting, and lazy
loading to improve application speed and responsiveness.
Development Workflow:
Setup: Use create-react-app or a build tool like Vite to quickly set up a new React project with a pre-configured
development environment.
Component Development: Break down the UI into smaller, manageable components, leveraging functional
components and Hooks where appropriate.
State and Data Management: Implement state management strategies, whether local component state, Context
API, or a library like Redux.
Styling: Apply styles using CSS, CSS-in-JS libraries, or pre-processors like Sass.
Testing: Write unit and integration tests for components and application logic using tools like Jest and React Testing
Library.
Deployment: Build the application for production and deploy it to a hosting platform.
React Components
In React, components are reusable, independent code blocks (A function or a class) that define the
structure and behavior of the UI. They accept inputs (props or properties) and return elements that
describe what should appear on the screen.
Key Concepts of React Components:
Each component handles its own logic and UI rendering.
Components can be reused throughout the app for consistency.
Components accept inputs via props and manage dynamic data using state.
Only the changed component re-renders, not the entire page.
Example:
import React from 'react';
// Creating a simple functional component
function Greeting() {
return (
<h1>Hello, welcome to React!</h1>
);
}
export default Greeting;
Output:
Hello, welcome to React!
Types of React Components
There are two primary types of React components:
1. Functional Components
Functional components are simpler and preferred for most use cases. They are JavaScript
functions that return React elements. With the introduction of React Hooks, functional components
can also manage state and lifecycle events.
Stateless or Stateful: Can manage state using React Hooks.
Simpler Syntax: Ideal for small and reusable components.
Performance: Generally faster since they don’t require a 'this' keyword.
function Greet(props) {
return <h1>Hello, {[Link]}!</h1>;
}
2. Class Components
Class components are ES6 classes that extend [Link]. They include additional features
like state management and lifecycle methods.
State Management: State is managed using the [Link] property.
Lifecycle Methods: Includes methods like componentDidMount,componentDidUpdate, etc.
class Greet extends [Link] {
render() {
return <h1>Hello, {[Link]}!</h1>;
}
}
Props in React Components
Props (short for properties) are read-only inputs passed from a parent component to a child
component. They enable dynamic data flow and reusability.
Props are immutable.
They enable communication between components.
function Greet(props) {
return <h2>Welcome, {[Link]}!</h2>;
}
// Usage
<Greet username="Anil" />;
State in React Components
The state is a JavaScript object managed within a component, allowing it to maintain and update its
own data over time. Unlike props, state is mutable and controlled entirely by the component.
State updates trigger re-renders.
Functional components use the useState hook to manage state.
function Counter() {
const [count, setCount] = [Link](0);
return (
<div>
<p>Count: {count}</p>
<button onClick={() =>
setCount(count + 1)}>Increment</button>
</div>
);
}
Rendering a Component
Rendering a component refers to displaying it on the browser. React components can be rendered
using the [Link]() method or by embedding them inside other components.
Ensure the component is imported before rendering.
The [Link] method is generally used in the root file.
[Link](<Greeting name="Pooja" />, [Link]('root'));
Components in Components
In React, you can nest components inside other components to build a modular and hierarchical
structure.
Components can be reused multiple times within the same or different components.
Props can be passed to nested components for dynamic content.
function Header() {
return <h1>Welcome to My Site</h1>;
}
function Footer() {
return <p>© 2024 My Company</p>;
}
function App() {
return (
<div>
<Header />
<p>This is the main content.</p>
<Footer />
</div>
);
}
Introduction to TypeScript
TypeScript is a statically typed superset of JavaScript that compiles to plain JavaScript. It adds
features like static typing, interfaces, generics, and modern ECMAScript support, helping developers
catch errors early and build scalable applications with better tooling such as autocompletion,
refactoring, and debugging.
It is a compiled language, meaning TypeScript code is first converted into JavaScript before
execution.
Strong typing reduces runtime errors.
It makes code more predictable, maintainable, and easier to debug.
Client-Side:
Used for controlling the browser and its DOM (Document Object Model).
Handles user events like clicks, form inputs, and rendering dynamic content.
Common frameworks and libraries like Angular, React, and Vue offer strong TypeScript support for
building large-scale front-end applications.
Server-Side:
Used for interacting with databases, handling APIs, file manipulation, and generating responses.
[Link] with TypeScript, along with frameworks like Express or NestJS, is widely used to build type-
safe backend applications.
Type definitions help catch errors early and make server-side code more reliable and maintainable.
JavaScript Vs TypeScript
JavaScript TypeScript
A lightweight, interpreted scripting language A superset of JavaScript that adds static typing and
used for web development. advanced features.
Dynamically typed (types are checked at Statically typed (optional) – types are checked at compile
runtime). time.
Runs directly in browsers or [Link] (no Must be compiled to JavaScript using the TypeScript
compilation needed). compiler (tsc).
Errors appear only at runtime. Errors are caught at compile time, reducing runtime bugs.
Supports ES6+ features depending on the Supports all modern ES6+ features, plus extra
environment. TypeScript-only features.
[Link](port, () => {
[Link](`Example app listening on port ${port}!`);
});
The first two lines require() (import) the express module and create an Express application. This object,
which is traditionally named app, has methods for routing HTTP requests, configuring middleware,
rendering HTML views, registering a template engine, and modifying application settings that control how
the application behaves (e.g., the environment mode, whether route definitions are case sensitive, etc.)
The middle part of the code (the three lines starting with [Link]) shows a route definition.
The [Link]() method specifies a callback function that will be invoked whenever there is an
HTTP GET request with a path ('/') relative to the site root. The callback function takes a request and a
response object as arguments, and calls send() on the response to return the string "Hello World!"
The final block starts up the server on a specified port ('3000') and prints a log comment to the console. With
the server running, you could go to localhost:3000 in your browser to see the example response returned.
To make objects available outside of a module you just need to expose them as additional properties on
the exports object. For example, the [Link] module below is a file that exports area() and perimeter() methods:
[Link] = function (width) {
return width * width;
};
[Link] = function (width) {
return 4 * width;
};
[Link]("First");
[Link]("Second");
By contrast, an asynchronous API is one in which the API will start an operation and immediately return (before the
operation is complete). Once the operation finishes, the API will use some mechanism to perform additional
operations. For example, the code below will print out "Second, First" because even though setTimeout() method
is called first, and returns immediately, the operation doesn't complete for several seconds.
setTimeout(() => {
[Link]("First");
}, 3000);
[Link]("Second");
Using non-blocking asynchronous APIs is even more important on Node than in the browser
because Node applications are often written as a single-threaded event-driven execution environment.
"Single threaded" means that all requests to the server are run on the same thread (rather than being spawned
off into separate processes). This model is extremely efficient in terms of speed and server resources.
However, it does mean that if any of your functions call synchronous methods that take a long time to
complete, they will block not only the current request, but every other request being handled by your web
application.
There are multiple ways for an asynchronous API to notify your application that it has completed.
Historically, the approach used was to register a callback function when invoking the asynchronous API,
which is then called when the operation completes
Can lead to "callback hell" Allows chaining with .then() Provides a more synchronous-
with nested functions, and .catch(), improving like flow, enhancing
Readability making code hard to read. readability. readability.
What is Callback?
Callbacks are functions passed as arguments to other functions and are executed once a specific
task is completed. They are commonly used in JavaScript for handling asynchronous operations but
can lead to "callback hell" when nested multiple times.
// Callback function to process user data
function process(data, callback) {
[Link]("Processing user data:", data);
callback();
}
Output
Processing user data: { id: 1, name: 'Pushkar' }
User data processed successfully.
In this example
Callbacks are passed as arguments to other functions.
They execute once the asynchronous operation is completed.
Callback hell can occur with multiple nested callbacks, making the code harder to read and
maintain.
What is Promises?
Promises offer a more structured approach to handle asynchronous operations, addressing the
callback hell problem. They represent the eventual completion (or failure) of an asynchronous task.
//Function to fetch user data with a Promise
function fetch() {
// Simulating an API request
const user = { id: 1, name: "Pushkar" };
Output
Processing user data: { id: 1, name: 'Pushkar' }
User data processed successfully.
In this example
Promises represent the completion of an asynchronous task.
They are chained with .then() for successful completion and .catch() for errors.
Promises improve readability compared to callbacks, preventing nested structures.
What is Async/Await?
Async/Await is built on top of Promises and allows asynchronous code to be written in a
synchronous style, making it easier to read and understand.
// Function to fetch user data with Async/Await
async function fetch() {
// Simulating an API request
const user = { id: 1, name: "Pushkar" };
// Using Async/Await
process();
Output
Processing user data: { id: 1, name: 'Pushkar' }
User data processed successfully.
In this example
Async/Await simplifies asynchronous code, making it appear synchronous.
The await keyword pauses the execution until the Promise is resolved.
Async/Await is ideal for handling multiple asynchronous operations in a clear, easy-to-read way.
When to Use Callbacks
Callbacks are suitable for simple asynchronous operations where you only need to handle one or
two asynchronous tasks. They are the original way to handle asynchronous code in JavaScript.
Simple Asynchronous Tasks: When you have a single asynchronous operation to perform,
callbacks can be straightforward.
Legacy Code: You might encounter callbacks in older JavaScript codebases or libraries.
When to Use Promises
Promises are a better choice for managing more complex asynchronous code, especially when you
have multiple operations that depend on each other.
Chaining Asynchronous Operations: Promises excel when you need to execute asynchronous
tasks sequentially.
Improved Error Handling: Promises provide a cleaner way to handle errors compared to
callbacks.
Modern JavaScript APIs: Many modern JavaScript APIs and libraries are promise-based.
When to Use Async/Await
async/await is generally the preferred way to work with asynchronous code in modern JavaScript. It
makes asynchronous code look and behave a bit more like synchronous code.
Readability and Maintainability: async/await significantly improves the readability of complex
asynchronous code.
Simplified Control Flow: async/await allows you to use familiar control flow structures (like if
statements and loops) within your asynchronous code.
Working with Promises: async/await is built on top of promises, so it works seamlessly with
promise-based APIs. It's generally the best approach when dealing with promises.
Creating REST APIs that perform CRUD operations is a fundamental concept in web development. CRUD stands
for Create, Read, Update, and Delete, the four basic functions for managing data in any application. REST
(Representational State Transfer) is an architectural style that maps these operations to standard HTTP methods.
Mapping CRUD to HTTP Methods
In a REST API, each CRUD operation corresponds to a specific HTTP method, which provides a uniform interface for
client-server interaction.
CRUD Description HTTP Method Typical URL Endpoint Typical
Operation (Resource: users ) Success
Status Code
Create Add new POST /users 201 (Created)
resources to
the database.