SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Tendances

Tendances (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
 

Similaire à 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
 

Similaire à 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
 

Plus 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
 

Plus 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
 

Dernier

WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburgmasabamasaba
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 

Dernier (20)

WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 

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