SlideShare a Scribd company logo
11/30/2011
1
JavaScript
JavaScript is the scripting language of the
Web.
JavaScript is used in millions of Web pages
to add functionality, validate forms, detect
browsers, and much more.
11/30/2011 1Hassan Khan
What is JavaScript?
JavaScript was designed to add interactivity to HTML
pages
JavaScript is a scripting language
A scripting language is a lightweight programming
language
JavaScript is usually embedded directly into HTML
pages
JavaScript is an interpreted language (means that
scripts execute without preliminary compilation)
Everyone can use JavaScript without purchasing a
license
11/30/2011 2Hassan Khan
11/30/2011
2
Example
<html>
<body>
<script type="text/javascript">
document.write("This is my first JavaScript!");
</script>
</body>
</html>
11/30/2011 3Hassan Khan
How to Handle Simple
Browsers
Browsers that do not support JavaScript, will display
JavaScript as page content.
The HTML comment tag should be used to "hide" the
JavaScript.
Just add an HTML comment tag <!-- before the first
JavaScript statement, and a --> (end of comment) after
the last JavaScript statement.
11/30/2011 4Hassan Khan
11/30/2011
3
Example
The two forward slashes at the end of comment line (//) is
the JavaScript comment symbol. This prevents
JavaScript from executing the --> tag.
11/30/2011 5Hassan Khan
What can a JavaScript do?
JavaScript gives HTML designers a programming
tool
JavaScript can put dynamic text into an HTML page
JavaScript can react to events
JavaScript can read and write HTML elements
JavaScript can be used to validate data
JavaScript can be used to detect the visitor's
browser
JavaScript can be used to create cookies
11/30/2011 6Hassan Khan
11/30/2011
4
How To Use?
<script> tag is used to insert a JavaScript into
an HTML page.
Between <body> tag
Between <head> tag
11/30/2011 7Hassan Khan
How To Use (Cont.)?
JavaScripts in the body section will be
executed WHILE the page loads.
JavaScripts in the head section will be
executed when CALLED.
11/30/2011 8Hassan Khan
11/30/2011
5
JavaScript Statements
JavaScript is case sensitive.
Use of semicolon(;) in the end of statement is
optional.
document.write("Hello");
document.write("Hello")
11/30/2011 9Hassan Khan
JavaScript Comments
Single line comments start with //.
Multi line comments start with /* and end with
*/.
11/30/2011 10Hassan Khan
11/30/2011
6
JavaScript Variables
JavaScript variables are used to hold values
or expressions.
x=5, y=6, z=x+y
Rules for JavaScript variable names:
Variable names are case sensitive (y and Y
are two different variables)
Variable names must begin with a letter or
the underscore character
11/30/2011 11Hassan Khan
JavaScript Variables
Declaration
var x;
var carname;
Assign Values
x=5;
carname=“Toyota";
11/30/2011 12Hassan Khan
11/30/2011
7
JavaScript Arithmetic Operators
Y=5
11/30/2011 13Hassan Khan
JavaScript Assignment Operators
x = 5 and y=10
11/30/2011 14Hassan Khan
11/30/2011
8
+ Operator and Strings
To add two or more string variables together,
use the + operator.
11/30/2011 15Hassan Khan
Comparison Operators
11/30/2011 16Hassan Khan
11/30/2011
9
Logical Operators
11/30/2011 17Hassan Khan
If...Else Statements
used to perform different actions based on different
conditions.
if statement - use this statement to execute some
code only if a specified condition is true
if...else statement - use this statement to execute
some code if the condition is true and another code
if the condition is false
if...else if....else statement - use this statement to
select one of many blocks of code to be executed
switch statement - use this statement to select one
of many blocks of code to be executed
11/30/2011 18Hassan Khan
11/30/2011
10
Example (If)
11/30/2011 19Hassan Khan
Example (If...else)
11/30/2011 20Hassan Khan
11/30/2011
11
Example(If...else if...else)
11/30/2011 21Hassan Khan
Switch Statement
used to perform different actions based on
different conditions.
11/30/2011 22Hassan Khan
11/30/2011
12
Example (Switch)
11/30/2011 23Hassan Khan
Popup Boxes
Alert Box
alert(“Hello Every Body");
Confirm Box
confirm(“Press a button");
Prompt Box
prompt("Your name","")
11/30/2011 24
Hassan Khan
11/30/2011
13
Functions
A function will be executed by an event or by
a call to the function.
11/30/2011 25Hassan Khan
Example (Function)
11/30/2011 26Hassan Khan
11/30/2011
14
JavaScript Loops
You want the same block of code to run over and
over again in a row. Instead of adding several
almost equal lines in a script we can use loops to
perform a task like this.
In JavaScript, there are two different kind of loops:
for - loops through a block of code a specified
number of times
while - loops through a block of code while a
specified condition is true
11/30/2011 27Hassan Khan
The for Loop
11/30/2011 28Hassan Khan
11/30/2011
15
While Loop
11/30/2011 29Hassan Khan
The break Statement
The break statement will break the loop and
continue executing the code that follows after
the loop (if any).
11/30/2011 30Hassan Khan
11/30/2011
16
The continue Statement
The continue statement will break the current
loop and continue with the next value.
11/30/2011 31Hassan Khan
JavaScript Events
Events are actions that can be detected by
JavaScript.
Examples of events:
A mouse click
A web page or an image loading
Mousing over a hot spot on the web page
Selecting an input field in an HTML form
Submitting an HTML form
A keystroke
11/30/2011 32Hassan Khan
11/30/2011
17
Events
onLoad and onUnload
onFocus, onBlur and onChange
onSubmit
onMouseOver and onMouseOut
11/30/2011 33Hassan Khan
JavaScript Objects
JavaScript is an Object Oriented
Programming (OOP) language.
An OOP language allows you to define your
own objects and make your own variable
types.
We will start by looking at the built-in
JavaScript objects.
11/30/2011 34Hassan Khan
11/30/2011
18
JavaScript Objects and Properties
Properties are the values associated with an
object.
11/30/2011 35Hassan Khan
JavaScript String Object
The String object is used to manipulate a
stored piece of text.
Some String Methods
search()
toLowerCase()
toUpperCase()
11/30/2011 36Hassan Khan
11/30/2011
19
JavaScript Date Object
The Date object is used to work with dates
and times.
11/30/2011 37Hassan Khan
Data Comparison
?
11/30/2011 38Hassan Khan
11/30/2011
20
JavaScript Array Object
The Array object is used to store multiple
values in a single variable.
An array can be defined in three ways.
11/30/2011 39Hassan Khan
JavaScript Math Object
The Math object allows you to perform
mathematical tasks.
Math.PI
Math.E
Math.sqrt(number)
Math.round(4.7)
11/30/2011 40Hassan Khan
11/30/2011
21
JavaScript Navigator Object
The Navigator object allows you to
check/validate your Browser.
Navigator.appName,;
Navigator.appVersion
11/30/2011 41Hassan Khan

More Related Content

What's hot

Android app development ppt
Android app development pptAndroid app development ppt
Android app development ppt
saitej15
 
Bots & Customer Service
Bots & Customer ServiceBots & Customer Service
Bots & Customer Service
Tech Talks Central
 
Payment Card System Overview
Payment Card System OverviewPayment Card System Overview
Payment Card System Overview
Narudom Roongsiriwong, CISSP
 
ppt about chatgpt.pptx
ppt about chatgpt.pptxppt about chatgpt.pptx
ppt about chatgpt.pptx
Srinivas237938
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFA
Maulik Togadiya
 
Skip gram and cbow
Skip gram and cbowSkip gram and cbow
Skip gram and cbow
hyunyoung Lee
 
Full Stack Web Development
Full Stack Web DevelopmentFull Stack Web Development
Full Stack Web Development
SWAGATHCHOWDARY1
 
Basic Structure of C Language and Related Term
Basic Structure of C Language  and Related TermBasic Structure of C Language  and Related Term
Basic Structure of C Language and Related Term
MuhammadWaseem305
 
Php Presentation
Php PresentationPhp Presentation
Php Presentation
Manish Bothra
 
Context free grammar
Context free grammarContext free grammar
Context free grammar
Ratnakar Mikkili
 
Language translator
Language translatorLanguage translator
Language translator
SumitSumit26
 
Visual question answering vqa
Visual question answering vqaVisual question answering vqa
Visual question answering vqa
hyunyoung Lee
 
Chatbots - The Business Opportunity
Chatbots - The Business OpportunityChatbots - The Business Opportunity
Chatbots - The Business Opportunity
Alexandros Ivos
 
Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)
Ahsanul Karim
 
Web Development
Web DevelopmentWeb Development
Web Development
Aditya Raman
 
Variables and Data Types
Variables and Data TypesVariables and Data Types
Variables and Data Types
Infoviaan Technologies
 
C programming basics
C  programming basicsC  programming basics
C programming basics
argusacademy
 
Whatsapp project work
Whatsapp project workWhatsapp project work
Whatsapp project work
Virginia Sgargi
 
Web Development with HTML5, CSS3 & JavaScript
Web Development with HTML5, CSS3 & JavaScriptWeb Development with HTML5, CSS3 & JavaScript
Web Development with HTML5, CSS3 & JavaScript
Edureka!
 
C functions
C functionsC functions

What's hot (20)

Android app development ppt
Android app development pptAndroid app development ppt
Android app development ppt
 
Bots & Customer Service
Bots & Customer ServiceBots & Customer Service
Bots & Customer Service
 
Payment Card System Overview
Payment Card System OverviewPayment Card System Overview
Payment Card System Overview
 
ppt about chatgpt.pptx
ppt about chatgpt.pptxppt about chatgpt.pptx
ppt about chatgpt.pptx
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFA
 
Skip gram and cbow
Skip gram and cbowSkip gram and cbow
Skip gram and cbow
 
Full Stack Web Development
Full Stack Web DevelopmentFull Stack Web Development
Full Stack Web Development
 
Basic Structure of C Language and Related Term
Basic Structure of C Language  and Related TermBasic Structure of C Language  and Related Term
Basic Structure of C Language and Related Term
 
Php Presentation
Php PresentationPhp Presentation
Php Presentation
 
Context free grammar
Context free grammarContext free grammar
Context free grammar
 
Language translator
Language translatorLanguage translator
Language translator
 
Visual question answering vqa
Visual question answering vqaVisual question answering vqa
Visual question answering vqa
 
Chatbots - The Business Opportunity
Chatbots - The Business OpportunityChatbots - The Business Opportunity
Chatbots - The Business Opportunity
 
Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)
 
Web Development
Web DevelopmentWeb Development
Web Development
 
Variables and Data Types
Variables and Data TypesVariables and Data Types
Variables and Data Types
 
C programming basics
C  programming basicsC  programming basics
C programming basics
 
Whatsapp project work
Whatsapp project workWhatsapp project work
Whatsapp project work
 
Web Development with HTML5, CSS3 & JavaScript
Web Development with HTML5, CSS3 & JavaScriptWeb Development with HTML5, CSS3 & JavaScript
Web Development with HTML5, CSS3 & JavaScript
 
C functions
C functionsC functions
C functions
 

Viewers also liked

Ar3 c ati weco2 park actual work up to july 18 2014
Ar3 c ati weco2 park actual work up to july 18 2014Ar3 c ati weco2 park actual work up to july 18 2014
Ar3 c ati weco2 park actual work up to july 18 2014
kjstrong
 
Ar3 c r&d plus demo weco2 park greenhouse
Ar3 c r&d plus demo weco2 park greenhouseAr3 c r&d plus demo weco2 park greenhouse
Ar3 c r&d plus demo weco2 park greenhouse
kjstrong
 
CARACTERÍSTICAS INFORMÁTICA OO
CARACTERÍSTICAS INFORMÁTICA OOCARACTERÍSTICAS INFORMÁTICA OO
CARACTERÍSTICAS INFORMÁTICA OO
Patricio Xtr
 
Ar3 c ati weco2 park outdoor storage pad july 18 2014
Ar3 c ati weco2 park outdoor storage pad july 18 2014Ar3 c ati weco2 park outdoor storage pad july 18 2014
Ar3 c ati weco2 park outdoor storage pad july 18 2014
kjstrong
 
Important marketing notes
Important marketing notesImportant marketing notes
Important marketing notes
ANNIEJAN
 

Viewers also liked (6)

Ar3 c ati weco2 park actual work up to july 18 2014
Ar3 c ati weco2 park actual work up to july 18 2014Ar3 c ati weco2 park actual work up to july 18 2014
Ar3 c ati weco2 park actual work up to july 18 2014
 
Filming powerpoint
Filming powerpointFilming powerpoint
Filming powerpoint
 
Ar3 c r&d plus demo weco2 park greenhouse
Ar3 c r&d plus demo weco2 park greenhouseAr3 c r&d plus demo weco2 park greenhouse
Ar3 c r&d plus demo weco2 park greenhouse
 
CARACTERÍSTICAS INFORMÁTICA OO
CARACTERÍSTICAS INFORMÁTICA OOCARACTERÍSTICAS INFORMÁTICA OO
CARACTERÍSTICAS INFORMÁTICA OO
 
Ar3 c ati weco2 park outdoor storage pad july 18 2014
Ar3 c ati weco2 park outdoor storage pad july 18 2014Ar3 c ati weco2 park outdoor storage pad july 18 2014
Ar3 c ati weco2 park outdoor storage pad july 18 2014
 
Important marketing notes
Important marketing notesImportant marketing notes
Important marketing notes
 

Similar to Java Script notes

Java script
Java scriptJava script
Java script
Rajkiran Mummadi
 
Basics of Javascript
Basics of Javascript Basics of Javascript
Basics of Javascript
poojanov04
 
Web designing unit 4
Web designing unit 4Web designing unit 4
Web designing unit 4
SURBHI SAROHA
 
Cordova training : Day 3 - Introduction to Javascript
Cordova training : Day 3 - Introduction to JavascriptCordova training : Day 3 - Introduction to Javascript
Cordova training : Day 3 - Introduction to Javascript
Binu Paul
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
ambuj pathak
 
Javascript
JavascriptJavascript
Javascript
Nital Shingala
 
Javascript tutorial basic for starter
Javascript tutorial basic for starterJavascript tutorial basic for starter
Javascript tutorial basic for starter
Marcello Harford
 
Unit 2.5
Unit 2.5Unit 2.5
Java script Basic
Java script BasicJava script Basic
Java script Basic
Jaya Kumari
 
Unit 2.5
Unit 2.5Unit 2.5
Javascript tutorial
Javascript tutorialJavascript tutorial
Javascript tutorial
Avinash Malhotra
 
Unit 2.4
Unit 2.4Unit 2.4
Introduction to java script
Introduction to java scriptIntroduction to java script
Introduction to java script
DivyaKS12
 
JAVA SCRIPT
JAVA SCRIPTJAVA SCRIPT
JAVA SCRIPT
Mohammed Hussein
 
JavaScript Lecture notes.pptx
JavaScript Lecture notes.pptxJavaScript Lecture notes.pptx
JavaScript Lecture notes.pptx
NishaRohit6
 
Web programming
Web programmingWeb programming
Web programming
Leo Mark Villar
 
Javascript
JavascriptJavascript
Javascript
Nagarajan
 
Unit 2.4
Unit 2.4Unit 2.4
Java script
Java scriptJava script
Java script
GowriLatha1
 
Cutting the Fat
Cutting the FatCutting the Fat
Cutting the Fat
Codemotion
 

Similar to Java Script notes (20)

Java script
Java scriptJava script
Java script
 
Basics of Javascript
Basics of Javascript Basics of Javascript
Basics of Javascript
 
Web designing unit 4
Web designing unit 4Web designing unit 4
Web designing unit 4
 
Cordova training : Day 3 - Introduction to Javascript
Cordova training : Day 3 - Introduction to JavascriptCordova training : Day 3 - Introduction to Javascript
Cordova training : Day 3 - Introduction to Javascript
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
Javascript
JavascriptJavascript
Javascript
 
Javascript tutorial basic for starter
Javascript tutorial basic for starterJavascript tutorial basic for starter
Javascript tutorial basic for starter
 
Unit 2.5
Unit 2.5Unit 2.5
Unit 2.5
 
Java script Basic
Java script BasicJava script Basic
Java script Basic
 
Unit 2.5
Unit 2.5Unit 2.5
Unit 2.5
 
Javascript tutorial
Javascript tutorialJavascript tutorial
Javascript tutorial
 
Unit 2.4
Unit 2.4Unit 2.4
Unit 2.4
 
Introduction to java script
Introduction to java scriptIntroduction to java script
Introduction to java script
 
JAVA SCRIPT
JAVA SCRIPTJAVA SCRIPT
JAVA SCRIPT
 
JavaScript Lecture notes.pptx
JavaScript Lecture notes.pptxJavaScript Lecture notes.pptx
JavaScript Lecture notes.pptx
 
Web programming
Web programmingWeb programming
Web programming
 
Javascript
JavascriptJavascript
Javascript
 
Unit 2.4
Unit 2.4Unit 2.4
Unit 2.4
 
Java script
Java scriptJava script
Java script
 
Cutting the Fat
Cutting the FatCutting the Fat
Cutting the Fat
 

Recently uploaded

BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
Nguyen Thanh Tu Collection
 
220711130082 Srabanti Bag Internet Resources For Natural Science
220711130082 Srabanti Bag Internet Resources For Natural Science220711130082 Srabanti Bag Internet Resources For Natural Science
220711130082 Srabanti Bag Internet Resources For Natural Science
Kalna College
 
220711130097 Tulip Samanta Concept of Information and Communication Technology
220711130097 Tulip Samanta Concept of Information and Communication Technology220711130097 Tulip Samanta Concept of Information and Communication Technology
220711130097 Tulip Samanta Concept of Information and Communication Technology
Kalna College
 
Ch-4 Forest Society and colonialism 2.pdf
Ch-4 Forest Society and colonialism 2.pdfCh-4 Forest Society and colonialism 2.pdf
Ch-4 Forest Society and colonialism 2.pdf
lakshayrojroj
 
How to Setup Default Value for a Field in Odoo 17
How to Setup Default Value for a Field in Odoo 17How to Setup Default Value for a Field in Odoo 17
How to Setup Default Value for a Field in Odoo 17
Celine George
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
zuzanka
 
FinalSD_MathematicsGrade7_Session2_Unida.pptx
FinalSD_MathematicsGrade7_Session2_Unida.pptxFinalSD_MathematicsGrade7_Session2_Unida.pptx
FinalSD_MathematicsGrade7_Session2_Unida.pptx
JennySularte1
 
Skimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S EliotSkimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S Eliot
nitinpv4ai
 
skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)
Mohammad Al-Dhahabi
 
