SlideShare a Scribd company logo
UNIT – III
JAVA SCRIPT
Arulkumar V P
Introduction: Scripting
• Scripting: Scripting is an easy way of automating the process
which is needed to be done step-by-step by a user.
• Scripting languages: do not require the compilation step and
are rather interpreted. For example, normally, a C program needs
to be compiled before running whereas normally, a scripting
language like JavaScript or PHP need not be compiled.
• Applications of Scripting Languages :
1.To automate certain tasks in a program
2.Extracting information from a data set
3.Less code intensive as compared to traditional programming
languages
Introduction: Types of Scripting
• Client scripting can be defined as a code that is present in
a client’s HTML page.
• It is usually attached to the browser in a language that is
compatible with the browser.
• The browser then downloads that code temporarily and
processes it without the server. If additional information is
required, a request is raised and sent to the server.
• Client-side programming languages are :
1) Javascript
2) VBScript
3) HTML
4) CSS
5) AJAX
6) jQuery etc.
Introduction: Types of Scripting
• Server-side scripting is a method of designing websites
so that the process or user request is run on the
originating server.
• Server-side scripts provide an interface to the user and
limit access to proprietary data and help keep control of
the script source code.
• which produce a response customized for each user's
(client's) request to the website.
• Server-side programming languages are :
ASP .NET, PHP, C++, Java and JSP, Python, Ruby on Rails, R
Introduction: Types of Scripting
CLIENT SIDE SCRIPTING SERVER SIDE SCRIPTING
Source code is visible to user. Source code is not visible to user
because its output of server side is
a HTML page.
It usually depends on browser
and it’s version.
In this any server side technology
can be use and it does not depend
on client.
It runs on user’s computer. It runs on web server.
There are many advantages link
with this like faster. response
times, a more interactive
application.
The primary advantage is its ability
to highly customize, response
requirements, access rights based
on user.
Introduction: Types of Scripting
CLIENT SIDE SCRIPTING SERVER SIDE SCRIPTING
It does not provide security for
data.
It provides more security for data.
It is a technique use in web
development in which scripts
runs on clients browser.
It is a technique that uses scripts
on web server to produce a
response that is customized for
each clients request.
HTML, CSS, javascript and
VBScript
ASP, PHP, Python, Java and Ruby
Introduction: JavaScript
• JavaScript is the most popular scripting language on the
internet, and works in all major browsers, such as Internet
Explorer, Firefox, Chrome, Opera, and Safari.
• What is JavaScript?
• JavaScript is a scripting language
• JavaScript is usually embedded directly into HTML pages
• JavaScript was designed to add interactivity to HTML pages
• JavaScript is an interpreted language (means that scripts
execute without preliminary compilation)
Introduction: JavaScript
• Everyone can use JavaScript without purchasing a license.
• JavaScript is Netscape's cross-platform, object-oriented
scripting language.
• Core JavaScript contains a core set of objects, such as
Array, Date, and Math, and
• A core set of language elements such as operators,
control structures, and statements. Core JavaScript can
be extended for a variety of purposes by supplementing it
with additional objects.
Introduction: JavaScript
What can a JavaScript do? (Applications)
• JavaScript gives HTML designers a programming tool
HTML authors are normally not programmers, but JavaScript
is a scripting language with a very simple syntax! Almost
anyone can put small "snippets" of code into their HTML
pages
• JavaScript can put dynamic text into an HTML page - A
JavaScript statement like this:
document.write("<h1>" + name + "</h1>") can write a
variable text into an HTML page
• JavaScript can react to events - A JavaScript can be set to
execute when something happens, like when a page has
finished loading or when a user clicks on an HTML element.
Introduction: JavaScript
What can a JavaScript do?
• JavaScript can be used to validate data - A JavaScript
can be used to validate form data before it is submitted
to a server. This saves the server from extra processing
• JavaScript can be used to create cookies - A JavaScript
can be used to store and retrieve information on the
visitor's computer
• JavaScript can read and write HTML elements - A
JavaScript can read and change the content of an HTML
element
JavaScript: Placement in HTML File
In HTML, JavaScript code is inserted between
<script> . . . </script> tag
The most preferred ways to include JavaScript in an
HTML file are
1. Script in <head>...</head> section.
2. Script in <body>...</body> section.
3. Script in <body>...</body> and <head>...</head>
sections.
4. Script in an external file and then include in
<head>...</head> section.
JavaScript: <script> tag
JavaScript programs can be inserted into any part of an
HTML document with the help of the <script> tag, which is
automatically executed when the browser processes the tag.
The <script> tag has a few attributes that are
The type attribute: <script type=…>
he language attribute: <script language=…>
<script type="text/javascript">
. . . .
</script>
Script files are attached to HTML with the src attribute:
<script src="/path/to/script.js"> . . . </script>
JavaScript: <script> tag
A single <script> tag can't have both the src attribute
and code inside.
<script src="file.js"></script> <script>
alert("HELLO");
</script>
<script src="file.js">
alert("HELLO"); // the content is ignored, because src
is set </script>
x

JavaScript: <script> in <head>
• If you want to have a script run on some event, such as when a
user clicks somewhere
• Scripts to be executed when they are called, or when an event
is triggered, go in the head section.
• If you place a script in the head section, you will ensure that
the script is loaded before anyone uses it.
<html>
<head>
<script type = "text/javascript">
alert("Hello World")
</script>
</head>
<body>
<h2> Alert Completed </h2>
</body>
</html>
JavaScript: <script> in <body>
If we want to display/generate content in html on page
load, we can place <script> inside the <body>:
<html>
<head>
</head>
<body>
<script type = "text/javascript">
document.write("Hello World")
</script>
<p>This is web page body </p>
</body>
</html>
JavaScript: <script> in <head> & <body>
You can place an unlimited number of scripts in your
document, so you can have scripts in both the body and the head
section, the <script> in <head> will be loaded first.
<html>
<head>
<script type="text/javascript">
....
</script>
</head>
<body>
<script type="text/javascript">
....
</script>
</body>
</html>
JavaScript: <script> in External file (.js)
• JavaScript files have the file extension .js
• External JavaScript file (.js) can be referenced using
<script src="/PathToScriptFile.js"></script>
 src attribute is used to specify the full path of .js file.
• You can place an external script reference in <head> or
<body> as you like.
• External scripts cannot contain <script> tags.
• Placing scripts in external files has some advantages:
• It separates HTML and code
• It makes HTML and JavaScript easier to read and maintain
• Cached JavaScript files can speed up page loads
JavaScript: Code Structure
• Statements are syntax constructs and commands that perform
actions.
• We can have as many statements in our code as we want.
Statements can be separated with a semicolon.
• The semicolon is optional (according to the JavaScript
standard), and the browser is supposed to interpret the end of
the line as the end of the statement.
• A semicolon may be omitted in most cases when a line break
exists.
var v= 3 +
4 + 4;
If the line ends with a plus "+", then it is an "incomplete
expression", so the semicolon is not required. And in this case
that works as intended.
JavaScript: Code Structure
Note: Using semicolons makes it possible to write multiple
statements on one line.
Ex:
var name = "Jeeva"
var mark = 89
(or)
var name = "Jeeva"; var mark = 89
JavaScript is Case Sensitive
Unlike HTML, JavaScript is case sensitive - therefore
watch your capitalization closely when you write JavaScript
statements, create or call variables, objects and functions.
Ex: num, Num are different variables.
JavaScript: Code Structure
JavaScript Code:
JavaScript code (or just JavaScript) is a sequence of JavaScript
statements.
Each statement is executed by the browser in the sequence they are
written.
This example will write a heading and two paragraphs to a web
page:
Example:
<script type="text/javascript">
document.write("<h1>This is a heading</h1>");
document.write("<p>This is a paragraph.</p>");
document.write("<p>This is another paragraph.</p>");
</script>
JavaScript: Code Structure
JavaScript Blocks
• JavaScript statements can be grouped together in blocks.
• Blocks start with a left curly bracket { ,
• and ends with a right curly bracket } .
• The purpose of a block is to make the sequence of statements
execute together.
Example
<script type="text/javascript">
{
document.write("<h1>This is a heading</h1>");
document.write("<p>This is a paragraph.</p>");
document.write("<p>This is another paragraph.</p>");
}
</script>
JavaScript: Comments
Single line comments:
Comments can be added to explain the JavaScript, or to make the
code more readable.
Single line comments start with //.
JavaScript Multi-Line Comments
Multi line comments start with /* and end with */.
The following example uses a multi line comment to explain the
code:
Using Comments at the End of a Line
In the following example the comment is placed at the end of a
code line.
document.write("Hello"); // Write "Hello“
JavaScript: Variables
Variables as symbolic names for values in your application. You
give variables names by which used to hold values or expressions.
We refer to them and which must conform to certain rules.
A variable can have a short name, like x, or a more descriptive name,
like carname.
• A JavaScript identifier, or name, must start with a letter or
underscore ("_"),
• Subsequent characters can also be digits (0-9).
• Because JavaScript is case sensitive, letters include the characters
"A" through "Z" (uppercase) and the characters "a" through "z"
(lowercase).
• Identifier name must not contain any white-space.
• legal names: Number_hits, temp99, and _name
• illegal names: 9temp, Number hits,
JavaScript: Variables
Declaring (Creating) JavaScript Variables
Creating variables in JavaScript is most often referred to as
"declaring" variables.
We can declare a variable in two ways:
• By simply assigning its a value. For example, x = 42
• With the keyword var. For example, var x = 42
var x;
var carname;
After the declaration shown above, the variables are empty (they
have no values yet).
However, you can also assign values to the variables when you
declare them:
var x=5;
var carname="Volvo";
JavaScript: Variables
Assigning Values to Undeclared JavaScript Variables:
If you assign values to variables that have not yet been declared,
the variables will automatically be declared.
These statements:
x=5;
carname="Volvo";
Redeclaring JavaScript Variables:
If you redeclare a JavaScript variable, it will not lose its original
value.
var x=5;
var x;
After the execution of the statements above, the variable x will still
have the value of 5. The value of x is not reset (or cleared) when
you redeclare it.
JavaScript: Variables Scope
When we set a variable identifier by assignment outside of a
function, it is called a global variable,
because it is available everywhere in the current document. When
we declare a variable within a
function, it is called a local variable, because it is available only
within the function.
let keyword used for variable declaration in JavaScript like var but
the difference between them is that var is function scoped(global)
and let is block scoped. Example:
var a = 10;
var a = 20; //a is replaced
let a = 10;
let a = 20; //SyntaxError: //Identifier
'a' has already been declared
JavaScript: Data Types
JavaScript: Operators
JavaScript operators are symbols that are used to perform
operations on operands, types of operators in JavaScript
• Arithmetic Operators
• Comparison (Relational) Operators
• Assignment Operators
• Bitwise Operators
• Logical Operators
• Special Operators
JavaScript: Arithmetic Operators
Operator Description Example
+ Addition 10+20 = 30
- Subtraction 20-10 = 10
* Multiplication 10*20 = 200
/ Division 20/10 = 2
%
Modulus
(Remainder)
20%10 = 0
++ Increment var a=10; a++; Now a = 11
-- Decrement var a=10; a--; Now a = 9
JavaScript: Comparison Operators
Operator Description Example
== Is equal to 10==20 => false
===
Identical
(equal and of same type)
10===20 => false
10 === "10" => false
!= Not equal to 10!=20 => true
!== Not Identical 20!==20 => false
> Greater than 20>10 => true
>= Greater than or equal to 20>=10 => true
< Less than 20<10 => false
<= Less than or equal to 20<=10 => false
JavaScript: Assignment Operators
Operator Description Example
= Assign 10+10 = 20
+= Add and assign var a=10; a+=20; Now a = 30
-= Subtract and assign var a=20; a-=10; Now a = 10
*= Multiply and assign var a=10; a*=20; Now a = 200
/= Divide and assign var a=10; a/=2; Now a = 5
%= Modulus and assign var a=10; a%=2; Now a = 0
JavaScript: Logical Operators
Operator Description Example
&& Logical AND (10==20 && 20==33)
=> false
|| Logical OR (10==20 || 20==33)
=> false
! Logical Not !(10==20) => true
Logical operators are used to determine the logic between
variables or values. An expression containing logical
operator returns either 0 or 1 depending upon whether
expression results true or false.
JavaScript: Bitwise Operators
The bitwise operators perform bitwise operations on
operands.
Operator Description Example
& Bitwise AND (10==20 & 20==33) = false
| Bitwise OR (10==20 | 20==33) = false
^ Bitwise XOR (10==20 ^ 20==33) = false
~ Bitwise NOT (~10) = -10
<< Bitwise Left Shift (10<<2) = 40
>> Bitwise Right Shift (10>>2) = 2
>>>
Bitwise Right Shift
with Zero
(10>>>2) = 2
JavaScript: Bitwise Operators
The bitwise operators perform bitwise operations on
operands. Example:
12 = 00001100 (In Binary)
25 = 00011001 (In Binary)
Bit Operation of 12 and 25
00001100 ------>12
& 00011001 ------>25
00001000 ==> 8 (In decimal)

More Related Content

What's hot (20)

Improving web site performance and scalability while saving
Improving web site performance and scalability while savingImproving web site performance and scalability while saving
Improving web site performance and scalability while saving
mdc11
 
Web Fundamentals
Web FundamentalsWeb Fundamentals
Web Fundamentals
arunv
 
Ui perf
Ui perfUi perf
Ui perf
Franz Allan See
 
Client-side Website Optimization
Client-side Website OptimizationClient-side Website Optimization
Client-side Website Optimization
Radu Pintilie
 
Web performance Talk
Web performance TalkWeb performance Talk
Web performance Talk
Prasoon Agrawal
 
Optimizing Client-Side Performance
Optimizing Client-Side PerformanceOptimizing Client-Side Performance
Optimizing Client-Side Performance
andrew4web
 
Website/Web Applications / Static vs Dynamic Website / Web Browser /
Website/Web Applications  / Static vs Dynamic Website / Web Browser / Website/Web Applications  / Static vs Dynamic Website / Web Browser /
Website/Web Applications / Static vs Dynamic Website / Web Browser /
Sachin Yadav
 
Skalowalna architektura na przykładzie soccerway.com
Skalowalna architektura na przykładzie soccerway.comSkalowalna architektura na przykładzie soccerway.com
Skalowalna architektura na przykładzie soccerway.com
Spodek 2.0
 
Difference between reseller hosting and dedicated web servers
Difference between reseller hosting and dedicated web serversDifference between reseller hosting and dedicated web servers
Difference between reseller hosting and dedicated web servers
HTS Hosting
 
Caching in Drupal 8
Caching in Drupal 8Caching in Drupal 8
Caching in Drupal 8
valuebound
 
Reliable dedicated server hosting provider
Reliable dedicated server hosting providerReliable dedicated server hosting provider
Reliable dedicated server hosting provider
Go4hosting Web Hosting Provider
 
Web Hosting Solutions: Shared Hosting and VPS Hosting
Web Hosting Solutions: Shared Hosting and VPS HostingWeb Hosting Solutions: Shared Hosting and VPS Hosting
Web Hosting Solutions: Shared Hosting and VPS Hosting
HTS Hosting
 
Differences between Reseller Hosting, Dedicated Hosting & Shared Hosting
Differences between Reseller Hosting, Dedicated Hosting & Shared HostingDifferences between Reseller Hosting, Dedicated Hosting & Shared Hosting
Differences between Reseller Hosting, Dedicated Hosting & Shared Hosting
HTS Hosting
 
Apache Multiview Vulnerability
Apache Multiview VulnerabilityApache Multiview Vulnerability
Apache Multiview Vulnerability
Ronan Dunne, CEH, SSCP
 
Simple server side cache for Express.js with Node.js
Simple server side cache for Express.js with Node.jsSimple server side cache for Express.js with Node.js
Simple server side cache for Express.js with Node.js
Gokusen Newz
 
Web servers
Web serversWeb servers
Web servers
webhostingguy
 
Web hosting
Web hostingWeb hosting
Web hosting
audace82
 
web hosting
web hostingweb hosting
web hosting
Thush madu
 
What is Server? (Web Server vs Application Server)
What is Server? (Web Server vs Application Server)What is Server? (Web Server vs Application Server)
What is Server? (Web Server vs Application Server)
Amit Nirala
 
Posting Images using Android
Posting Images using AndroidPosting Images using Android
Posting Images using Android
Ali Muzaffar
 
Improving web site performance and scalability while saving
Improving web site performance and scalability while savingImproving web site performance and scalability while saving
Improving web site performance and scalability while saving
mdc11
 
Web Fundamentals
Web FundamentalsWeb Fundamentals
Web Fundamentals
arunv
 
Client-side Website Optimization
Client-side Website OptimizationClient-side Website Optimization
Client-side Website Optimization
Radu Pintilie
 
Optimizing Client-Side Performance
Optimizing Client-Side PerformanceOptimizing Client-Side Performance
Optimizing Client-Side Performance
andrew4web
 
Website/Web Applications / Static vs Dynamic Website / Web Browser /
Website/Web Applications  / Static vs Dynamic Website / Web Browser / Website/Web Applications  / Static vs Dynamic Website / Web Browser /
Website/Web Applications / Static vs Dynamic Website / Web Browser /
Sachin Yadav
 
Skalowalna architektura na przykładzie soccerway.com
Skalowalna architektura na przykładzie soccerway.comSkalowalna architektura na przykładzie soccerway.com
Skalowalna architektura na przykładzie soccerway.com
Spodek 2.0
 
Difference between reseller hosting and dedicated web servers
Difference between reseller hosting and dedicated web serversDifference between reseller hosting and dedicated web servers
Difference between reseller hosting and dedicated web servers
HTS Hosting
 
Caching in Drupal 8
Caching in Drupal 8Caching in Drupal 8
Caching in Drupal 8
valuebound
 
Web Hosting Solutions: Shared Hosting and VPS Hosting
Web Hosting Solutions: Shared Hosting and VPS HostingWeb Hosting Solutions: Shared Hosting and VPS Hosting
Web Hosting Solutions: Shared Hosting and VPS Hosting
HTS Hosting
 
Differences between Reseller Hosting, Dedicated Hosting & Shared Hosting
Differences between Reseller Hosting, Dedicated Hosting & Shared HostingDifferences between Reseller Hosting, Dedicated Hosting & Shared Hosting
Differences between Reseller Hosting, Dedicated Hosting & Shared Hosting
HTS Hosting
 
Simple server side cache for Express.js with Node.js
Simple server side cache for Express.js with Node.jsSimple server side cache for Express.js with Node.js
Simple server side cache for Express.js with Node.js
Gokusen Newz
 
Web hosting
Web hostingWeb hosting
Web hosting
audace82
 
What is Server? (Web Server vs Application Server)
What is Server? (Web Server vs Application Server)What is Server? (Web Server vs Application Server)
What is Server? (Web Server vs Application Server)
Amit Nirala
 
Posting Images using Android
Posting Images using AndroidPosting Images using Android
Posting Images using Android
Ali Muzaffar
 

Similar to JS BASICS JAVA SCRIPT SCRIPTING (20)

Basics java scripts
Basics java scriptsBasics java scripts
Basics java scripts
ch samaram
 
Java script by Act Academy
Java script by Act AcademyJava script by Act Academy
Java script by Act Academy
actanimation
 
JAVA SCRIPT
JAVA SCRIPTJAVA SCRIPT
JAVA SCRIPT
Go4Guru
 
2javascript web programming with JAVA script
2javascript web programming with JAVA script2javascript web programming with JAVA script
2javascript web programming with JAVA script
umardanjumamaiwada
 
CS8651- Unit 2 - JS.internet programming paper anna university -2017 regulation
CS8651- Unit 2 - JS.internet programming paper anna university -2017 regulationCS8651- Unit 2 - JS.internet programming paper anna university -2017 regulation
CS8651- Unit 2 - JS.internet programming paper anna university -2017 regulation
amrashbhanuabdul
 
Unit 4 Java script.pptx
Unit 4 Java script.pptxUnit 4 Java script.pptx
Unit 4 Java script.pptx
Gangesh8
 
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
Bhavsingh Maloth
 
Web programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh MalothWeb programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh Maloth
Bhavsingh Maloth
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
Andres Baravalle
 
Java script Basic
Java script BasicJava script Basic
Java script Basic
Jaya Kumari
 
JavaScript_III.pptx
JavaScript_III.pptxJavaScript_III.pptx
JavaScript_III.pptx
rashmiisrani1
 
HNDIT1022 Week 08, 09 10 Theory web .pptx
HNDIT1022 Week 08, 09  10 Theory web .pptxHNDIT1022 Week 08, 09  10 Theory web .pptx
HNDIT1022 Week 08, 09 10 Theory web .pptx
IsuriUmayangana
 
Unit 4(it workshop)
Unit 4(it workshop)Unit 4(it workshop)
Unit 4(it workshop)
Dr.Lokesh Gagnani
 
Client side scripting using Javascript
Client side scripting using JavascriptClient side scripting using Javascript
Client side scripting using Javascript
Bansari Shah
 
Java script
Java scriptJava script
Java script
sanjay joshi
 
Java script
Java scriptJava script
Java script
umesh patil
 
Lecture-15.pptx
Lecture-15.pptxLecture-15.pptx
Lecture-15.pptx
vishal choudhary
 
CHAPTER 3 JS (1).pptx
CHAPTER 3  JS (1).pptxCHAPTER 3  JS (1).pptx
CHAPTER 3 JS (1).pptx
achutachut
 
basics of javascript and fundamentals ppt
basics of javascript and fundamentals pptbasics of javascript and fundamentals ppt
basics of javascript and fundamentals ppt
MaanKansagra
 
Javascript overview and introduction to js
Javascript overview and introduction to jsJavascript overview and introduction to js
Javascript overview and introduction to js
mohammedarshadhussai4
 
Basics java scripts
Basics java scriptsBasics java scripts
Basics java scripts
ch samaram
 
Java script by Act Academy
Java script by Act AcademyJava script by Act Academy
Java script by Act Academy
actanimation
 
JAVA SCRIPT
JAVA SCRIPTJAVA SCRIPT
JAVA SCRIPT
Go4Guru
 
2javascript web programming with JAVA script
2javascript web programming with JAVA script2javascript web programming with JAVA script
2javascript web programming with JAVA script
umardanjumamaiwada
 
CS8651- Unit 2 - JS.internet programming paper anna university -2017 regulation
CS8651- Unit 2 - JS.internet programming paper anna university -2017 regulationCS8651- Unit 2 - JS.internet programming paper anna university -2017 regulation
CS8651- Unit 2 - JS.internet programming paper anna university -2017 regulation
amrashbhanuabdul
 
Unit 4 Java script.pptx
Unit 4 Java script.pptxUnit 4 Java script.pptx
Unit 4 Java script.pptx
Gangesh8
 
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
Bhavsingh Maloth
 
Web programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh MalothWeb programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh Maloth
Bhavsingh Maloth
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
Andres Baravalle
 
Java script Basic
Java script BasicJava script Basic
Java script Basic
Jaya Kumari
 
HNDIT1022 Week 08, 09 10 Theory web .pptx
HNDIT1022 Week 08, 09  10 Theory web .pptxHNDIT1022 Week 08, 09  10 Theory web .pptx
HNDIT1022 Week 08, 09 10 Theory web .pptx
IsuriUmayangana
 
Client side scripting using Javascript
Client side scripting using JavascriptClient side scripting using Javascript
Client side scripting using Javascript
Bansari Shah
 
CHAPTER 3 JS (1).pptx
CHAPTER 3  JS (1).pptxCHAPTER 3  JS (1).pptx
CHAPTER 3 JS (1).pptx
achutachut
 
basics of javascript and fundamentals ppt
basics of javascript and fundamentals pptbasics of javascript and fundamentals ppt
basics of javascript and fundamentals ppt
MaanKansagra
 
Javascript overview and introduction to js
Javascript overview and introduction to jsJavascript overview and introduction to js
Javascript overview and introduction to js
mohammedarshadhussai4
 
Ad

Recently uploaded (20)

社内勉強会資料_Chain of Thought .
社内勉強会資料_Chain of Thought                           .社内勉強会資料_Chain of Thought                           .
社内勉強会資料_Chain of Thought .
NABLAS株式会社
 
A Comprehensive Investigation into the Accuracy of Soft Computing Tools for D...
A Comprehensive Investigation into the Accuracy of Soft Computing Tools for D...A Comprehensive Investigation into the Accuracy of Soft Computing Tools for D...
A Comprehensive Investigation into the Accuracy of Soft Computing Tools for D...
Journal of Soft Computing in Civil Engineering
 
11th International Conference on Data Mining (DaMi 2025)
11th International Conference on Data Mining (DaMi 2025)11th International Conference on Data Mining (DaMi 2025)
11th International Conference on Data Mining (DaMi 2025)
kjim477n
 
Airport_Substation_With_Diagrams (2).pptx
Airport_Substation_With_Diagrams (2).pptxAirport_Substation_With_Diagrams (2).pptx
Airport_Substation_With_Diagrams (2).pptx
BibekMedhi2
 
operationg systemsdocumentmemorymanagement
operationg systemsdocumentmemorymanagementoperationg systemsdocumentmemorymanagement
operationg systemsdocumentmemorymanagement
SNIGDHAAPPANABHOTLA
 
02 - Ethics & Professionalism - BEM, IEM, MySET.PPT
02 - Ethics & Professionalism - BEM, IEM, MySET.PPT02 - Ethics & Professionalism - BEM, IEM, MySET.PPT
02 - Ethics & Professionalism - BEM, IEM, MySET.PPT
SharinAbGhani1
 
Top Cite Articles- International Journal on Soft Computing, Artificial Intell...
Top Cite Articles- International Journal on Soft Computing, Artificial Intell...Top Cite Articles- International Journal on Soft Computing, Artificial Intell...
Top Cite Articles- International Journal on Soft Computing, Artificial Intell...
ijscai
 
Semi-Conductor ppt ShubhamSeSemi-Con.pptx
Semi-Conductor ppt ShubhamSeSemi-Con.pptxSemi-Conductor ppt ShubhamSeSemi-Con.pptx
Semi-Conductor ppt ShubhamSeSemi-Con.pptx
studyshubham18
 
Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptxWeek 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
dayananda54
 
New Microsoft Office Word Documentfrf.docx
New Microsoft Office Word Documentfrf.docxNew Microsoft Office Word Documentfrf.docx
New Microsoft Office Word Documentfrf.docx
misheetasah
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
djiceramil
 
Présentation_gestion[1] [Autosaved].pptx
Présentation_gestion[1] [Autosaved].pptxPrésentation_gestion[1] [Autosaved].pptx
Présentation_gestion[1] [Autosaved].pptx
KHADIJAESSAKET
 
IOt Based Research on Challenges and Future
IOt Based Research on Challenges and FutureIOt Based Research on Challenges and Future
IOt Based Research on Challenges and Future
SACHINSAHU821405
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
djiceramil
 
SEW make Brake BE05 – BE30 Brake – Repair Kit
SEW make Brake BE05 – BE30 Brake – Repair KitSEW make Brake BE05 – BE30 Brake – Repair Kit
SEW make Brake BE05 – BE30 Brake – Repair Kit
projectultramechanix
 
Third Review PPT that consists of the project d etails like abstract.
Third Review PPT that consists of the project d etails like abstract.Third Review PPT that consists of the project d etails like abstract.
Third Review PPT that consists of the project d etails like abstract.
Sowndarya6
 
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdfIrja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus
 
Ppt on the related on the solar power system for electric vehicle engineering
Ppt on the related on the solar power system for electric vehicle engineeringPpt on the related on the solar power system for electric vehicle engineering
Ppt on the related on the solar power system for electric vehicle engineering
ravindrabodke
 
Universal Human Values and professional ethics Quantum AKTU BVE401
Universal Human Values and professional ethics Quantum AKTU BVE401Universal Human Values and professional ethics Quantum AKTU BVE401
Universal Human Values and professional ethics Quantum AKTU BVE401
Unknown
 
3. What is the principles of Teamwork_Module_V1.0.ppt
3. What is the principles of Teamwork_Module_V1.0.ppt3. What is the principles of Teamwork_Module_V1.0.ppt
3. What is the principles of Teamwork_Module_V1.0.ppt
engaash9
 
社内勉強会資料_Chain of Thought .
社内勉強会資料_Chain of Thought                           .社内勉強会資料_Chain of Thought                           .
社内勉強会資料_Chain of Thought .
NABLAS株式会社
 
11th International Conference on Data Mining (DaMi 2025)
11th International Conference on Data Mining (DaMi 2025)11th International Conference on Data Mining (DaMi 2025)
11th International Conference on Data Mining (DaMi 2025)
kjim477n
 
Airport_Substation_With_Diagrams (2).pptx
Airport_Substation_With_Diagrams (2).pptxAirport_Substation_With_Diagrams (2).pptx
Airport_Substation_With_Diagrams (2).pptx
BibekMedhi2
 
operationg systemsdocumentmemorymanagement
operationg systemsdocumentmemorymanagementoperationg systemsdocumentmemorymanagement
operationg systemsdocumentmemorymanagement
SNIGDHAAPPANABHOTLA
 
02 - Ethics & Professionalism - BEM, IEM, MySET.PPT
02 - Ethics & Professionalism - BEM, IEM, MySET.PPT02 - Ethics & Professionalism - BEM, IEM, MySET.PPT
02 - Ethics & Professionalism - BEM, IEM, MySET.PPT
SharinAbGhani1
 
Top Cite Articles- International Journal on Soft Computing, Artificial Intell...
Top Cite Articles- International Journal on Soft Computing, Artificial Intell...Top Cite Articles- International Journal on Soft Computing, Artificial Intell...
Top Cite Articles- International Journal on Soft Computing, Artificial Intell...
ijscai
 
Semi-Conductor ppt ShubhamSeSemi-Con.pptx
Semi-Conductor ppt ShubhamSeSemi-Con.pptxSemi-Conductor ppt ShubhamSeSemi-Con.pptx
Semi-Conductor ppt ShubhamSeSemi-Con.pptx
studyshubham18
 
Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptxWeek 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
dayananda54
 
New Microsoft Office Word Documentfrf.docx
New Microsoft Office Word Documentfrf.docxNew Microsoft Office Word Documentfrf.docx
New Microsoft Office Word Documentfrf.docx
misheetasah
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
djiceramil
 
Présentation_gestion[1] [Autosaved].pptx
Présentation_gestion[1] [Autosaved].pptxPrésentation_gestion[1] [Autosaved].pptx
Présentation_gestion[1] [Autosaved].pptx
KHADIJAESSAKET
 
IOt Based Research on Challenges and Future
IOt Based Research on Challenges and FutureIOt Based Research on Challenges and Future
IOt Based Research on Challenges and Future
SACHINSAHU821405
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
djiceramil
 
SEW make Brake BE05 – BE30 Brake – Repair Kit
SEW make Brake BE05 – BE30 Brake – Repair KitSEW make Brake BE05 – BE30 Brake – Repair Kit
SEW make Brake BE05 – BE30 Brake – Repair Kit
projectultramechanix
 
Third Review PPT that consists of the project d etails like abstract.
Third Review PPT that consists of the project d etails like abstract.Third Review PPT that consists of the project d etails like abstract.
Third Review PPT that consists of the project d etails like abstract.
Sowndarya6
 
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdfIrja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus
 
Ppt on the related on the solar power system for electric vehicle engineering
Ppt on the related on the solar power system for electric vehicle engineeringPpt on the related on the solar power system for electric vehicle engineering
Ppt on the related on the solar power system for electric vehicle engineering
ravindrabodke
 
Universal Human Values and professional ethics Quantum AKTU BVE401
Universal Human Values and professional ethics Quantum AKTU BVE401Universal Human Values and professional ethics Quantum AKTU BVE401
Universal Human Values and professional ethics Quantum AKTU BVE401
Unknown
 
3. What is the principles of Teamwork_Module_V1.0.ppt
3. What is the principles of Teamwork_Module_V1.0.ppt3. What is the principles of Teamwork_Module_V1.0.ppt
3. What is the principles of Teamwork_Module_V1.0.ppt
engaash9
 
Ad

JS BASICS JAVA SCRIPT SCRIPTING

  • 1. UNIT – III JAVA SCRIPT Arulkumar V P
  • 2. Introduction: Scripting • Scripting: Scripting is an easy way of automating the process which is needed to be done step-by-step by a user. • Scripting languages: do not require the compilation step and are rather interpreted. For example, normally, a C program needs to be compiled before running whereas normally, a scripting language like JavaScript or PHP need not be compiled. • Applications of Scripting Languages : 1.To automate certain tasks in a program 2.Extracting information from a data set 3.Less code intensive as compared to traditional programming languages
  • 3. Introduction: Types of Scripting • Client scripting can be defined as a code that is present in a client’s HTML page. • It is usually attached to the browser in a language that is compatible with the browser. • The browser then downloads that code temporarily and processes it without the server. If additional information is required, a request is raised and sent to the server. • Client-side programming languages are : 1) Javascript 2) VBScript 3) HTML 4) CSS 5) AJAX 6) jQuery etc.
  • 4. Introduction: Types of Scripting • Server-side scripting is a method of designing websites so that the process or user request is run on the originating server. • Server-side scripts provide an interface to the user and limit access to proprietary data and help keep control of the script source code. • which produce a response customized for each user's (client's) request to the website. • Server-side programming languages are : ASP .NET, PHP, C++, Java and JSP, Python, Ruby on Rails, R
  • 5. Introduction: Types of Scripting CLIENT SIDE SCRIPTING SERVER SIDE SCRIPTING Source code is visible to user. Source code is not visible to user because its output of server side is a HTML page. It usually depends on browser and it’s version. In this any server side technology can be use and it does not depend on client. It runs on user’s computer. It runs on web server. There are many advantages link with this like faster. response times, a more interactive application. The primary advantage is its ability to highly customize, response requirements, access rights based on user.
  • 6. Introduction: Types of Scripting CLIENT SIDE SCRIPTING SERVER SIDE SCRIPTING It does not provide security for data. It provides more security for data. It is a technique use in web development in which scripts runs on clients browser. It is a technique that uses scripts on web server to produce a response that is customized for each clients request. HTML, CSS, javascript and VBScript ASP, PHP, Python, Java and Ruby
  • 7. Introduction: JavaScript • JavaScript is the most popular scripting language on the internet, and works in all major browsers, such as Internet Explorer, Firefox, Chrome, Opera, and Safari. • What is JavaScript? • JavaScript is a scripting language • JavaScript is usually embedded directly into HTML pages • JavaScript was designed to add interactivity to HTML pages • JavaScript is an interpreted language (means that scripts execute without preliminary compilation)
  • 8. Introduction: JavaScript • Everyone can use JavaScript without purchasing a license. • JavaScript is Netscape's cross-platform, object-oriented scripting language. • Core JavaScript contains a core set of objects, such as Array, Date, and Math, and • A core set of language elements such as operators, control structures, and statements. Core JavaScript can be extended for a variety of purposes by supplementing it with additional objects.
  • 9. Introduction: JavaScript What can a JavaScript do? (Applications) • JavaScript gives HTML designers a programming tool HTML authors are normally not programmers, but JavaScript is a scripting language with a very simple syntax! Almost anyone can put small "snippets" of code into their HTML pages • JavaScript can put dynamic text into an HTML page - A JavaScript statement like this: document.write("<h1>" + name + "</h1>") can write a variable text into an HTML page • JavaScript can react to events - A JavaScript can be set to execute when something happens, like when a page has finished loading or when a user clicks on an HTML element.
  • 10. Introduction: JavaScript What can a JavaScript do? • JavaScript can be used to validate data - A JavaScript can be used to validate form data before it is submitted to a server. This saves the server from extra processing • JavaScript can be used to create cookies - A JavaScript can be used to store and retrieve information on the visitor's computer • JavaScript can read and write HTML elements - A JavaScript can read and change the content of an HTML element
  • 11. JavaScript: Placement in HTML File In HTML, JavaScript code is inserted between <script> . . . </script> tag The most preferred ways to include JavaScript in an HTML file are 1. Script in <head>...</head> section. 2. Script in <body>...</body> section. 3. Script in <body>...</body> and <head>...</head> sections. 4. Script in an external file and then include in <head>...</head> section.
  • 12. JavaScript: <script> tag JavaScript programs can be inserted into any part of an HTML document with the help of the <script> tag, which is automatically executed when the browser processes the tag. The <script> tag has a few attributes that are The type attribute: <script type=…> he language attribute: <script language=…> <script type="text/javascript"> . . . . </script> Script files are attached to HTML with the src attribute: <script src="/path/to/script.js"> . . . </script>
  • 13. JavaScript: <script> tag A single <script> tag can't have both the src attribute and code inside. <script src="file.js"></script> <script> alert("HELLO"); </script> <script src="file.js"> alert("HELLO"); // the content is ignored, because src is set </script> x 
  • 14. JavaScript: <script> in <head> • If you want to have a script run on some event, such as when a user clicks somewhere • Scripts to be executed when they are called, or when an event is triggered, go in the head section. • If you place a script in the head section, you will ensure that the script is loaded before anyone uses it. <html> <head> <script type = "text/javascript"> alert("Hello World") </script> </head> <body> <h2> Alert Completed </h2> </body> </html>
  • 15. JavaScript: <script> in <body> If we want to display/generate content in html on page load, we can place <script> inside the <body>: <html> <head> </head> <body> <script type = "text/javascript"> document.write("Hello World") </script> <p>This is web page body </p> </body> </html>
  • 16. JavaScript: <script> in <head> & <body> You can place an unlimited number of scripts in your document, so you can have scripts in both the body and the head section, the <script> in <head> will be loaded first. <html> <head> <script type="text/javascript"> .... </script> </head> <body> <script type="text/javascript"> .... </script> </body> </html>
  • 17. JavaScript: <script> in External file (.js) • JavaScript files have the file extension .js • External JavaScript file (.js) can be referenced using <script src="/PathToScriptFile.js"></script>  src attribute is used to specify the full path of .js file. • You can place an external script reference in <head> or <body> as you like. • External scripts cannot contain <script> tags. • Placing scripts in external files has some advantages: • It separates HTML and code • It makes HTML and JavaScript easier to read and maintain • Cached JavaScript files can speed up page loads
  • 18. JavaScript: Code Structure • Statements are syntax constructs and commands that perform actions. • We can have as many statements in our code as we want. Statements can be separated with a semicolon. • The semicolon is optional (according to the JavaScript standard), and the browser is supposed to interpret the end of the line as the end of the statement. • A semicolon may be omitted in most cases when a line break exists. var v= 3 + 4 + 4; If the line ends with a plus "+", then it is an "incomplete expression", so the semicolon is not required. And in this case that works as intended.
  • 19. JavaScript: Code Structure Note: Using semicolons makes it possible to write multiple statements on one line. Ex: var name = "Jeeva" var mark = 89 (or) var name = "Jeeva"; var mark = 89 JavaScript is Case Sensitive Unlike HTML, JavaScript is case sensitive - therefore watch your capitalization closely when you write JavaScript statements, create or call variables, objects and functions. Ex: num, Num are different variables.
  • 20. JavaScript: Code Structure JavaScript Code: JavaScript code (or just JavaScript) is a sequence of JavaScript statements. Each statement is executed by the browser in the sequence they are written. This example will write a heading and two paragraphs to a web page: Example: <script type="text/javascript"> document.write("<h1>This is a heading</h1>"); document.write("<p>This is a paragraph.</p>"); document.write("<p>This is another paragraph.</p>"); </script>
  • 21. JavaScript: Code Structure JavaScript Blocks • JavaScript statements can be grouped together in blocks. • Blocks start with a left curly bracket { , • and ends with a right curly bracket } . • The purpose of a block is to make the sequence of statements execute together. Example <script type="text/javascript"> { document.write("<h1>This is a heading</h1>"); document.write("<p>This is a paragraph.</p>"); document.write("<p>This is another paragraph.</p>"); } </script>
  • 22. JavaScript: Comments Single line comments: Comments can be added to explain the JavaScript, or to make the code more readable. Single line comments start with //. JavaScript Multi-Line Comments Multi line comments start with /* and end with */. The following example uses a multi line comment to explain the code: Using Comments at the End of a Line In the following example the comment is placed at the end of a code line. document.write("Hello"); // Write "Hello“
  • 23. JavaScript: Variables Variables as symbolic names for values in your application. You give variables names by which used to hold values or expressions. We refer to them and which must conform to certain rules. A variable can have a short name, like x, or a more descriptive name, like carname. • A JavaScript identifier, or name, must start with a letter or underscore ("_"), • Subsequent characters can also be digits (0-9). • Because JavaScript is case sensitive, letters include the characters "A" through "Z" (uppercase) and the characters "a" through "z" (lowercase). • Identifier name must not contain any white-space. • legal names: Number_hits, temp99, and _name • illegal names: 9temp, Number hits,
  • 24. JavaScript: Variables Declaring (Creating) JavaScript Variables Creating variables in JavaScript is most often referred to as "declaring" variables. We can declare a variable in two ways: • By simply assigning its a value. For example, x = 42 • With the keyword var. For example, var x = 42 var x; var carname; After the declaration shown above, the variables are empty (they have no values yet). However, you can also assign values to the variables when you declare them: var x=5; var carname="Volvo";
  • 25. JavaScript: Variables Assigning Values to Undeclared JavaScript Variables: If you assign values to variables that have not yet been declared, the variables will automatically be declared. These statements: x=5; carname="Volvo"; Redeclaring JavaScript Variables: If you redeclare a JavaScript variable, it will not lose its original value. var x=5; var x; After the execution of the statements above, the variable x will still have the value of 5. The value of x is not reset (or cleared) when you redeclare it.
  • 26. JavaScript: Variables Scope When we set a variable identifier by assignment outside of a function, it is called a global variable, because it is available everywhere in the current document. When we declare a variable within a function, it is called a local variable, because it is available only within the function. let keyword used for variable declaration in JavaScript like var but the difference between them is that var is function scoped(global) and let is block scoped. Example: var a = 10; var a = 20; //a is replaced let a = 10; let a = 20; //SyntaxError: //Identifier 'a' has already been declared
  • 28. JavaScript: Operators JavaScript operators are symbols that are used to perform operations on operands, types of operators in JavaScript • Arithmetic Operators • Comparison (Relational) Operators • Assignment Operators • Bitwise Operators • Logical Operators • Special Operators
  • 29. JavaScript: Arithmetic Operators Operator Description Example + Addition 10+20 = 30 - Subtraction 20-10 = 10 * Multiplication 10*20 = 200 / Division 20/10 = 2 % Modulus (Remainder) 20%10 = 0 ++ Increment var a=10; a++; Now a = 11 -- Decrement var a=10; a--; Now a = 9
  • 30. JavaScript: Comparison Operators Operator Description Example == Is equal to 10==20 => false === Identical (equal and of same type) 10===20 => false 10 === "10" => false != Not equal to 10!=20 => true !== Not Identical 20!==20 => false > Greater than 20>10 => true >= Greater than or equal to 20>=10 => true < Less than 20<10 => false <= Less than or equal to 20<=10 => false
  • 31. JavaScript: Assignment Operators Operator Description Example = Assign 10+10 = 20 += Add and assign var a=10; a+=20; Now a = 30 -= Subtract and assign var a=20; a-=10; Now a = 10 *= Multiply and assign var a=10; a*=20; Now a = 200 /= Divide and assign var a=10; a/=2; Now a = 5 %= Modulus and assign var a=10; a%=2; Now a = 0
  • 32. JavaScript: Logical Operators Operator Description Example && Logical AND (10==20 && 20==33) => false || Logical OR (10==20 || 20==33) => false ! Logical Not !(10==20) => true Logical operators are used to determine the logic between variables or values. An expression containing logical operator returns either 0 or 1 depending upon whether expression results true or false.
  • 33. JavaScript: Bitwise Operators The bitwise operators perform bitwise operations on operands. Operator Description Example & Bitwise AND (10==20 & 20==33) = false | Bitwise OR (10==20 | 20==33) = false ^ Bitwise XOR (10==20 ^ 20==33) = false ~ Bitwise NOT (~10) = -10 << Bitwise Left Shift (10<<2) = 40 >> Bitwise Right Shift (10>>2) = 2 >>> Bitwise Right Shift with Zero (10>>>2) = 2
  • 34. JavaScript: Bitwise Operators The bitwise operators perform bitwise operations on operands. Example: 12 = 00001100 (In Binary) 25 = 00011001 (In Binary) Bit Operation of 12 and 25 00001100 ------>12 & 00011001 ------>25 00001000 ==> 8 (In decimal)