SlideShare uma empresa Scribd logo
1 de 36
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

Mais conteúdo relacionado

Mais procurados

Mais procurados (18)

Php
PhpPhp
Php
 
Janakiram web
Janakiram webJanakiram web
Janakiram web
 
Sprouting into the world of Elm
Sprouting into the world of ElmSprouting into the world of Elm
Sprouting into the world of Elm
 
Error handling and debugging in vb
Error handling and debugging in vbError handling and debugging in vb
Error handling and debugging in vb
 
Coding standards
Coding standardsCoding standards
Coding standards
 
Commenting Best Practices
Commenting Best PracticesCommenting Best Practices
Commenting Best Practices
 
Abap course chapter 7 abap objects and bsp
Abap course   chapter 7 abap objects and bspAbap course   chapter 7 abap objects and bsp
Abap course chapter 7 abap objects and bsp
 
Introduction to computer science
Introduction to computer scienceIntroduction to computer science
Introduction to computer science
 
C language
C languageC language
C language
 
Java script basic
Java script basicJava script basic
Java script basic
 
Exception handling in ASP .NET
Exception handling in ASP .NETException handling in ASP .NET
Exception handling in ASP .NET
 
Cordovilla
CordovillaCordovilla
Cordovilla
 
Error handling and debugging
Error handling and debuggingError handling and debugging
Error handling and debugging
 
code analysis for c++
code analysis for c++code analysis for c++
code analysis for c++
 
Coding Best Practices
Coding Best PracticesCoding Best Practices
Coding Best Practices
 
Swift 2.0: Apple’s Advanced Programming Platform for Developers
Swift 2.0: Apple’s Advanced Programming Platform for DevelopersSwift 2.0: Apple’s Advanced Programming Platform for Developers
Swift 2.0: Apple’s Advanced Programming Platform for Developers
 
Vb script
Vb scriptVb script
Vb script
 
Unit of competency
Unit of competencyUnit of competency
Unit of competency
 

Semelhante a Cordova training : Day 3 - Introduction to Javascript

Ch3- Java Script.pdf
Ch3- Java Script.pdfCh3- Java Script.pdf
Ch3- Java Script.pdfHASENSEID
 
Introduction to java script
Introduction to java scriptIntroduction to java script
Introduction to java scriptDivyaKS12
 
Javascript tutorial basic for starter
Javascript tutorial basic for starterJavascript tutorial basic for starter
Javascript tutorial basic for starterMarcello Harford
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascriptambuj pathak
 
Basics of Javascript
Basics of Javascript Basics of Javascript
Basics of Javascript poojanov04
 
Javascript sivasoft
Javascript sivasoftJavascript sivasoft
Javascript sivasoftch samaram
 
Macasu, gerrell c.
Macasu, gerrell c.Macasu, gerrell c.
Macasu, gerrell c.gerrell
 
Switch case and looping new
Switch case and looping newSwitch case and looping new
Switch case and looping newaprilyyy
 
Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!olracoatalub
 
Android Application Development - Level 3
Android Application Development - Level 3Android Application Development - Level 3
Android Application Development - Level 3Isham Rashik
 
a basic java programming and data type.ppt
a basic java programming and data type.ppta basic java programming and data type.ppt
a basic java programming and data type.pptGevitaChinnaiah
 

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

Ch3- Java Script.pdf
Ch3- Java Script.pdfCh3- Java Script.pdf
Ch3- Java Script.pdf
 
Introduction to java script
Introduction to java scriptIntroduction to java script
Introduction to java script
 
Javascript tutorial basic for starter
Javascript tutorial basic for starterJavascript tutorial basic for starter
Javascript tutorial basic for starter
 
Java chapter 5
Java chapter 5Java chapter 5
Java chapter 5
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
My final requirement
My final requirementMy final requirement
My final requirement
 
Basics of Javascript
Basics of Javascript Basics of Javascript
Basics of Javascript
 
Switch case and looping jam
Switch case and looping jamSwitch case and looping jam
Switch case and looping jam
 
Programming in Arduino (Part 2)
Programming in Arduino  (Part 2)Programming in Arduino  (Part 2)
Programming in Arduino (Part 2)
 
Javascript sivasoft
Javascript sivasoftJavascript sivasoft
Javascript sivasoft
 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
 
Java script
Java scriptJava script
Java script
 
Macasu, gerrell c.
Macasu, gerrell c.Macasu, gerrell c.
Macasu, gerrell c.
 
Switch case and looping new
Switch case and looping newSwitch case and looping new
Switch case and looping new
 
Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!
 
Javascript
JavascriptJavascript
Javascript
 