A Free 200-Page eBook ~ Brain and Mind Exercise.pptx
A Free 200-Page eBook ~ Brain and Mind Exercise.pptxA Free 200-Page eBook ~ Brain and Mind Exercise.pptx
A Free 200-Page eBook ~ Brain and Mind Exercise.pptx
OH TEIK BIN
 
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGHKHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
shreyassri1208
 
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
Payaamvohra1
 
Observational Learning
Observational Learning Observational Learning
Observational Learning
sanamushtaq922
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
Iris Thiele Isip-Tan
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
nitinpv4ai
 
Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)
nitinpv4ai
 
Diversity Quiz Prelims by Quiz Club, IIT Kanpur
Diversity Quiz Prelims by Quiz Club, IIT KanpurDiversity Quiz Prelims by Quiz Club, IIT Kanpur
Diversity Quiz Prelims by Quiz Club, IIT Kanpur
Quiz Club IIT Kanpur
 
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
ShwetaGawande8
 
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptxCapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapitolTechU
 
Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10
nitinpv4ai
 

Recently uploaded (20)

BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
 
220711130082 Srabanti Bag Internet Resources For Natural Science
220711130082 Srabanti Bag Internet Resources For Natural Science220711130082 Srabanti Bag Internet Resources For Natural Science
220711130082 Srabanti Bag Internet Resources For Natural Science
 
