SlideShare a Scribd company logo
1 of 365
Unit 2
What are the different image file
formats?
ā€¢ Image Format describes how data related to
the image will be stored.
ā€¢ Data can be stored in compressed,
Uncompressed or vector format.
ā€¢ Each format of the image have a different
advantage and disadvantage.
ā€¢ Image types such a TIFF are good for printing
while JPG or PNG, are best for web.
ā€¢ JPEG (.jpg, .jpeg)
Joint Photographic Experts Group is a loss-prone (lossy)
format in which data is lost to reduce size of image.
Due to compression, some data is lost but that loss is
very less. It is a very common format and are good for
digital cameras, nonprofessional prints, E-Mail,
Powerpoint etc., making it ideal for web use.
ā€¢ GIF (.gif)
GIF or Graphics Interchange Format files are used for
web graphics.They can be animated and are limited to
only 256 colors, can allow for transparency. GIF files
are typically small is size and are portable.
ā€¢ PNG (.png)
PNG or Portable Network Graphics files are a lossless
image format. It was designed to replace gif format as
gif supported 256 colors unlike PNG which support 16
million colors.
Difference between Server Side
Scripting and Client Side Scripting
ā€¢ 1. Client side scripting :
web browsers execute client side scripting. It is use when
browsers has all code.
ā€¢ Source code used to transfer from web server to userā€™s
computer over internet and run directly on browsers. It is
also used for validations and functionality for user events.
ā€¢ It allows for more interactivity.
ā€¢ It usually performs several actions without going to user.
ā€¢ It cannot be basically used to connect to databases on web
server.
ā€¢ Pages are altered on basis of users choice. It can also used
to create ā€œcookiesā€ that store data on userā€™s computer
Example
ā€¢ 2. Server side scripting :
Web servers are used to execute server side scripting.
They are basically used to create dynamic pages.
ā€¢ It can also access the file system residing at web server.
Server-side environment that runs on a scripting
language is a web-server.
ā€¢ Scripts can be written in any of a number of server-side
scripting language available.
ā€¢ It is used to retrieve and generate content for dynamic
pages. A dynamic page displays different content for
different users while retaining the same layout and
design
ā€¢ It is used to require to download plugins. In this load
times are generally faster than client-side scripting.
When you need to store and retrieve information a
database will be used to contain data. It can use huge
resources of server.
ā€¢ It reduces client-side computation overhead. Server
sends pages to request of user/client.
For example in a social media site, if you request info about @myFriend
the server will look up that user and return his profile if found.
What is JavaScript
ā€¢ JavaScript (js) is a light-weight object-oriented
programming language which is used by several
websites for scripting the webpages.
ā€¢ It is an interpreted, full-fledged programming
language that enables dynamic interactivity on
websites when applied to an HTML document.
ā€¢ It was introduced in the year 1995 for adding
programs to the webpages in the Netscape
Navigator browser.
ā€¢ Since then, it has been adopted by all other
graphical web browsers. A process is said to be lightweight if it occupies
less Memory and takes less processor time to
complete.
Advantages and Disadvantages of
JavaScript
JavaScript Example
The write() method in HTML is used to write some
content or JavaScript code in a Document. This method
is mostly used for testing purpose.
JavaScript Example
ā€¢ Javascript example is easy to code.
ā€¢ JavaScript provides 3 places to put the
JavaScript code: within body tag, within head
tag and external JavaScript file.
ā€¢ Letā€™s create the first JavaScript example.
ā€¢ The text/javascript is the content type that
provides information to the browser about the
data.
ā€¢ The document.write() function is used to
display dynamic content through JavaScript.
We will learn about document object in detail
later.
3 Places to put JavaScript code
1. Between the body tag of html
2. Between the head tag of html
3. In .js file (external javaScript)
1) JavaScript Example : code between
the body tag
ā€¢ In the above example, we have displayed the
dynamic content using JavaScript.
ā€¢ Letā€™s see the simple example of JavaScript that
displays alert dialog box
2) JavaScript Example : code between
the head tag
ā€¢ Letā€™s see the same example of displaying alert
dialog box of JavaScript that is contained
inside the head tag.
ā€¢ In this example, we are creating a function
msg().
ā€¢ To create function in JavaScript, you need to
write function with function_name as given
below.
ā€¢ To call function, you need to work on event.
Here we are using onclick event to call msg()
function.
output
3. External JavaScript file
ā€¢ We can create external JavaScript file and
embed it in many html page.
ā€¢ It provides code re usability because single
JavaScript file can be used in several html
pages.
ā€¢ An external JavaScript file must be saved by .js
extension. It is recommended to embed all
JavaScript files into a single file. It increases
the speed of the webpage.
ā€¢ Let's create an external JavaScript file that
prints Hello Javatpoint in a alert dialog box.
message.js
function msg(){
alert("Hello JavatScript");
}
ā€¢ Let's include the JavaScript file into html page.
ā€¢ It calls the JavaScript function on button click.
JavaScript String replace() Method
ā€¢ The JavaScript string replace() method is used
to replace a part of a given string with a new
substring.
ā€¢ This method searches for specified regular
expression in a given string and then replace it
if the match occurs.
ā€¢ We can use global search modifier with
replace() method to replace all the match
elements otherwise the method replace only
first match. JavaScript also provides ignore flag
to make the method case-insensitive.
Parameter
ā€¢ originalstr - It represents the string to be
searched and replaced.
ā€¢ Newstr - It represents the new string that
replaced with the searched string.
JavaScript String charAt() Method
ā€¢ The JavaScript string charAt() method is used
to find out a char value present at the
specified index in a string.
ā€¢ The index number starts from 0 and goes to n-
1, where n is the length of the string.
ā€¢ The index value can't be a negative, greater
than or equal to the length of the string.
ā€¢ Parameter
ā€¢ index - It represent the position of a character.
JavaScript Math abs() method
ā€¢ The JavaScript math abs() method returns an
absolute value of a given number.
ā€¢ The abs() is a static method of Math.
JavaScript Math abs() method
example
JavaScript Date getDate() method
ā€¢ The JavaScript date getDate() method returns
the day for the specified date on the basis of
local time.
Difference between var and let in
JavaScript
ā€¢ var and let are both used for variable
declaration in javascript but the difference
between them is that var is function scoped
and let is block scoped.
It can be said that a variable declared with var
is defined throughout the program as
compared to let.
Output
Javascript Data Types
ā€¢ JavaScript provides different data types to
hold different types of values.
ā€¢ There are two types of data types in
JavaScript.
1. Primitive data type
2. Non-primitive (reference) data type
ā€¢ JavaScript is a dynamic type language, means
you don't need to specify type of the variable
because it is dynamically used by JavaScript
engine.
ā€¢ You need to use var here to specify the data
type.
ā€¢ It can hold any type of values such as
numbers, strings etc.
ā€¢ For example:
JavaScript primitive data types
ā€¢ There are five types of primitive data types in
JavaScript.
ā€¢ They are as follows:
JavaScript non-primitive data types
ā€¢ The non-primitive data types are as follows:
JavaScript Operators
1. Arithmetic Operators
2. Comparison (Relational) Operators
3. Bitwise Operators
4. Logical Operators
5. Assignment Operators
6. Special Operators
JavaScript Arithmetic Operators
ā€¢ Arithmetic operators are used to perform
arithmetic operations on the operands.
ā€¢ The following operators are known as
JavaScript arithmetic operators.
JavaScript Comparison Operators
ā€¢ The JavaScript comparison operator compares
the two operands.
ā€¢ The comparison operators are as follows:
JavaScript Bitwise Operators
ā€¢ The bitwise operators perform bitwise
operations on operands.
ā€¢ The bitwise operators are as follows:
Bitwise Operator </h2>
Bitwise Operator
JavaScript Logical Operators
ā€¢ The following operators are known as
JavaScript logical operators.
JavaScript Assignment Operators
ā€¢ The following operators are known as
JavaScript assignment operators.
JavaScript Special Operators
ā€¢ The following operators are known as
JavaScript special operators.
assignment operator<h2>
assignment operator
Output
JavaScript Loops
ā€¢ The JavaScript loops are used to iterate the
piece of code using for, while, do while or for-
in loops.
ā€¢ It makes the code compact.
ā€¢ It is mostly used in array.
ā€¢ There are four types of loops in JavaScript.
1. for loop
2. while loop
3. do-while loop
4. for-in loop
1) JavaScript For loop
ā€¢ The JavaScript for loop iterates the elements
for the fixed number of times.
ā€¢ It should be used if number of iteration is
known.
ā€¢ The syntax of for loop is given below.
Letā€™s see the simple example of for
loop in javascript.
2) JavaScript while loop
ā€¢ The JavaScript while loop iterates the
elements for the infinite number of times.
ā€¢ It should be used if number of iteration is not
known.
ā€¢ The syntax of while loop is given below.
Letā€™s see the simple example of while
loop in javascript.
3) 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.
ā€¢ The syntax of do while loop is given below.
Letā€™s see the simple example of do
while loop in javascript.
4) JavaScript for in loop
ā€¢ The JavaScript for in loop is used to iterate the
properties of an object.
JavaScript Functions
ā€¢ JavaScript functions are used to perform
operations.
ā€¢ We can call JavaScript function many times to
reuse the code.
ā€¢ Advantage of JavaScript function
ā€¢ There are mainly two advantages of JavaScript
functions.
ā€¢ Code reusability:
ā€¢ We can call a function several times so it save
coding.
ā€¢ Less coding:
ā€¢ It makes our program compact.
ā€¢ We donā€™t need to write many lines of code each
time to perform a common task.
ā€¢ where, function_name represents the name
of the function and parameter-1, ... ,
parameter-n represents list of parameters.
JavaScript Function Syntax
ā€¢ The syntax of declaring function is given
below.
JavaScript Functions can have 0 or more arguments.
JavaScript Function Example
ā€¢ Letā€™s see the simple example of function in
JavaScript that does not has arguments.
JavaScript Function Arguments
ā€¢ We can call function by passing arguments.
Letā€™s see the example of function that has one
argument.
Function with Return Value
ā€¢ We can call function that returns a value and
use it in our program.
ā€¢ Letā€™s see the example of function that returns
value.
Using Iterative approach
ā€¢ Here, we are iterating a loop over the
sequence of numbers to get the factorial of a
given number.
ā€¢ Using this approach, the consumption of
memory is less than the recursive
implementation.
ā€¢ But the code is lengthier than the recursive
method.
Example
ā€¢ In this example, there is a text field that
requires a number and a button, which gives
us the factorial of the entered number.
ā€¢ We have to enter a number in the given
textfield to find the factorial of that number.
ā€¢ Then we need to click the given button
named Factorial to get the result.
ā€¢ If we enter a negative number, then the
program calculates the factorial of 0, which
is 1.
Factorial of a number using JavaScript
Using Recursive approach
ā€¢ In this approach, we are using recursion to
calculate the factorial of a number.
ā€¢ Here, we call same function again and again to
get the factorial. Using recursion, we have to
code less than the iterative approach.
ā€¢ Now, we will see an example of finding the
factorial of number using recursion in
JavaScript.
Example
ā€¢ Here there is a function fact(), which accepts a
parameter num. It is a number for which we
need to calculate the factorial.
ā€¢ The function returns 1 when the value
of num is 0.
ā€¢ In the output we will see a text field that
requires number and a button which gives us
the factorial of the entered number.
ā€¢ We have to enter a number in the given
textfield to find the factorial of that number.
Then we need to click the given button named
as Factorial to get the result.
JavaScript Objects
ā€¢ A javaScript object is an entity having state
and behavior (properties and method).
ā€¢ For example: car, pen, bike, chair, glass,
keyboard, monitor etc.
ā€¢ JavaScript is an object-based language.
Everything is an object in JavaScript.
ā€¢ JavaScript is template based not class based.
Here, we don't create class to get the object.
But, we direct create objects.
Creating Objects in JavaScript
ā€¢ There are 3 ways to create objects.
1. By object literal
2. By creating instance of Object directly (using
new keyword)
3. By using an object constructor (using new
keyword)
1) JavaScript Object by object literal
ā€¢ The syntax of creating object using object
literal is given below:
As you can see, property and value is separated by : (colon).
2) By creating instance of Object
ā€¢ The syntax of creating object directly is given
below:
3) By using an Object constructor
ā€¢ Here, you need to create function with
arguments.
ā€¢ Each argument value can be assigned in the
current object by using this keyword.
ā€¢ The this keyword refers to the current object.
ā€¢ The example of creating object by object
constructor is given below.
Defining method in JavaScript Object
ā€¢ We can define method in JavaScript object.
But before defining method, we need to add
property in the function with same name as
method.
ā€¢ The example of defining method in object is
given below.
JavaScript Array
ā€¢ JavaScript array is an object that represents a
collection of similar type of elements.
ā€¢ There are 3 ways to construct array in
JavaScript
1. By array literal
2. By creating instance of Array directly (using
new keyword)
3. By using an Array constructor (using new
keyword)
1) JavaScript array literal
ā€¢ The syntax of creating array using array literal
is given below:
As you can see, values are contained inside [ ] and
separated by , (comma).
Note: Literals are constant values that can be assigned to the
variables
ā€¢ Let's see the simple example of creating and
using array in JavaScript
Output of the above example
2) JavaScript Array directly (new
keyword)
ā€¢ The syntax of creating array directly is given
below:
ā€¢ Here, new keyword is used to create instance
of array.
Let's see the example of creating
array directly.
output
3) JavaScript array constructor (new
keyword)
ā€¢ Here, you need to create instance of array by
passing arguments in constructor so that we
don't have to provide value explicitly.
The example of creating object by
array constructor is given below.
output
Array Methods
ā€¢ The following table lists the standard methods
of the Array object.
JavaScript Built-in Objects
ā€¢ Built-in Objects
ā€¢ Built-in objects are not related to any Window
or DOM object model.
ā€¢ These objects are used for simple data
processing in the JavaScript.
Example: Simple Program on Math
Object Properties
JavaScript Events
ā€¢ The change in the state of an object is known as
an Event.
ā€¢ In html, there are various events which represents that
some activity is performed by the user or by the
browser.
ā€¢ When javascript code is included in HTML, js react over
these events and allow the execution. This process of
reacting over the events is called Event Handling.
ā€¢ Thus, js handles the HTML events via Event Handlers.
ā€¢ For example, when a user clicks over the browser, add
js code, which will execute the task to be performed on
the event.
ā€¢ Some of the HTML events and their event handlers are:
JavaScript onclick event
JavaScript addEventListener()
ā€¢ The addEventListener() method is used to attach
an event handler to a particular element.
ā€¢ It does not override the existing event handlers.
Events are said to be an essential part of the
JavaScript.
ā€¢ A web page responds according to the event that
occurred.
ā€¢ Events can be user-generated or generated by
API's. An event listener is a JavaScript's procedure
that waits for the occurrence of an event.
ā€¢ The addEventListener() method is an inbuilt
function of JavaScript. We can add multiple event
handlers to a particular element without
overwriting the existing event handlers.
Parameter Values
Example
ā€¢ It is a simple example of using the
addEventListener() method.
ā€¢ We have to click the given HTML button to see
the effect.
ā€¢ Now, in the next example we will see how to
add many events to the same element
without overwriting the existing events.
Example
ā€¢ In this example, we are adding multiple events
of a different type to the same element.
Using JavaScript
ā€¢ In this example, we are using
JavaScript's onclick event.
ā€¢ Here we are using the onclick event with the
paragraph element.
ā€¢ When the user clicks on
the paragraph element, the corresponding
function will get executed, and the text of the
paragraph gets changed.
ā€¢ On clicking the <p> element, the background
color, size, border, and color of the text will
also get change.
Using addEventListener() method
ā€¢ In this example, we are using
JavaScript's addEventListener() method to
attach a click event to the paragraph element.
ā€¢ When the user clicks the paragraph element,
the text of the paragraph gets changed.
ā€¢ On clicking the paragraph, the background
color and font-size of elements will also
change.
Window Object
ā€¢ The window object represents a window in
browser.
ā€¢ An object of window is created automatically
by the browser.
ā€¢ Window is the object of browser, it is not the
object of javascript.
ā€¢ The javascript objects are string, array, date
etc.
Methods of window object
Example of alert() in javascript
ā€¢ It displays alert dialog box.
ā€¢ It has message and ok button.
Example of confirm() in javascript
ā€¢ It displays the confirm dialog box.
ā€¢ It has message with ok and cancel buttons.
Example of prompt() in javascript
ā€¢ It displays prompt dialog box for input.
ā€¢ It has message and textfield.
Example of open() in javascript
ā€¢ It displays the content in a new window.
Example of setTimeout() in javascript
ā€¢ It performs its task after the given
milliseconds.
What is CSS
ā€¢ CSS stands for Cascading Style Sheets.
ā€¢ It is a style sheet language which is used to
describe the look and formatting of a document
written in markup language.
ā€¢ It provides an additional feature to HTML.
ā€¢ It is generally used with HTML to change the
style of web pages and user interfaces.
ā€¢ It can also be used with any kind of XML
documents including plain XML, SVG and XUL.
ā€¢ CSS is used along with HTML and JavaScript in
most websites to create user interfaces for web
applications and user interfaces for many mobile
applications.
ā€¢ The major points of CSS are given below:
ā€¢ CSS stands for Cascading Style Sheet.
ā€¢ CSS is used to design HTML tags.
ā€¢ CSS is a widely used language on the web.
ā€¢ HTML, CSS and JavaScript are used for web
designing.
ā€¢ It helps the web designers to apply style on
HTML tags.
selector
CSS Syntax
ā€¢ A CSS rule set contains a selector and a
declaration block.
ā€¢ Selector:
ā€¢ Selector indicates the HTML element you want
to style.
ā€¢ It could be any tag like <h1>, <title> etc.
ā€¢ Declaration Block:
ā€¢ The declaration block can contain one or more
declarations separated by a semicolon.
ā€¢ For the above example, there are two
declarations:
ā€¢ color: yellow;
ā€¢ font-size: 11 px;
ā€¢ Each declaration contains a property name
and value, separated by a colon.
Property:
ā€¢ A Property is a type of attribute of HTML
element.
ā€¢ It could be color, border etc.
Value:
ā€¢ Values are assigned to CSS properties.
ā€¢ In the above example, value "yellow" is
assigned to color property.
CSS Selector
ā€¢ CSS selectors are used to select the content
you want to style.
ā€¢ Selectors are the part of CSS rule set.
ā€¢ CSS selectors select HTML elements according
to its id, class, type, attribute etc.
ā€¢ There are several different types of selectors
in CSS.
1. CSS Element Selector
2. CSS Id Selector
3. CSS Class Selector
4. CSS Universal Selector
5. CSS Group Selector
1) CSS Element Selector
ā€¢ The element selector selects the HTML
element by name.
2) CSS Id Selector
ā€¢ The id selector selects the id attribute of an
HTML element to select a specific element.
ā€¢ An id is always unique within the page so it is
chosen to select a single, unique element.
ā€¢ It is written with the hash character (#),
followed by the id of the element.
ā€¢ Let?s take an example with the id "para1".
3) CSS Class Selector
ā€¢ The class selector selects HTML elements with
a specific class attribute.
ā€¢ It is used with a period character .
(full stop symbol) followed by the class name.
CSS Class Selector for specific element
ā€¢ If you want to specify that only one specific
HTML element should be affected then you
should use the element name with class
selector.
ā€¢ Let's see an example.
4) CSS Universal Selector
ā€¢ The universal selector is used as a wildcard
character.
ā€¢ It selects all the elements on the pages.
5) CSS Group Selector
ā€¢ The grouping selector is used to select all the
elements with the same style definitions.
ā€¢ Grouping selector is used to minimize the
code. Commas are used to separate each
selector in grouping.
ā€¢ Let's see the CSS code without group selector.
ā€¢ As you can see, you need to define CSS
properties for all the elements.
ā€¢ It can be grouped in following ways:
How to add CSS
ā€¢ CSS is added to HTML pages to format the
document according to information in the
style sheet.
ā€¢ There are three ways to insert CSS in HTML
documents.
1. Inline CSS
2. Internal CSS
3. External CSS
1) Inline CSS
ā€¢ Inline CSS is used to apply CSS on a single line
or element.
ā€¢ Inline CSS: Inline CSS contains the CSS
property in the body section attached with
element is known as inline CSS.
ā€¢ This kind of style is specified within an HTML
tag using the style attribute.
Example 2
Disadvantages of Inline CSS
ā€¢ You cannot use quotations within inline CSS.
ā€¢ If you use quotations the browser will
interpret this as an end of your style value.
ā€¢ These styles cannot be reused anywhere else.
ā€¢ These styles are tough to be edited because
they are not stored at a single place.
ā€¢ It is not possible to style pseudo-codes and
pseudo-classes with inline CSS.
ā€¢ Inline CSS does not provide browser cache
advantages.
2) Internal CSS
ā€¢ Internal CSS is used to apply CSS on a single
document or page.
ā€¢ It can affect all the elements of the page.
ā€¢ It is written inside the style tag within head
section of html.
ā€¢ For example:
ā€¢ Internal or Embedded CSS:
ā€¢ This can be used when a single HTML
document must be styled uniquely.
ā€¢ The CSS rule set should be within the HTML
file in the head section i.e the CSS is
embedded within the HTML file.
Example 2
3) External CSS
ā€¢ External CSS is used to apply CSS on multiple
pages or all pages.
ā€¢ Here, we write all the CSS code in a css file.
ā€¢ Its extension must be .css for example
style.css.
ā€¢ External CSS:
ā€¢ External CSS contains separate CSS file which
contains only style property with the help of
tag attributes (For example class, id, heading,
ā€¦ etc).
ā€¢ CSS property written in a separate file with
.css extension and should be linked to the
HTML document using link tag.
ā€¢ This means that for each element, style can be
set only once and that will be applied across
web pages.
CSS text-indent Property
CSS text-decoration Property
CSS text-transform Property
CSS text-align Property
CSS white-space Property
Advantages of CSS
ā€¢ Saves time: It allows you define a style for
each HTML element. You can apply this style
to as many web pages as you want.
ā€¢ Easy maintenance: You can easily update
document formatting and maintain
consistency in multiple documents.
ā€¢ Faster page loading: It allows multiple pages
to share formatting that reduces file transfer
size which helps pages load faster.
ā€¢ Platform Independence:
ā€¢ It offers platform independence and also
supports the latest browsers.
ā€¢ Multiple device compatibility:
ā€¢ It allows you optimize content for more than
one type of devices.
ā€¢ You can present a HTML document in
different viewing styles for different devices
like computer, cell phone and printer.
Superior styles to HTML:
It has more presentation capabilities than HTML.
It allows you enhance the look of your HTML
pages better than using HTML presentational
elements and attributes.
Pizza Restaurant
output
Web Technology Part 2
Web Technology Part 2
Web Technology Part 2
Web Technology Part 2
Web Technology Part 2
Web Technology Part 2
Web Technology Part 2
Web Technology Part 2
Web Technology Part 2
Web Technology Part 2
Web Technology Part 2

