SlideShare a Scribd company logo
CORDOVA TRAINING
SESSION: 3 – INTRODUCTION TO JAVASCRIPT
INTRODUCTION TO JAVASCRIPT
 Javascript is a dynamic computer programming language. It is lightweight and most
commonly used as a part of web pages.
 JavaScript is a lightweight, interpreted programming language.
 Designed for creating network-centric applications.
 Complementary to and integrated with Java.
 Complementary to and integrated with HTML.
 Open and cross-platform
ADVANTAGES OF JAVASCRIPT
 The merits of using JavaScript are:
 Less server interaction
 Immediate feedback to the visitors
 Increased interactivity
 Richer interfaces
DIS-ADVANTAGES OF JAVASCRIPT
 The demerits of using JavaScript are:
 Client-side JavaScript does not allow the reading or writing of files. This has been
kept for security reason.
 JavaScript cannot be used for networking applications because there is no such
support available.
 JavaScript doesn't have any multithreading or multiprocessor capabilities.
SYNTAX
 JavaScript can be implemented using JavaScript statements that are placed within the
<script>... </script> HTML tags in a web page.
 You can place the <script> tags, containing your JavaScript, anywhere within you web
page, but it is normally recommended that you should keep it within the <head> tags.
<script language="javascript" type="text/javascript">
JavaScript code
</script>
SYNTAX
 JavaScript ignores spaces, tabs, and newlines that appear in JavaScript programs.
 Simple statements in JavaScript are generally followed by a semicolon character, just as
they are in C, C++, and Java.
 JavaScript is a case-sensitive language. This means that the language keywords,
variables, function names, and any other identifiers must always be typed with a
consistent capitalization of letters.
COMMENTS
 JavaScript supports both C-style and C++-style comments:
 Any text between a // and the end of a line is treated as a comment and is ignored
by JavaScript.
 Any text between the characters /* and */ is treated as a comment. This may span
multiple lines.
INCLUDING JAVASCRIPT IN A PAGE
 There is a flexibility given to include JavaScript code anywhere in an HTML document.
However the most preferred ways to include JavaScript in an HTML file are as follows:
 Script in <head>...</head> section
 Script in <body>...</body> section
 Script in an external file and then include in <head>...</head> section
<script type="text/javascript" src="filename.js" ></script>
JAVASCRIPT VARIABLES
 One of the most fundamental characteristics of a programming language is the set of
data types it supports.
 JavaScript allows you to work with three primitive data types:
 String
 Number
 Boolean : true | false
JAVASCRIPT VARIABLES
 Like many other programming languages, JavaScript has variables. Variables can be
thought of as named containers. You can place data into these containers and then
refer to the data simply by naming the container.
 Before you use a variable in a JavaScript program, you must declare it. Variables are
declared with the var keyword
var name;
JAVASCRIPT RESERVED KEYWORDS
 A list of all the reserved words in JavaScript are given in the following table. They
cannot be used as JavaScript variables, functions, methods, loop labels, or any object
names.
JAVASCRIPT RESERVED KEYWORDS
abstract
boolean
break
byte
case
Catch
char
class
const
continue
debugger
default
delete
do
double
else
enum
export
extends
false
final
finally
float
for
function
goto
if
Implements
import
in
instanceof
int
interface
long
native
new
null
package
private
protected
public
return
short
static
super
switch
synchronized
this
throw
throws
transient
true
try
typeof
var
void
volatile
while
With
OPERATORS
 Let us take a simple expression 4 + 5 is equal to 9. Here 4 and 5 are called operands
and ‘+’ is called the operator.
 JavaScript supports the following types of operators:
 Arithmetic
 Comparision
 Logical
 Assignment
 Conditional
ARITHMETIC OPERATORS
 JavaScript supports the following arithmetic operators:
 + (Addition)
 - (Subtraction)
 * (Multiplication)
 / (Division)
 % (Modulus)
 ++ (Increment)
 -- (Decrement)
