3. 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
4. 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
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
11/8/2021
Dr. Vikram Neerugatti, Associate Professor,
Dept. of CSE, ASCET, Guduru.
5
6. 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
9. 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
10. 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
11. 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
12. 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
13. 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
15. 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
17. 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
26. 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
29. 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