More Related Content

Similar to Web Technology Part 2

Project First presentation about introduction to technologies to be used
Project First presentation about introduction to technologies to be usedProject First presentation about introduction to technologies to be used
Project First presentation about introduction to technologies to be usedarya krazydude
Ā 
JS BASICS JAVA SCRIPT SCRIPTING
JS BASICS JAVA SCRIPT SCRIPTINGJS BASICS JAVA SCRIPT SCRIPTING
JS BASICS JAVA SCRIPT SCRIPTINGArulkumar
Ā 
MTA understanding java script and coding essentials
MTA understanding java script and coding essentialsMTA understanding java script and coding essentials
MTA understanding java script and coding essentialsDhairya Joshi
Ā 
WTA-MODULE-4.pptx
WTA-MODULE-4.pptxWTA-MODULE-4.pptx
WTA-MODULE-4.pptxChayapathiAR
Ā 
Iwt note(module 2)
Iwt note(module 2)Iwt note(module 2)
Iwt note(module 2)SANTOSH RATH
Ā 
javascript 1
javascript 1javascript 1
javascript 1osman do
Ā 
WT Unit-3 PPT.pptx
WT Unit-3 PPT.pptxWT Unit-3 PPT.pptx
WT Unit-3 PPT.pptxTusharTikia
Ā 
BITM3730Week12.pptx
BITM3730Week12.pptxBITM3730Week12.pptx
BITM3730Week12.pptxMattMarino13
Ā 
walkmod - JUG talk
walkmod - JUG talkwalkmod - JUG talk
walkmod - JUG talkwalkmod
Ā 
Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2divzi1913
Ā 
FFW Gabrovo PMG - JavaScript 1
FFW Gabrovo PMG - JavaScript 1FFW Gabrovo PMG - JavaScript 1
FFW Gabrovo PMG - JavaScript 1Toni Kolev
Ā 
TypeScript and Angular2 (Love at first sight)
TypeScript and Angular2 (Love at first sight)TypeScript and Angular2 (Love at first sight)
TypeScript and Angular2 (Love at first sight)Igor Talevski
Ā 
Java script202
Java script202Java script202
Java script202Wasiq Zia
Ā 
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptxUnit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptxMalla Reddy University
Ā 
Optimization of modern web applications
Optimization of modern web applicationsOptimization of modern web applications
Optimization of modern web applicationsEugene Lazutkin
Ā 