COMPARISION OPERATORS
 JavaScript supports the following comparison operators:
 = = (Equal)
 != (Not Equal)
 > (Greater than)
 >= (Greater than or Equal to)
 < (Less than)
 <= (Less than or Equal to)
LOGICAL OPERATORS
 JavaScript supports the following logical operators:
 && (Logical AND)
 || (Logical OR)
 ! (Logical NOT)
ASSIGNMENT OPERATORS
 JavaScript supports the following assignment operators:
 = (Simple Assignment )
 += (Add and Assignment)
 −= (Subtract and Assignment)
 *= (Multiply and Assignment)
 /= (Divide and Assignment)
 %= (Modules and Assignment)
CONDITIONAL OPERATORS
 The conditional operator first evaluates an expression for a true or false value and then
executes one of the two given statements depending upon the result of the evaluation.
 ? : (Conditional )
If Condition is true? Then value X : Otherwise value Y
IF-ELSE STATEMENT
 While writing a program, there may be a situation when you need to adopt one out of
a given set of paths. In such cases, you need to use conditional statements that allow
your program to make correct decisions and perform right actions.
if (expression) {
Statement(s) to be executed if expression is true
} else{
Statement(s) to be executed if expression is false
}
IF-ELSE STATEMENT
SWITCH CASE STATEMENT
 We can use a switch statement to handle a situation where repeated if...else if
statements are required.
switch (expression) {
case condition 1: statement(s)
break;
case condition 2: statement(s)
break;
default: statement(s)
}
SWITCH CASE STATEMENT
LOOPS
 You may encounter a situation where you need to perform an action over and over
again. In such situations, you would need to write loop statements. Javascript supports
the following types of loops:
 for loop
 while loop
FOR LOOP
 The 'for' loop is the most compact form of looping. It includes the following three
important parts.
 loop initialization
 test statement
 iteration statement
for (initialization; test condition; iteration statement) {
Statement(s) to be executed if test condition is true
}
FOR LOOP
WHILE LOOP
 The purpose of a while loop is to execute a statement or code block repeatedly as long
as an expression is true. Once the expression becomes false, the loop terminates.
while (expression){
Statement(s) to be executed if expression is true
}
WHILE LOOP
LOOP CONTROL
 JavaScript provides full control to handle loops and switch statements. There may be a
situation when you need to come out of a loop without reaching at its bottom.
 There may also be a situation when you want to skip a part of your code block and
start the next iteration of the look.
 To handle all such situations, JavaScript provides break and continue statements.
BREAK STATEMENT
 The break statement, which was briefly introduced with the switch statement, is used to
exit a loop early, breaking out of the enclosing curly braces.
break;
CONTINUE STATEMENT
 The continue statement tells the interpreter to immediately start the next iteration of
the loop and skip the remaining code block.
 When a continue statement is encountered, the program flow moves to the loop check
expression immediately and if the condition remains true, then it starts the next
iteration, otherwise the control comes out of the loop.
continue;
FUNCTIONS
 A function is a group of reusable code which can be called anywhere in your program.
This eliminates the need of writing the same code again and again. It helps
programmers in writing modular codes.
 Before we use a function, we need to define it. The most common way to define a
function in JavaScript is by using the function keyword, followed by a unique function
name, a list of parameters (that might be empty), and a statement block surrounded by
curly braces.
function functionname (parameter-list) {
statements
}
FUNCTIONS
 To invoke a function somewhere later in the script, you would simply need to write the
name of that function as shown in the following code.
 A function can take multiple parameters separated by comma.
 A JavaScript function can have an optional return statement. This is required if you want
to return a value from a function. This statement should be the last statement in a
function.
ALERT DIALOG BOX
 An alert dialog box is mostly used to give a message to the users.
 For example, if one input field requires to enter some text but the user does not
provide any input, then as a part of validation, you can use an alert box to give a
warning message.
alert(message);
CONFIRM DIALOG BOX
 A confirmation dialog box is mostly used to take user's consent on any option. It
displays a dialog box with two buttons: OK and Cancel.
 If the user clicks on the OK button, the window method confirm() will return true. If the