220711130097 Tulip Samanta Concept of Information and Communication Technology
220711130097 Tulip Samanta Concept of Information and Communication Technology220711130097 Tulip Samanta Concept of Information and Communication Technology
220711130097 Tulip Samanta Concept of Information and Communication Technology
 
Ch-4 Forest Society and colonialism 2.pdf
Ch-4 Forest Society and colonialism 2.pdfCh-4 Forest Society and colonialism 2.pdf
Ch-4 Forest Society and colonialism 2.pdf
 
How to Setup Default Value for a Field in Odoo 17
How to Setup Default Value for a Field in Odoo 17How to Setup Default Value for a Field in Odoo 17
How to Setup Default Value for a Field in Odoo 17
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
 
FinalSD_MathematicsGrade7_Session2_Unida.pptx
FinalSD_MathematicsGrade7_Session2_Unida.pptxFinalSD_MathematicsGrade7_Session2_Unida.pptx
FinalSD_MathematicsGrade7_Session2_Unida.pptx
 
Skimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S EliotSkimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S Eliot
 
skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)
 
A Free 200-Page eBook ~ Brain and Mind Exercise.pptx
A Free 200-Page eBook ~ Brain and Mind Exercise.pptxA Free 200-Page eBook ~ Brain and Mind Exercise.pptx
A Free 200-Page eBook ~ Brain and Mind Exercise.pptx
 
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGHKHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
 
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
 