Similar to Web Technology Part 2 (20)

Project First presentation about introduction to technologies to be used
Project First presentation about introduction to technologies to be usedProject First presentation about introduction to technologies to be used
Project First presentation about introduction to technologies to be used
Ā 
JS BASICS JAVA SCRIPT SCRIPTING
JS BASICS JAVA SCRIPT SCRIPTINGJS BASICS JAVA SCRIPT SCRIPTING
JS BASICS JAVA SCRIPT SCRIPTING
Ā 
MTA understanding java script and coding essentials
MTA understanding java script and coding essentialsMTA understanding java script and coding essentials
MTA understanding java script and coding essentials
Ā 
WTA-MODULE-4.pptx
WTA-MODULE-4.pptxWTA-MODULE-4.pptx
WTA-MODULE-4.pptx
Ā 
Iwt note(module 2)
Iwt note(module 2)Iwt note(module 2)
Iwt note(module 2)
Ā 
javascript 1
javascript 1javascript 1
javascript 1
Ā 
Javascript best practices
Javascript best practicesJavascript best practices
Javascript best practices
Ā 
Spatial approximate string search Doc
Spatial approximate string search DocSpatial approximate string search Doc
Spatial approximate string search Doc
Ā 
WT Unit-3 PPT.pptx
WT Unit-3 PPT.pptxWT Unit-3 PPT.pptx
WT Unit-3 PPT.pptx
Ā 
BITM3730Week12.pptx
BITM3730Week12.pptxBITM3730Week12.pptx
BITM3730Week12.pptx
Ā 
Web Technology Part 3
Web Technology Part 3Web Technology Part 3
Web Technology Part 3
Ā 
walkmod - JUG talk
walkmod - JUG talkwalkmod - JUG talk
walkmod - JUG talk
Ā 
js.pptx
js.pptxjs.pptx
js.pptx
Ā 
Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2
Ā 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
Ā 
FFW Gabrovo PMG - JavaScript 1
FFW Gabrovo PMG - JavaScript 1FFW Gabrovo PMG - JavaScript 1
FFW Gabrovo PMG - JavaScript 1
Ā 
TypeScript and Angular2 (Love at first sight)
TypeScript and Angular2 (Love at first sight)TypeScript and Angular2 (Love at first sight)
TypeScript and Angular2 (Love at first sight)
Ā 
Java script202
Java script202Java script202
Java script202
Ā 
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptxUnit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
Ā 
Optimization of modern web applications
Optimization of modern web applicationsOptimization of modern web applications
Optimization of modern web applications
Ā 