user clicks on the Cancel button, then confirm() returns false.
var retValue = confirm(message);
PROMPT DIALOG BOX
 The prompt dialog box is very useful when you want to pop-up a text box to get user
input. Thus, it enables you to interact with the user. The user needs to fill in the field and
then click OK.
 This dialog box is displayed using a method called prompt() which takes two
parameters: (i) a label which you want to display in the text box and (ii) a default string
to display in the text box.
 var retVal = prompt(message, defaultValue);
THANK YOU

More Related Content

What's hot (18)

DOCX
Php
Amrisha Sinha
 
DOCX
Janakiram web
MARELLA CHINABABU
 
PPTX
Sprouting into the world of Elm
Mike Onslow
 
PPTX
Error handling and debugging in vb
Salim M
 
DOC
Coding standards
mallareddy0107
 
PPS
Commenting Best Practices
mh_azad
 
PPT
Abap course chapter 7 abap objects and bsp
Milind Patil
 
PPTX
Introduction to computer science
umardanjumamaiwada
 
PPTX
C language
Arafat Bin Reza
 
PPTX
Java script basic
Ravi Bhadauria
 
PPTX
Exception handling in ASP .NET
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Cordovilla
brianmae002
 
PDF
Error handling and debugging
salissal
 
PPTX
code analysis for c++
Roman Okolovich
 
PPS
Coding Best Practices
mh_azad
 
PDF
Swift 2.0: Apple’s Advanced Programming Platform for Developers
Azilen Technologies Pvt. Ltd.
 
PPT
Vb script
Aamir Sohail
 
DOCX
Unit of competency
loidasacueza
 
Janakiram web
MARELLA CHINABABU
 
Sprouting into the world of Elm
Mike Onslow
 
Error handling and debugging in vb
Salim M
 
Coding standards
mallareddy0107
 
Commenting Best Practices
mh_azad
 
Abap course chapter 7 abap objects and bsp
Milind Patil
 
Introduction to computer science
umardanjumamaiwada
 
C language
Arafat Bin Reza
 
Java script basic
Ravi Bhadauria
 
Exception handling in ASP .NET
baabtra.com - No. 1 supplier of quality freshers
 
Cordovilla
brianmae002
 
Error handling and debugging
salissal
 
code analysis for c++
Roman Okolovich
 
Coding Best Practices
mh_azad
 
Swift 2.0: Apple’s Advanced Programming Platform for Developers
Azilen Technologies Pvt. Ltd.
 
Vb script
Aamir Sohail
 
Unit of competency
loidasacueza
 

Similar to Cordova training : Day 3 - Introduction to Javascript (20)

PPT
Javascript sivasoft
ch samaram
 
PDF
8 introduction to_java_script
Vijay Kalyan
 
PDF
IT2255 Web Essentials - Unit III Client-Side Processing and Scripting
pkaviya
 
PPTX
wp-UNIT_III.pptx
GANDHAMKUMAR2
 
PPTX
javascriptbasicsPresentationsforDevelopers
Ganesh Bhosale
 
PPTX
Unit 3-Javascript.pptx
AmanJha533833
 
PDF
Java Script notes
ANNIEJAN
 
PDF
Javascript - Tutorial
adelaticleanu
 
PDF
Ch3- Java Script.pdf
HASENSEID
 
PPTX
Unit III.pptx IT3401 web essentials presentatio
lakshitakumar291
 
PDF
Hsc IT Chap 3. Advanced javascript-1.pdf
AAFREEN SHAIKH
 
PDF
Javascript basics
shreesenthil
 
PPT
JavaScript - An Introduction
Manvendra Singh
 
PPTX
JavaScript_III.pptx
rashmiisrani1
 
PPTX
Java script
Sukrit Gupta
 
PPTX
Full Stack Online Course in Marathahalli| AchieversIT
AchieversIT
 
PPTX
JAVASCRIPT PPT [Autosaved].pptx
AchieversIT
 
PDF
javascriptPresentation.pdf
wildcat9335
 