Android Application Development - Level 3
Android Application Development - Level 3Android Application Development - Level 3
Android Application Development - Level 3
 
Web programming
Web programmingWeb programming
Web programming
 
Unit 2.5
Unit 2.5Unit 2.5
Unit 2.5
 
a basic java programming and data type.ppt
a basic java programming and data type.ppta basic java programming and data type.ppt
a basic java programming and data type.ppt
 

Mais de Binu Paul

Cordova training - Day 9 - SQLITE
Cordova training - Day 9 - SQLITECordova training - Day 9 - SQLITE
Cordova training - Day 9 - SQLITEBinu Paul
 
Cordova training - Day 8 - REST API's
Cordova training - Day 8 - REST API'sCordova training - Day 8 - REST API's
Cordova training - Day 8 - REST API'sBinu Paul
 
Cordova training - Day 7 - Form data processing
Cordova training - Day 7 - Form data processingCordova training - Day 7 - Form data processing
Cordova training - Day 7 - Form data processingBinu Paul
 
Cordova training : Cordova plugins
Cordova training : Cordova pluginsCordova training : Cordova plugins
Cordova training : Cordova pluginsBinu Paul
 
Cordova training : Day 6 - UI development using Framework7
Cordova training : Day 6 - UI development using Framework7Cordova training : Day 6 - UI development using Framework7
Cordova training : Day 6 - UI development using Framework7Binu Paul
 
Cordova training : Day 5 - UI development using Framework7
Cordova training : Day 5 - UI development using Framework7Cordova training : Day 5 - UI development using Framework7
Cordova training : Day 5 - UI development using Framework7Binu Paul
 
Cordova training : Day 4 - Advanced Javascript
Cordova training : Day 4 - Advanced JavascriptCordova training : Day 4 - Advanced Javascript
Cordova training : Day 4 - Advanced JavascriptBinu Paul
 
Cordova training - Day 3 : Advanced CSS 3
Cordova training - Day 3 : Advanced CSS 3Cordova training - Day 3 : Advanced CSS 3
Cordova training - Day 3 : Advanced CSS 3Binu Paul
 
Cordova training - Day 2 Introduction to CSS 3
Cordova training - Day 2 Introduction to CSS 3Cordova training - Day 2 Introduction to CSS 3
Cordova training - Day 2 Introduction to CSS 3Binu Paul
 
Cordova training : Day 1 : Introduction to Cordova
Cordova training : Day 1 : Introduction to CordovaCordova training : Day 1 : Introduction to Cordova
Cordova training : Day 1 : Introduction to CordovaBinu Paul
 

Mais de Binu Paul (11)

GIT
GITGIT
GIT
 
Cordova training - Day 9 - SQLITE
Cordova training - Day 9 - SQLITECordova training - Day 9 - SQLITE
Cordova training - Day 9 - SQLITE
 
Cordova training - Day 8 - REST API's
Cordova training - Day 8 - REST API'sCordova training - Day 8 - REST API's
Cordova training - Day 8 - REST API's
 
Cordova training - Day 7 - Form data processing
Cordova training - Day 7 - Form data processingCordova training - Day 7 - Form data processing
Cordova training - Day 7 - Form data processing
 
Cordova training : Cordova plugins
Cordova training : Cordova pluginsCordova training : Cordova plugins
Cordova training : Cordova plugins
 
Cordova training : Day 6 - UI development using Framework7
Cordova training : Day 6 - UI development using Framework7Cordova training : Day 6 - UI development using Framework7
Cordova training : Day 6 - UI development using Framework7
 
Cordova training : Day 5 - UI development using Framework7
Cordova training : Day 5 - UI development using Framework7Cordova training : Day 5 - UI development using Framework7
Cordova training : Day 5 - UI development using Framework7
 
Cordova training : Day 4 - Advanced Javascript
Cordova training : Day 4 - Advanced JavascriptCordova training : Day 4 - Advanced Javascript
Cordova training : Day 4 - Advanced Javascript
 
Cordova training - Day 3 : Advanced CSS 3
Cordova training - Day 3 : Advanced CSS 3Cordova training - Day 3 : Advanced CSS 3
Cordova training - Day 3 : Advanced CSS 3
 
Cordova training - Day 2 Introduction to CSS 3
Cordova training - Day 2 Introduction to CSS 3Cordova training - Day 2 Introduction to CSS 3
Cordova training - Day 2 Introduction to CSS 3
 
Cordova training : Day 1 : Introduction to Cordova
Cordova training : Day 1 : Introduction to CordovaCordova training : Day 1 : Introduction to Cordova
Cordova training : Day 1 : Introduction to Cordova
 

Último

Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 

Último (20)

Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 

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);