More from Thapar Institute

Digital Electronics Unit_4_new.pptx
Digital Electronics Unit_4_new.pptxDigital Electronics Unit_4_new.pptx
Digital Electronics Unit_4_new.pptxThapar Institute
Ā 
Digital Electronics Unit_3.pptx
Digital Electronics Unit_3.pptxDigital Electronics Unit_3.pptx
Digital Electronics Unit_3.pptxThapar Institute
Ā 
Digital Electronics Unit_2.pptx
Digital Electronics Unit_2.pptxDigital Electronics Unit_2.pptx
Digital Electronics Unit_2.pptxThapar Institute
Ā 
Digital Electronics Unit_1.pptx
Digital Electronics Unit_1.pptxDigital Electronics Unit_1.pptx
Digital Electronics Unit_1.pptxThapar Institute
Ā 
Compiler Design Introduction
Compiler Design Introduction Compiler Design Introduction
Compiler Design Introduction Thapar Institute
Ā 
Software Testing Introduction (Part 4))
 Software Testing Introduction (Part 4)) Software Testing Introduction (Part 4))
Software Testing Introduction (Part 4))Thapar Institute
Ā 
Software Testing Introduction (Part 3)
 Software Testing Introduction (Part 3) Software Testing Introduction (Part 3)
Software Testing Introduction (Part 3)Thapar Institute
Ā 
Software Testing Introduction (Part 2)
Software Testing Introduction (Part 2)Software Testing Introduction (Part 2)
Software Testing Introduction (Part 2)Thapar Institute
Ā 
Software Testing Introduction (Part 1)
Software Testing Introduction (Part 1)Software Testing Introduction (Part 1)
Software Testing Introduction (Part 1)Thapar Institute
Ā 

More from Thapar Institute (18)