PPTX
Lecture 5 javascript
Mujtaba Haider
 
Javascript sivasoft
ch samaram
 
8 introduction to_java_script
Vijay Kalyan
 
IT2255 Web Essentials - Unit III Client-Side Processing and Scripting
pkaviya
 
wp-UNIT_III.pptx
GANDHAMKUMAR2
 
javascriptbasicsPresentationsforDevelopers
Ganesh Bhosale
 
Unit 3-Javascript.pptx
AmanJha533833
 
Java Script notes
ANNIEJAN
 
Javascript - Tutorial
adelaticleanu
 
Ch3- Java Script.pdf
HASENSEID
 
Unit III.pptx IT3401 web essentials presentatio
lakshitakumar291
 
Hsc IT Chap 3. Advanced javascript-1.pdf
AAFREEN SHAIKH
 
Javascript basics
shreesenthil
 
JavaScript - An Introduction
Manvendra Singh
 
JavaScript_III.pptx
rashmiisrani1
 
Java script
Sukrit Gupta
 
Full Stack Online Course in Marathahalli| AchieversIT
AchieversIT
 
JAVASCRIPT PPT [Autosaved].pptx
AchieversIT
 
javascriptPresentation.pdf
wildcat9335
 
Lecture 5 javascript
Mujtaba Haider
 
Ad

More from Binu Paul (11)

PPTX
GIT
Binu Paul
 
PPTX
Cordova training - Day 9 - SQLITE
Binu Paul
 
PPTX
Cordova training - Day 8 - REST API's
Binu Paul
 
PPTX
Cordova training - Day 7 - Form data processing
Binu Paul
 
PPTX
Cordova training : Cordova plugins
Binu Paul
 
PPTX
Cordova training : Day 6 - UI development using Framework7
Binu Paul
 
PPTX
Cordova training : Day 5 - UI development using Framework7
Binu Paul
 
PPTX
Cordova training : Day 4 - Advanced Javascript
Binu Paul
 
PPTX
Cordova training - Day 3 : Advanced CSS 3
Binu Paul
 
PPTX
Cordova training - Day 2 Introduction to CSS 3
Binu Paul
 
PPTX
Cordova training : Day 1 : Introduction to Cordova
Binu Paul
 
Cordova training - Day 9 - SQLITE
Binu Paul
 
Cordova training - Day 8 - REST API's
Binu Paul
 
Cordova training - Day 7 - Form data processing
Binu Paul
 
Cordova training : Cordova plugins
Binu Paul
 
Cordova training : Day 6 - UI development using Framework7
Binu Paul
 
Cordova training : Day 5 - UI development using Framework7
Binu Paul
 
Cordova training : Day 4 - Advanced Javascript
Binu Paul
 
Cordova training - Day 3 : Advanced CSS 3
Binu Paul
 
Cordova training - Day 2 Introduction to CSS 3
Binu Paul
 
Cordova training : Day 1 : Introduction to Cordova
Binu Paul
 
Ad

Recently uploaded (20)

PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PPTX
3uTools Full Crack Free Version Download [Latest] 2025
muhammadgurbazkhan
 
PPTX
Engineering the Java Web Application (MVC)
abhishekoza1981
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
DOCX
Import Data Form Excel to Tally Services
Tally xperts
 
PDF
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PDF
Capcut Pro Crack For PC Latest Version {Fully Unlocked} 2025
hashhshs786
 
PPTX
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PPTX
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
PPTX
Revolutionizing Code Modernization with AI
KrzysztofKkol1
 
PDF
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
PPTX
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
PPTX
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
PDF
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
PPTX
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
3uTools Full Crack Free Version Download [Latest] 2025
muhammadgurbazkhan
 
Engineering the Java Web Application (MVC)
abhishekoza1981
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Import Data Form Excel to Tally Services
Tally xperts
 
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Capcut Pro Crack For PC Latest Version {Fully Unlocked} 2025
hashhshs786
 
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
Tally software_Introduction_Presentation
AditiBansal54083
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
Revolutionizing Code Modernization with AI
KrzysztofKkol1
 
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
Human Resources Information System (HRIS)
Amity University, Patna
 
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 