Observational Learning
Observational Learning Observational Learning
Observational Learning
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
 
Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)
 
Diversity Quiz Prelims by Quiz Club, IIT Kanpur
Diversity Quiz Prelims by Quiz Club, IIT KanpurDiversity Quiz Prelims by Quiz Club, IIT Kanpur
Diversity Quiz Prelims by Quiz Club, IIT Kanpur
 
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
 
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptxCapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
 
Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10
 

Java Script notes

  • 1. 11/30/2011 1 JavaScript JavaScript is the scripting language of the Web. JavaScript is used in millions of Web pages to add functionality, validate forms, detect browsers, and much more. 11/30/2011 1Hassan Khan What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting language is a lightweight programming language JavaScript is usually embedded directly into HTML pages JavaScript is an interpreted language (means that scripts execute without preliminary compilation) Everyone can use JavaScript without purchasing a license 11/30/2011 2Hassan Khan
  • 2. 11/30/2011 2 Example <html> <body> <script type="text/javascript"> document.write("This is my first JavaScript!"); </script> </body> </html> 11/30/2011 3Hassan Khan How to Handle Simple Browsers Browsers that do not support JavaScript, will display JavaScript as page content. The HTML comment tag should be used to "hide" the JavaScript. Just add an HTML comment tag <!-- before the first JavaScript statement, and a --> (end of comment) after the last JavaScript statement. 11/30/2011 4Hassan Khan
  • 3. 11/30/2011 3 Example The two forward slashes at the end of comment line (//) is the JavaScript comment symbol. This prevents JavaScript from executing the --> tag. 11/30/2011 5Hassan Khan What can a JavaScript do? JavaScript gives HTML designers a programming tool JavaScript can put dynamic text into an HTML page JavaScript can react to events JavaScript can read and write HTML elements JavaScript can be used to validate data JavaScript can be used to detect the visitor's browser JavaScript can be used to create cookies 11/30/2011 6Hassan Khan
  • 4. 11/30/2011 4 How To Use? <script> tag is used to insert a JavaScript into an HTML page. Between <body> tag Between <head> tag 11/30/2011 7Hassan Khan How To Use (Cont.)? JavaScripts in the body section will be executed WHILE the page loads. JavaScripts in the head section will be executed when CALLED. 11/30/2011 8Hassan Khan
  • 5. 11/30/2011 5 JavaScript Statements JavaScript is case sensitive. Use of semicolon(;) in the end of statement is optional. document.write("Hello"); document.write("Hello") 11/30/2011 9Hassan Khan JavaScript Comments Single line comments start with //. Multi line comments start with /* and end with */. 11/30/2011 10Hassan Khan
  • 6. 11/30/2011 6 JavaScript Variables JavaScript variables are used to hold values or expressions. x=5, y=6, z=x+y Rules for JavaScript variable names: Variable names are case sensitive (y and Y are two different variables) Variable names must begin with a letter or the underscore character 11/30/2011 11Hassan Khan JavaScript Variables Declaration var x; var carname; Assign Values x=5; carname=“Toyota"; 11/30/2011 12Hassan Khan
  • 7. 11/30/2011 7 JavaScript Arithmetic Operators Y=5 11/30/2011 13Hassan Khan JavaScript Assignment Operators x = 5 and y=10 11/30/2011 14Hassan Khan
  • 8. 11/30/2011 8 + Operator and Strings To add two or more string variables together, use the + operator. 11/30/2011 15Hassan Khan Comparison Operators 11/30/2011 16Hassan Khan
  • 9. 11/30/2011 9 Logical Operators 11/30/2011 17Hassan Khan If...Else Statements used to perform different actions based on different conditions. if statement - use this statement to execute some code only if a specified condition is true if...else statement - use this statement to execute some code if the condition is true and another code if the condition is false if...else if....else statement - use this statement to select one of many blocks of code to be executed switch statement - use this statement to select one of many blocks of code to be executed 11/30/2011 18Hassan Khan
  • 10. 11/30/2011 10 Example (If) 11/30/2011 19Hassan Khan Example (If...else) 11/30/2011 20Hassan Khan
  • 11. 11/30/2011 11 Example(If...else if...else) 11/30/2011 21Hassan Khan Switch Statement used to perform different actions based on different conditions. 11/30/2011 22Hassan Khan
  • 12. 11/30/2011 12 Example (Switch) 11/30/2011 23Hassan Khan Popup Boxes Alert Box alert(“Hello Every Body"); Confirm Box confirm(“Press a button"); Prompt Box prompt("Your name","") 11/30/2011 24 Hassan Khan
  • 13. 11/30/2011 13 Functions A function will be executed by an event or by a call to the function. 11/30/2011 25Hassan Khan Example (Function) 11/30/2011 26Hassan Khan
  • 14. 11/30/2011 14 JavaScript Loops You want the same block of code to run over and over again in a row. Instead of adding several almost equal lines in a script we can use loops to perform a task like this. In JavaScript, there are two different kind of loops: for - loops through a block of code a specified number of times while - loops through a block of code while a specified condition is true 11/30/2011 27Hassan Khan The for Loop 11/30/2011 28Hassan Khan
  • 15. 11/30/2011 15 While Loop 11/30/2011 29Hassan Khan The break Statement The break statement will break the loop and continue executing the code that follows after the loop (if any). 11/30/2011 30Hassan Khan
  • 16. 11/30/2011 16 The continue Statement The continue statement will break the current loop and continue with the next value. 11/30/2011 31Hassan Khan JavaScript Events Events are actions that can be detected by JavaScript. Examples of events: A mouse click A web page or an image loading Mousing over a hot spot on the web page Selecting an input field in an HTML form Submitting an HTML form A keystroke 11/30/2011 32Hassan Khan
  • 17. 11/30/2011 17 Events onLoad and onUnload onFocus, onBlur and onChange onSubmit onMouseOver and onMouseOut 11/30/2011 33Hassan Khan JavaScript Objects JavaScript is an Object Oriented Programming (OOP) language. An OOP language allows you to define your own objects and make your own variable types. We will start by looking at the built-in JavaScript objects. 11/30/2011 34Hassan Khan
  • 18. 11/30/2011 18 JavaScript Objects and Properties Properties are the values associated with an object. 11/30/2011 35Hassan Khan JavaScript String Object The String object is used to manipulate a stored piece of text. Some String Methods search() toLowerCase() toUpperCase() 11/30/2011 36Hassan Khan
  • 19. 11/30/2011 19 JavaScript Date Object The Date object is used to work with dates and times. 11/30/2011 37Hassan Khan Data Comparison ? 11/30/2011 38Hassan Khan
  • 20. 11/30/2011 20 JavaScript Array Object The Array object is used to store multiple values in a single variable. An array can be defined in three ways. 11/30/2011 39Hassan Khan JavaScript Math Object The Math object allows you to perform mathematical tasks. Math.PI Math.E Math.sqrt(number) Math.round(4.7) 11/30/2011 40Hassan Khan
  • 21. 11/30/2011 21 JavaScript Navigator Object The Navigator object allows you to check/validate your Browser. Navigator.appName,; Navigator.appVersion 11/30/2011 41Hassan Khan