Digital Electronics Unit_4_new.pptx
Digital Electronics Unit_4_new.pptxDigital Electronics Unit_4_new.pptx
Digital Electronics Unit_4_new.pptx
Ā 
Digital Electronics Unit_3.pptx
Digital Electronics Unit_3.pptxDigital Electronics Unit_3.pptx
Digital Electronics Unit_3.pptx
Ā 
Digital Electronics Unit_2.pptx
Digital Electronics Unit_2.pptxDigital Electronics Unit_2.pptx
Digital Electronics Unit_2.pptx
Ā 
Digital Electronics Unit_1.pptx
Digital Electronics Unit_1.pptxDigital Electronics Unit_1.pptx
Digital Electronics Unit_1.pptx
Ā 
C Language Part 1
C Language Part 1C Language Part 1
C Language Part 1
Ā 
Compiler Design Introduction
Compiler Design Introduction Compiler Design Introduction
Compiler Design Introduction
Ā 
Web Technology Part 4
Web Technology Part 4Web Technology Part 4
Web Technology Part 4
Ā 
Web Technology Part 1
Web Technology Part 1Web Technology Part 1
Web Technology Part 1
Ā 
TOC Introduction
TOC Introduction TOC Introduction
TOC Introduction
Ā 
CSS Introduction
CSS Introduction CSS Introduction
CSS Introduction
Ā 
COA (Unit_4.pptx)
COA (Unit_4.pptx)COA (Unit_4.pptx)
COA (Unit_4.pptx)
Ā 
COA(Unit_3.pptx)
COA(Unit_3.pptx)COA(Unit_3.pptx)
COA(Unit_3.pptx)
Ā 
COA (Unit_2.pptx)
COA (Unit_2.pptx)COA (Unit_2.pptx)
COA (Unit_2.pptx)
Ā 
COA (Unit_1.pptx)
COA (Unit_1.pptx)COA (Unit_1.pptx)
COA (Unit_1.pptx)
Ā 
Software Testing Introduction (Part 4))
 Software Testing Introduction (Part 4)) Software Testing Introduction (Part 4))
Software Testing Introduction (Part 4))
Ā 
Software Testing Introduction (Part 3)
 Software Testing Introduction (Part 3) Software Testing Introduction (Part 3)
Software Testing Introduction (Part 3)
Ā 
Software Testing Introduction (Part 2)
Software Testing Introduction (Part 2)Software Testing Introduction (Part 2)
Software Testing Introduction (Part 2)
Ā 
Software Testing Introduction (Part 1)
Software Testing Introduction (Part 1)Software Testing Introduction (Part 1)
Software Testing Introduction (Part 1)
Ā 

Recently uploaded

chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
Ā 
Study on Air-Water & Water-Water Heat Exchange in a Finned ļ»æTube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned ļ»æTube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned ļ»æTube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned ļ»æTube ExchangerAnamika Sarkar
Ā 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
Ā 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
Ā 
Call Us ā‰½ 8377877756 ā‰¼ Call Girls In Shastri Nagar (Delhi)
Call Us ā‰½ 8377877756 ā‰¼ Call Girls In Shastri Nagar (Delhi)Call Us ā‰½ 8377877756 ā‰¼ Call Girls In Shastri Nagar (Delhi)
Call Us ā‰½ 8377877756 ā‰¼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
Ā 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
Ā 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
Ā 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
Ā 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
Ā 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
Ā 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
Ā 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
Ā 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
Ā 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
Ā 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
Ā 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
Ā 

Recently uploaded (20)

chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
Ā 
young call girls in Rajiv ChowkšŸ” 9953056974 šŸ” Delhi escort Service
young call girls in Rajiv ChowkšŸ” 9953056974 šŸ” Delhi escort Serviceyoung call girls in Rajiv ChowkšŸ” 9953056974 šŸ” Delhi escort Service
young call girls in Rajiv ChowkšŸ” 9953056974 šŸ” Delhi escort Service
Ā 
Study on Air-Water & Water-Water Heat Exchange in a Finned ļ»æTube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned ļ»æTube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned ļ»æTube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned ļ»æTube Exchanger
Ā 
ā˜… CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
ā˜… CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCRā˜… CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
ā˜… CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
Ā 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Ā 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
Ā 
Call Us ā‰½ 8377877756 ā‰¼ Call Girls In Shastri Nagar (Delhi)
Call Us ā‰½ 8377877756 ā‰¼ Call Girls In Shastri Nagar (Delhi)Call Us ā‰½ 8377877756 ā‰¼ Call Girls In Shastri Nagar (Delhi)
Call Us ā‰½ 8377877756 ā‰¼ Call Girls In Shastri Nagar (Delhi)
Ā 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
Ā 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
Ā 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
Ā 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
Ā 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
Ā 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
Ā 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
Ā 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
Ā 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
Ā 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
Ā 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
Ā 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Ā 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
Ā 