Cordova training : Day 3 - Introduction to Javascript

  • 1. CORDOVA TRAINING SESSION: 3 – INTRODUCTION TO JAVASCRIPT
  • 2. INTRODUCTION TO JAVASCRIPT  Javascript is a dynamic computer programming language. It is lightweight and most commonly used as a part of web pages.  JavaScript is a lightweight, interpreted programming language.  Designed for creating network-centric applications.  Complementary to and integrated with Java.  Complementary to and integrated with HTML.  Open and cross-platform
  • 3. ADVANTAGES OF JAVASCRIPT  The merits of using JavaScript are:  Less server interaction  Immediate feedback to the visitors  Increased interactivity  Richer interfaces
  • 4. DIS-ADVANTAGES OF JAVASCRIPT  The demerits of using JavaScript are:  Client-side JavaScript does not allow the reading or writing of files. This has been kept for security reason.  JavaScript cannot be used for networking applications because there is no such support available.  JavaScript doesn't have any multithreading or multiprocessor capabilities.
  • 5. SYNTAX  JavaScript can be implemented using JavaScript statements that are placed within the <script>... </script> HTML tags in a web page.  You can place the <script> tags, containing your JavaScript, anywhere within you web page, but it is normally recommended that you should keep it within the <head> tags. <script language="javascript" type="text/javascript"> JavaScript code </script>
  • 6. SYNTAX  JavaScript ignores spaces, tabs, and newlines that appear in JavaScript programs.  Simple statements in JavaScript are generally followed by a semicolon character, just as they are in C, C++, and Java.  JavaScript is a case-sensitive language. This means that the language keywords, variables, function names, and any other identifiers must always be typed with a consistent capitalization of letters.
  • 7. COMMENTS  JavaScript supports both C-style and C++-style comments:  Any text between a // and the end of a line is treated as a comment and is ignored by JavaScript.  Any text between the characters /* and */ is treated as a comment. This may span multiple lines.
  • 8. INCLUDING JAVASCRIPT IN A PAGE  There is a flexibility given to include JavaScript code anywhere in an HTML document. However the most preferred ways to include JavaScript in an HTML file are as follows:  Script in <head>...</head> section  Script in <body>...</body> section  Script in an external file and then include in <head>...</head> section <script type="text/javascript" src="filename.js" ></script>
  • 9. JAVASCRIPT VARIABLES  One of the most fundamental characteristics of a programming language is the set of data types it supports.  JavaScript allows you to work with three primitive data types:  String  Number  Boolean : true | false
  • 10. JAVASCRIPT VARIABLES  Like many other programming languages, JavaScript has variables. Variables can be thought of as named containers. You can place data into these containers and then refer to the data simply by naming the container.  Before you use a variable in a JavaScript program, you must declare it. Variables are declared with the var keyword var name;
  • 11. JAVASCRIPT RESERVED KEYWORDS  A list of all the reserved words in JavaScript are given in the following table. They cannot be used as JavaScript variables, functions, methods, loop labels, or any object names.
  • 13. OPERATORS  Let us take a simple expression 4 + 5 is equal to 9. Here 4 and 5 are called operands and ‘+’ is called the operator.  JavaScript supports the following types of operators:  Arithmetic  Comparision  Logical  Assignment  Conditional
  • 14. ARITHMETIC OPERATORS  JavaScript supports the following arithmetic operators:  + (Addition)  - (Subtraction)  * (Multiplication)  / (Division)  % (Modulus)  ++ (Increment)  -- (Decrement)
  • 15. COMPARISION OPERATORS  JavaScript supports the following comparison operators:  = = (Equal)  != (Not Equal)  > (Greater than)  >= (Greater than or Equal to)  < (Less than)  <= (Less than or Equal to)
  • 16. LOGICAL OPERATORS  JavaScript supports the following logical operators:  && (Logical AND)  || (Logical OR)  ! (Logical NOT)
  • 17. ASSIGNMENT OPERATORS  JavaScript supports the following assignment operators:  = (Simple Assignment )  += (Add and Assignment)  −= (Subtract and Assignment)  *= (Multiply and Assignment)  /= (Divide and Assignment)  %= (Modules and Assignment)
  • 18. CONDITIONAL OPERATORS  The conditional operator first evaluates an expression for a true or false value and then executes one of the two given statements depending upon the result of the evaluation.  ? : (Conditional ) If Condition is true? Then value X : Otherwise value Y
  • 19. IF-ELSE STATEMENT  While writing a program, there may be a situation when you need to adopt one out of a given set of paths. In such cases, you need to use conditional statements that allow your program to make correct decisions and perform right actions. if (expression) { Statement(s) to be executed if expression is true } else{ Statement(s) to be executed if expression is false }
  • 21. SWITCH CASE STATEMENT  We can use a switch statement to handle a situation where repeated if...else if statements are required. switch (expression) { case condition 1: statement(s) break; case condition 2: statement(s) break; default: statement(s) }
  • 23. LOOPS  You may encounter a situation where you need to perform an action over and over again. In such situations, you would need to write loop statements. Javascript supports the following types of loops:  for loop  while loop
  • 24. FOR LOOP  The 'for' loop is the most compact form of looping. It includes the following three important parts.  loop initialization  test statement  iteration statement for (initialization; test condition; iteration statement) { Statement(s) to be executed if test condition is true }
  • 26. WHILE LOOP  The purpose of a while loop is to execute a statement or code block repeatedly as long as an expression is true. Once the expression becomes false, the loop terminates. while (expression){ Statement(s) to be executed if expression is true }
  • 28. LOOP CONTROL  JavaScript provides full control to handle loops and switch statements. There may be a situation when you need to come out of a loop without reaching at its bottom.  There may also be a situation when you want to skip a part of your code block and start the next iteration of the look.  To handle all such situations, JavaScript provides break and continue statements.
  • 29. BREAK STATEMENT  The break statement, which was briefly introduced with the switch statement, is used to exit a loop early, breaking out of the enclosing curly braces. break;
  • 30. CONTINUE STATEMENT  The continue statement tells the interpreter to immediately start the next iteration of the loop and skip the remaining code block.  When a continue statement is encountered, the program flow moves to the loop check expression immediately and if the condition remains true, then it starts the next iteration, otherwise the control comes out of the loop. continue;
  • 31. FUNCTIONS  A function is a group of reusable code which can be called anywhere in your program. This eliminates the need of writing the same code again and again. It helps programmers in writing modular codes.  Before we use a function, we need to define it. The most common way to define a function in JavaScript is by using the function keyword, followed by a unique function name, a list of parameters (that might be empty), and a statement block surrounded by curly braces. function functionname (parameter-list) { statements }
  • 32. FUNCTIONS  To invoke a function somewhere later in the script, you would simply need to write the name of that function as shown in the following code.  A function can take multiple parameters separated by comma.  A JavaScript function can have an optional return statement. This is required if you want to return a value from a function. This statement should be the last statement in a function.
  • 33. ALERT DIALOG BOX  An alert dialog box is mostly used to give a message to the users.  For example, if one input field requires to enter some text but the user does not provide any input, then as a part of validation, you can use an alert box to give a warning message. alert(message);
  • 34. CONFIRM DIALOG BOX  A confirmation dialog box is mostly used to take user's consent on any option. It displays a dialog box with two buttons: OK and Cancel.  If the user clicks on the OK button, the window method confirm() will return true. If the user clicks on the Cancel button, then confirm() returns false. var retValue = confirm(message);
  • 35. PROMPT DIALOG BOX  The prompt dialog box is very useful when you want to pop-up a text box to get user input. Thus, it enables you to interact with the user. The user needs to fill in the field and then click OK.  This dialog box is displayed using a method called prompt() which takes two parameters: (i) a label which you want to display in the text box and (ii) a default string to display in the text box.  var retVal = prompt(message, defaultValue);