Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
Topic: JAVA SCRIPT
UNIT – I (Part-II)
Subject name: WT
Year/Section: III CSE - A
Dr. Vikram Neerugatti
Associate Professor
Department of CSE
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
1
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
•Overview of Java script
•Primitives
•Operations
•Expressions
•Control Statements
•Arrays
•Functions
•Pattern Matching using regular expressions
Content
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
2
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
• JavaScript was introduced in 1995 to add programs to web
pages.
• JavaScript is used in more traditional websites to provide
various forms of interactivity and cleverness.
• The script should be included in an HTML document for
the code to be interpreted by the browser.
• It means that a web page need not be a static HTML,
• but can include programs that interact with the user,
control the browser, and dynamically create HTML
content.
Overview of Java script
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
3
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
• Script should place within the <script>... </script> HTML
tags in a web page.
• Can place any where but, recommended that you should
keep it within the <head> tags.
Java script-Example
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
4
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
• we call a function document.write which writes a string
into our HTML document.
• his function can be used to write text, HTML, or both.
• JavaScript is a case-sensitive language.
Java script-Example
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
5
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
• we call a function document.write which writes a string
into our HTML document.
• his function can be used to write text, HTML, or both.
• JavaScript is a case-sensitive language.
Java script-Example-Comments
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
6
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
Java script-Example-allow script
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
7
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
Java script-Example-External
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
8
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
• JavaScript allows you to work with three
primitive data types
– Numbers, eg. 123, 120.50 etc.
– Strings of text e.g. "This text string" etc.
– Boolean e.g. true or false.
• JavaScript also defines two trivial data types, null
and undefined, each of which defines only a
single value.
• Object- Composite data type
Primitives
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
9
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
• Variables- will be declared with var.
• While naming your variables in JavaScript, keep
the following rules in mind.
• You should not use any of the JavaScript reserved
keywords as a variable name.
• JavaScript variable names should not start with a
numeral (0-9).
• JavaScript variable names are case-sensitive.
• Scope
• Untyped
Primitives
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
10
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
▪ In an expression a+b, a and b are operands and +
is an operator.
▪ JavaScript supports the following types of
operators.
▪ Arithmetic Operators
▪ Comparison Operators
▪ Logical (or Relational) Operators
▪ Assignment Operators
▪ Conditional (or ternary) Operators
Operations
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
11
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
• + (Addition)
– A+B
• - (Subtraction)
– A-B
• * (Multiplication)
– A*B
• / (Division)
– A/B
• % (Modolus)
– A%B
• ++ (Increment)
– A++
• -- (Decrement)
– A--
Operations-Arithmetic operations
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
12
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
• = = (Equal)
– (A == B)
• != (Not Equal)
– (A != B)
• > (Greater than)
– (A > B)
• < (Less than)
– (A < B)
• >= (Greater than or Equal to)
– (A >= B)
• <= (Less than or Equal to)
– (A <= B)
Operations-Comparison operations
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
13
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
• && (Logical AND)
– (A && B)
• || (Logical OR)
– (A || B) is true
• ! (Logical NOT)
– ! (A && B)
Operations-Logical/Relational operations
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
14
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
• = (Simple Assignment )
– Ex: C = A + B will assign the value of A + B into C
• += (Add and Assignment)
– Ex: C += A is equivalent to C = C + A
• *= (Multiply and Assignment)
– Ex: C *= A is equivalent to C = C * A
• /= (Divide and Assignment)
– Ex: C /= A is equivalent to C = C / A
Operations-Assignment operators
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
15
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
▪ ? : (Conditional )
▪ If Condition is true? Then value X : Other wise
value Y
▪ Ex: (a>b)? X: Y;
Operations-conditional/ternary operators
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
16
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
• In an expression a+b, a and b are operands and +
is an operator.
• Expression is a Combination of operators and
operands.
▪ JavaScript supports the following types of
Expressions.
▪ Arithmetic Expressions
▪ Comparison Expressions
▪ Logical (or Relational) Expressions
▪ Assignment Expressions
▪ Conditional (or ternary) Expressions
Expressions
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
17
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
• If
• If else
• If … Else if
Control Statements-Conditionals
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
18
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
Control Statements-Conditionals
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
19
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
Control Statements-Conditionals
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
20
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
Control Statements-Conditionals
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
21
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
Control Statements-Loops-while
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
22
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
Control Statements-Loops-do while
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
23
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
Control Statements-Loops-for
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
24
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
Control Statements-Loops-Loop control
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
25
To come out of a loop without reaching its bottom – Break
To skip a part of code an to start a next iteration - continue
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
• Function is a group of reusable code, can call
anywhere in program.
• Used to break big problem into small units
• No need to write the same code again and again.
Functions
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
26
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
Functions-Example
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
27
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
• It is a collection of variables of same type.
• It store multiple values in a single variable.
Arrays
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
28
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
• It is a sequence of characters used to search a
pattern.
• Search pattern can be used for text search and text
replace.
• It can be a single character or more characters
• Ex: /csea/
• It uses a string methods called search() and
replace().
• Search-return the position
• replace-return the modified string
Regular expressions
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
29
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
Regular expressions-Example
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
30
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
Regular expressions-Modifiers
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
31
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
•/e/.exec("The best things in life are free!");
•Returns true or false
Pattern Matching using regular
expressions
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
32
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
Blooms Taxonomy
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
33
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
Any Questions/Clarifications/Doubts
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
34
Audisankara
College
of
Engineering
and
Technology(A)::Gudur,AP.
Department of CSE
Thank you all
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
35

Basics of Java Script