Web Technology Part 2

  • 2. What are the different image file formats?
  • 3. ā€¢ Image Format describes how data related to the image will be stored. ā€¢ Data can be stored in compressed, Uncompressed or vector format. ā€¢ Each format of the image have a different advantage and disadvantage. ā€¢ Image types such a TIFF are good for printing while JPG or PNG, are best for web.
  • 4. ā€¢ JPEG (.jpg, .jpeg) Joint Photographic Experts Group is a loss-prone (lossy) format in which data is lost to reduce size of image. Due to compression, some data is lost but that loss is very less. It is a very common format and are good for digital cameras, nonprofessional prints, E-Mail, Powerpoint etc., making it ideal for web use. ā€¢ GIF (.gif) GIF or Graphics Interchange Format files are used for web graphics.They can be animated and are limited to only 256 colors, can allow for transparency. GIF files are typically small is size and are portable. ā€¢ PNG (.png) PNG or Portable Network Graphics files are a lossless image format. It was designed to replace gif format as gif supported 256 colors unlike PNG which support 16 million colors.
  • 5. Difference between Server Side Scripting and Client Side Scripting ā€¢ 1. Client side scripting : web browsers execute client side scripting. It is use when browsers has all code. ā€¢ Source code used to transfer from web server to userā€™s computer over internet and run directly on browsers. It is also used for validations and functionality for user events. ā€¢ It allows for more interactivity. ā€¢ It usually performs several actions without going to user. ā€¢ It cannot be basically used to connect to databases on web server. ā€¢ Pages are altered on basis of users choice. It can also used to create ā€œcookiesā€ that store data on userā€™s computer
  • 7.
  • 8. ā€¢ 2. Server side scripting : Web servers are used to execute server side scripting. They are basically used to create dynamic pages. ā€¢ It can also access the file system residing at web server. Server-side environment that runs on a scripting language is a web-server. ā€¢ Scripts can be written in any of a number of server-side scripting language available. ā€¢ It is used to retrieve and generate content for dynamic pages. A dynamic page displays different content for different users while retaining the same layout and design ā€¢ It is used to require to download plugins. In this load times are generally faster than client-side scripting. When you need to store and retrieve information a database will be used to contain data. It can use huge resources of server. ā€¢ It reduces client-side computation overhead. Server sends pages to request of user/client.
  • 9. For example in a social media site, if you request info about @myFriend the server will look up that user and return his profile if found.
  • 10.
  • 11. What is JavaScript ā€¢ JavaScript (js) is a light-weight object-oriented programming language which is used by several websites for scripting the webpages. ā€¢ It is an interpreted, full-fledged programming language that enables dynamic interactivity on websites when applied to an HTML document. ā€¢ It was introduced in the year 1995 for adding programs to the webpages in the Netscape Navigator browser. ā€¢ Since then, it has been adopted by all other graphical web browsers. A process is said to be lightweight if it occupies less Memory and takes less processor time to complete.
  • 13.
  • 14. JavaScript Example The write() method in HTML is used to write some content or JavaScript code in a Document. This method is mostly used for testing purpose.
  • 15. JavaScript Example ā€¢ Javascript example is easy to code. ā€¢ JavaScript provides 3 places to put the JavaScript code: within body tag, within head tag and external JavaScript file. ā€¢ Letā€™s create the first JavaScript example.
  • 16. ā€¢ The text/javascript is the content type that provides information to the browser about the data. ā€¢ The document.write() function is used to display dynamic content through JavaScript. We will learn about document object in detail later.
  • 17. 3 Places to put JavaScript code 1. Between the body tag of html 2. Between the head tag of html 3. In .js file (external javaScript)
  • 18. 1) JavaScript Example : code between the body tag ā€¢ In the above example, we have displayed the dynamic content using JavaScript. ā€¢ Letā€™s see the simple example of JavaScript that displays alert dialog box
  • 19.
  • 20.
  • 21. 2) JavaScript Example : code between the head tag ā€¢ Letā€™s see the same example of displaying alert dialog box of JavaScript that is contained inside the head tag. ā€¢ In this example, we are creating a function msg(). ā€¢ To create function in JavaScript, you need to write function with function_name as given below. ā€¢ To call function, you need to work on event. Here we are using onclick event to call msg() function.
  • 22.
  • 24.
  • 25. 3. External JavaScript file ā€¢ We can create external JavaScript file and embed it in many html page. ā€¢ It provides code re usability because single JavaScript file can be used in several html pages. ā€¢ An external JavaScript file must be saved by .js extension. It is recommended to embed all JavaScript files into a single file. It increases the speed of the webpage.
  • 26. ā€¢ Let's create an external JavaScript file that prints Hello Javatpoint in a alert dialog box. message.js function msg(){ alert("Hello JavatScript"); } ā€¢ Let's include the JavaScript file into html page. ā€¢ It calls the JavaScript function on button click.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31. JavaScript String replace() Method ā€¢ The JavaScript string replace() method is used to replace a part of a given string with a new substring. ā€¢ This method searches for specified regular expression in a given string and then replace it if the match occurs. ā€¢ We can use global search modifier with replace() method to replace all the match elements otherwise the method replace only first match. JavaScript also provides ignore flag to make the method case-insensitive.
  • 32.
  • 33. Parameter ā€¢ originalstr - It represents the string to be searched and replaced. ā€¢ Newstr - It represents the new string that replaced with the searched string.
  • 34.
  • 35.
  • 36.
  • 37. JavaScript String charAt() Method ā€¢ The JavaScript string charAt() method is used to find out a char value present at the specified index in a string. ā€¢ The index number starts from 0 and goes to n- 1, where n is the length of the string. ā€¢ The index value can't be a negative, greater than or equal to the length of the string.
  • 38.
  • 39. ā€¢ Parameter ā€¢ index - It represent the position of a character.
  • 40.
  • 41.
  • 42. JavaScript Math abs() method ā€¢ The JavaScript math abs() method returns an absolute value of a given number. ā€¢ The abs() is a static method of Math.
  • 43.
  • 44. JavaScript Math abs() method example
  • 45.
  • 46.
  • 47.
  • 48. JavaScript Date getDate() method ā€¢ The JavaScript date getDate() method returns the day for the specified date on the basis of local time.
  • 49.
  • 50.
  • 51. Difference between var and let in JavaScript ā€¢ var and let are both used for variable declaration in javascript but the difference between them is that var is function scoped and let is block scoped. It can be said that a variable declared with var is defined throughout the program as compared to let.
  • 52.
  • 54.
  • 55. Javascript Data Types ā€¢ JavaScript provides different data types to hold different types of values. ā€¢ There are two types of data types in JavaScript. 1. Primitive data type 2. Non-primitive (reference) data type
  • 56. ā€¢ JavaScript is a dynamic type language, means you don't need to specify type of the variable because it is dynamically used by JavaScript engine. ā€¢ You need to use var here to specify the data type. ā€¢ It can hold any type of values such as numbers, strings etc. ā€¢ For example:
  • 57. JavaScript primitive data types ā€¢ There are five types of primitive data types in JavaScript. ā€¢ They are as follows:
  • 58. JavaScript non-primitive data types ā€¢ The non-primitive data types are as follows:
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69. JavaScript Operators 1. Arithmetic Operators 2. Comparison (Relational) Operators 3. Bitwise Operators 4. Logical Operators 5. Assignment Operators 6. Special Operators
  • 70. JavaScript Arithmetic Operators ā€¢ Arithmetic operators are used to perform arithmetic operations on the operands. ā€¢ The following operators are known as JavaScript arithmetic operators.
  • 71.
  • 72. JavaScript Comparison Operators ā€¢ The JavaScript comparison operator compares the two operands. ā€¢ The comparison operators are as follows:
  • 73.
  • 74.
  • 75. JavaScript Bitwise Operators ā€¢ The bitwise operators perform bitwise operations on operands. ā€¢ The bitwise operators are as follows:
  • 78. JavaScript Logical Operators ā€¢ The following operators are known as JavaScript logical operators.
  • 79.
  • 80.
  • 81. JavaScript Assignment Operators ā€¢ The following operators are known as JavaScript assignment operators.
  • 82. JavaScript Special Operators ā€¢ The following operators are known as JavaScript special operators.
  • 83.
  • 84.
  • 85.
  • 86.
  • 87.
  • 88.
  • 90.
  • 92.
  • 93.
  • 94.
  • 96.
  • 97.
  • 98. JavaScript Loops ā€¢ The JavaScript loops are used to iterate the piece of code using for, while, do while or for- in loops. ā€¢ It makes the code compact. ā€¢ It is mostly used in array. ā€¢ There are four types of loops in JavaScript. 1. for loop 2. while loop 3. do-while loop 4. for-in loop
  • 99. 1) JavaScript For loop ā€¢ The JavaScript for loop iterates the elements for the fixed number of times. ā€¢ It should be used if number of iteration is known. ā€¢ The syntax of for loop is given below.
  • 100. Letā€™s see the simple example of for loop in javascript.
  • 101.
  • 102. 2) JavaScript while loop ā€¢ The JavaScript while loop iterates the elements for the infinite number of times. ā€¢ It should be used if number of iteration is not known. ā€¢ The syntax of while loop is given below.
  • 103. Letā€™s see the simple example of while loop in javascript.
  • 104.
  • 105. 3) 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. ā€¢ The syntax of do while loop is given below.
  • 106. Letā€™s see the simple example of do while loop in javascript.
  • 107.
  • 108. 4) JavaScript for in loop ā€¢ The JavaScript for in loop is used to iterate the properties of an object.
  • 109.
  • 110.
  • 111. JavaScript Functions ā€¢ JavaScript functions are used to perform operations. ā€¢ We can call JavaScript function many times to reuse the code. ā€¢ Advantage of JavaScript function ā€¢ There are mainly two advantages of JavaScript functions. ā€¢ Code reusability: ā€¢ We can call a function several times so it save coding. ā€¢ Less coding: ā€¢ It makes our program compact. ā€¢ We donā€™t need to write many lines of code each time to perform a common task.
  • 112.
  • 113. ā€¢ where, function_name represents the name of the function and parameter-1, ... , parameter-n represents list of parameters.
  • 114. JavaScript Function Syntax ā€¢ The syntax of declaring function is given below. JavaScript Functions can have 0 or more arguments.
  • 115. JavaScript Function Example ā€¢ Letā€™s see the simple example of function in JavaScript that does not has arguments.
  • 116.
  • 117.
  • 118.
  • 119. JavaScript Function Arguments ā€¢ We can call function by passing arguments. Letā€™s see the example of function that has one argument.
  • 120.
  • 121.
  • 122.
  • 123. Function with Return Value ā€¢ We can call function that returns a value and use it in our program. ā€¢ Letā€™s see the example of function that returns value.
  • 124.
  • 125.
  • 126. Using Iterative approach ā€¢ Here, we are iterating a loop over the sequence of numbers to get the factorial of a given number. ā€¢ Using this approach, the consumption of memory is less than the recursive implementation. ā€¢ But the code is lengthier than the recursive method.
  • 127. Example ā€¢ In this example, there is a text field that requires a number and a button, which gives us the factorial of the entered number. ā€¢ We have to enter a number in the given textfield to find the factorial of that number. ā€¢ Then we need to click the given button named Factorial to get the result. ā€¢ If we enter a negative number, then the program calculates the factorial of 0, which is 1.
  • 128. Factorial of a number using JavaScript
  • 129.
  • 130.
  • 131.
  • 132. Using Recursive approach ā€¢ In this approach, we are using recursion to calculate the factorial of a number. ā€¢ Here, we call same function again and again to get the factorial. Using recursion, we have to code less than the iterative approach. ā€¢ Now, we will see an example of finding the factorial of number using recursion in JavaScript.
  • 133. Example ā€¢ Here there is a function fact(), which accepts a parameter num. It is a number for which we need to calculate the factorial. ā€¢ The function returns 1 when the value of num is 0. ā€¢ In the output we will see a text field that requires number and a button which gives us the factorial of the entered number. ā€¢ We have to enter a number in the given textfield to find the factorial of that number. Then we need to click the given button named as Factorial to get the result.
  • 134.
  • 135.
  • 136.
  • 137.
  • 138.
  • 139.
  • 140.
  • 141.
  • 142. JavaScript Objects ā€¢ A javaScript object is an entity having state and behavior (properties and method). ā€¢ For example: car, pen, bike, chair, glass, keyboard, monitor etc. ā€¢ JavaScript is an object-based language. Everything is an object in JavaScript. ā€¢ JavaScript is template based not class based. Here, we don't create class to get the object. But, we direct create objects.
  • 143.
  • 144.
  • 145. Creating Objects in JavaScript ā€¢ There are 3 ways to create objects. 1. By object literal 2. By creating instance of Object directly (using new keyword) 3. By using an object constructor (using new keyword)
  • 146. 1) JavaScript Object by object literal ā€¢ The syntax of creating object using object literal is given below: As you can see, property and value is separated by : (colon).
  • 147.
  • 148.
  • 149. 2) By creating instance of Object ā€¢ The syntax of creating object directly is given below:
  • 150.
  • 151.
  • 152. 3) By using an Object constructor ā€¢ Here, you need to create function with arguments. ā€¢ Each argument value can be assigned in the current object by using this keyword. ā€¢ The this keyword refers to the current object. ā€¢ The example of creating object by object constructor is given below.
  • 153.
  • 154.
  • 155. Defining method in JavaScript Object ā€¢ We can define method in JavaScript object. But before defining method, we need to add property in the function with same name as method. ā€¢ The example of defining method in object is given below.
  • 156.
  • 157.
  • 158. JavaScript Array ā€¢ JavaScript array is an object that represents a collection of similar type of elements. ā€¢ There are 3 ways to construct array in JavaScript 1. By array literal 2. By creating instance of Array directly (using new keyword) 3. By using an Array constructor (using new keyword)
  • 159. 1) JavaScript array literal ā€¢ The syntax of creating array using array literal is given below: As you can see, values are contained inside [ ] and separated by , (comma). Note: Literals are constant values that can be assigned to the variables
  • 160. ā€¢ Let's see the simple example of creating and using array in JavaScript
  • 161. Output of the above example
  • 162. 2) JavaScript Array directly (new keyword) ā€¢ The syntax of creating array directly is given below: ā€¢ Here, new keyword is used to create instance of array.
  • 163. Let's see the example of creating array directly.
  • 164. output
  • 165. 3) JavaScript array constructor (new keyword) ā€¢ Here, you need to create instance of array by passing arguments in constructor so that we don't have to provide value explicitly.
  • 166. The example of creating object by array constructor is given below.
  • 167. output
  • 168. Array Methods ā€¢ The following table lists the standard methods of the Array object.
  • 169.
  • 170.
  • 171.
  • 172.
  • 173.
  • 174.
  • 175.
  • 176.
  • 177.
  • 178.
  • 179.
  • 180.
  • 181.
  • 182.
  • 183.
  • 184.
  • 185.
  • 186. JavaScript Built-in Objects ā€¢ Built-in Objects ā€¢ Built-in objects are not related to any Window or DOM object model. ā€¢ These objects are used for simple data processing in the JavaScript.
  • 187.
  • 188.
  • 189.
  • 190.
  • 191. Example: Simple Program on Math Object Properties
  • 192.
  • 193.
  • 194.
  • 195.
  • 196.
  • 197.
  • 198.
  • 199.
  • 200.
  • 201.
  • 202.
  • 203. JavaScript Events ā€¢ The change in the state of an object is known as an Event. ā€¢ In html, there are various events which represents that some activity is performed by the user or by the browser. ā€¢ When javascript code is included in HTML, js react over these events and allow the execution. This process of reacting over the events is called Event Handling. ā€¢ Thus, js handles the HTML events via Event Handlers. ā€¢ For example, when a user clicks over the browser, add js code, which will execute the task to be performed on the event. ā€¢ Some of the HTML events and their event handlers are:
  • 204.
  • 205.
  • 206.
  • 207.
  • 208.
  • 209.
  • 210.
  • 211.
  • 212.
  • 213.
  • 214.
  • 215.
  • 216.
  • 217.
  • 218.
  • 219.
  • 220.
  • 221.
  • 222.
  • 223.
  • 224.
  • 225.
  • 226.
  • 228.
  • 229. JavaScript addEventListener() ā€¢ The addEventListener() method is used to attach an event handler to a particular element. ā€¢ It does not override the existing event handlers. Events are said to be an essential part of the JavaScript. ā€¢ A web page responds according to the event that occurred. ā€¢ Events can be user-generated or generated by API's. An event listener is a JavaScript's procedure that waits for the occurrence of an event. ā€¢ The addEventListener() method is an inbuilt function of JavaScript. We can add multiple event handlers to a particular element without overwriting the existing event handlers.
  • 230.
  • 232. Example ā€¢ It is a simple example of using the addEventListener() method. ā€¢ We have to click the given HTML button to see the effect.
  • 233.
  • 234.
  • 235.
  • 236. ā€¢ Now, in the next example we will see how to add many events to the same element without overwriting the existing events.
  • 237.
  • 238.
  • 239.
  • 240.
  • 241. Example ā€¢ In this example, we are adding multiple events of a different type to the same element.
  • 242.
  • 243.
  • 244.
  • 245.
  • 246. Using JavaScript ā€¢ In this example, we are using JavaScript's onclick event. ā€¢ Here we are using the onclick event with the paragraph element. ā€¢ When the user clicks on the paragraph element, the corresponding function will get executed, and the text of the paragraph gets changed. ā€¢ On clicking the <p> element, the background color, size, border, and color of the text will also get change.
  • 247.
  • 248.
  • 249.
  • 250. Using addEventListener() method ā€¢ In this example, we are using JavaScript's addEventListener() method to attach a click event to the paragraph element. ā€¢ When the user clicks the paragraph element, the text of the paragraph gets changed. ā€¢ On clicking the paragraph, the background color and font-size of elements will also change.
  • 251.
  • 252.
  • 253.
  • 254. Window Object ā€¢ The window object represents a window in browser. ā€¢ An object of window is created automatically by the browser. ā€¢ Window is the object of browser, it is not the object of javascript. ā€¢ The javascript objects are string, array, date etc.
  • 255. Methods of window object
  • 256. Example of alert() in javascript ā€¢ It displays alert dialog box. ā€¢ It has message and ok button.
  • 257.
  • 258.
  • 259. Example of confirm() in javascript ā€¢ It displays the confirm dialog box. ā€¢ It has message with ok and cancel buttons.
  • 260.
  • 261.
  • 262.
  • 263. Example of prompt() in javascript ā€¢ It displays prompt dialog box for input. ā€¢ It has message and textfield.
  • 264.
  • 265.
  • 266.
  • 267.
  • 268. Example of open() in javascript ā€¢ It displays the content in a new window.
  • 269.
  • 270.
  • 271.
  • 272. Example of setTimeout() in javascript ā€¢ It performs its task after the given milliseconds.
  • 273.
  • 274.
  • 275. What is CSS ā€¢ CSS stands for Cascading Style Sheets. ā€¢ It is a style sheet language which is used to describe the look and formatting of a document written in markup language. ā€¢ It provides an additional feature to HTML. ā€¢ It is generally used with HTML to change the style of web pages and user interfaces. ā€¢ It can also be used with any kind of XML documents including plain XML, SVG and XUL. ā€¢ CSS is used along with HTML and JavaScript in most websites to create user interfaces for web applications and user interfaces for many mobile applications.
  • 276. ā€¢ The major points of CSS are given below: ā€¢ CSS stands for Cascading Style Sheet. ā€¢ CSS is used to design HTML tags. ā€¢ CSS is a widely used language on the web. ā€¢ HTML, CSS and JavaScript are used for web designing. ā€¢ It helps the web designers to apply style on HTML tags.
  • 278.
  • 279. CSS Syntax ā€¢ A CSS rule set contains a selector and a declaration block.
  • 280. ā€¢ Selector: ā€¢ Selector indicates the HTML element you want to style. ā€¢ It could be any tag like <h1>, <title> etc. ā€¢ Declaration Block: ā€¢ The declaration block can contain one or more declarations separated by a semicolon. ā€¢ For the above example, there are two declarations: ā€¢ color: yellow; ā€¢ font-size: 11 px;
  • 281. ā€¢ Each declaration contains a property name and value, separated by a colon. Property: ā€¢ A Property is a type of attribute of HTML element. ā€¢ It could be color, border etc. Value: ā€¢ Values are assigned to CSS properties. ā€¢ In the above example, value "yellow" is assigned to color property.
  • 282. CSS Selector ā€¢ CSS selectors are used to select the content you want to style. ā€¢ Selectors are the part of CSS rule set. ā€¢ CSS selectors select HTML elements according to its id, class, type, attribute etc.
  • 283. ā€¢ There are several different types of selectors in CSS. 1. CSS Element Selector 2. CSS Id Selector 3. CSS Class Selector 4. CSS Universal Selector 5. CSS Group Selector
  • 284. 1) CSS Element Selector ā€¢ The element selector selects the HTML element by name.
  • 285.
  • 286.
  • 287. 2) CSS Id Selector ā€¢ The id selector selects the id attribute of an HTML element to select a specific element. ā€¢ An id is always unique within the page so it is chosen to select a single, unique element. ā€¢ It is written with the hash character (#), followed by the id of the element. ā€¢ Let?s take an example with the id "para1".
  • 288.
  • 289.
  • 290. 3) CSS Class Selector ā€¢ The class selector selects HTML elements with a specific class attribute. ā€¢ It is used with a period character . (full stop symbol) followed by the class name.
  • 291.
  • 292.
  • 293. CSS Class Selector for specific element ā€¢ If you want to specify that only one specific HTML element should be affected then you should use the element name with class selector. ā€¢ Let's see an example.
  • 294.
  • 295.
  • 296. 4) CSS Universal Selector ā€¢ The universal selector is used as a wildcard character. ā€¢ It selects all the elements on the pages.
  • 297.
  • 298.
  • 299. 5) CSS Group Selector ā€¢ The grouping selector is used to select all the elements with the same style definitions. ā€¢ Grouping selector is used to minimize the code. Commas are used to separate each selector in grouping. ā€¢ Let's see the CSS code without group selector.
  • 300.
  • 301. ā€¢ As you can see, you need to define CSS properties for all the elements. ā€¢ It can be grouped in following ways:
  • 302.
  • 303.
  • 304. How to add CSS ā€¢ CSS is added to HTML pages to format the document according to information in the style sheet. ā€¢ There are three ways to insert CSS in HTML documents. 1. Inline CSS 2. Internal CSS 3. External CSS
  • 305. 1) Inline CSS ā€¢ Inline CSS is used to apply CSS on a single line or element.
  • 306. ā€¢ Inline CSS: Inline CSS contains the CSS property in the body section attached with element is known as inline CSS. ā€¢ This kind of style is specified within an HTML tag using the style attribute.
  • 307.
  • 308.
  • 310.
  • 311. Disadvantages of Inline CSS ā€¢ You cannot use quotations within inline CSS. ā€¢ If you use quotations the browser will interpret this as an end of your style value. ā€¢ These styles cannot be reused anywhere else. ā€¢ These styles are tough to be edited because they are not stored at a single place. ā€¢ It is not possible to style pseudo-codes and pseudo-classes with inline CSS. ā€¢ Inline CSS does not provide browser cache advantages.
  • 312. 2) Internal CSS ā€¢ Internal CSS is used to apply CSS on a single document or page. ā€¢ It can affect all the elements of the page. ā€¢ It is written inside the style tag within head section of html. ā€¢ For example:
  • 313. ā€¢ Internal or Embedded CSS: ā€¢ This can be used when a single HTML document must be styled uniquely. ā€¢ The CSS rule set should be within the HTML file in the head section i.e the CSS is embedded within the HTML file.
  • 314.
  • 315.
  • 317.
  • 318. 3) External CSS ā€¢ External CSS is used to apply CSS on multiple pages or all pages. ā€¢ Here, we write all the CSS code in a css file. ā€¢ Its extension must be .css for example style.css.
  • 319.
  • 320. ā€¢ External CSS: ā€¢ External CSS contains separate CSS file which contains only style property with the help of tag attributes (For example class, id, heading, ā€¦ etc). ā€¢ CSS property written in a separate file with .css extension and should be linked to the HTML document using link tag. ā€¢ This means that for each element, style can be set only once and that will be applied across web pages.
  • 321.
  • 322.
  • 323.
  • 325.
  • 326.
  • 327.
  • 328.
  • 330.
  • 331.
  • 332.
  • 333.
  • 334.
  • 336.
  • 337.
  • 339.
  • 340.
  • 341.
  • 342.
  • 344.
  • 345.
  • 346.
  • 347.
  • 348. Advantages of CSS ā€¢ Saves time: It allows you define a style for each HTML element. You can apply this style to as many web pages as you want. ā€¢ Easy maintenance: You can easily update document formatting and maintain consistency in multiple documents. ā€¢ Faster page loading: It allows multiple pages to share formatting that reduces file transfer size which helps pages load faster.
  • 349. ā€¢ Platform Independence: ā€¢ It offers platform independence and also supports the latest browsers. ā€¢ Multiple device compatibility: ā€¢ It allows you optimize content for more than one type of devices. ā€¢ You can present a HTML document in different viewing styles for different devices like computer, cell phone and printer.
  • 350. Superior styles to HTML: It has more presentation capabilities than HTML. It allows you enhance the look of your HTML pages better than using HTML presentational elements and attributes.
  • 352.
  • 353.
  • 354. output