SlideShare a Scribd company logo
JAVA SCRIPT
SESSION NO 3

11/25/2013

Developed By: Saif Ullah Dar

1
SESSION OBJECTIVES
1) Java Script Data Types.
2) Primitive Data Types.
3) Composite Data Types.
4) Trivial Data Types.
5) Java Script Variables.
6) Rules for Declaration of Variables
7) Java Script Keywords.
8) Scope of Variables.
9) Examples
10) Quiz
11/25/2013

Developed By: Saif Ullah Dar

2
JAVA SCRIPT DATA TYPES
• Data is the information and Data Types means the
ways in which we can retrieve the data.
• There are two Main types of the Data Types in Java
Script Language
1. Primitive Data Types
2. Composite Data Types

11/25/2013

Developed By: Saif Ullah Dar

3
JAVA SCRIPT DATA TYPES

11/25/2013

Developed By: Saif Ullah Dar

4
PRIMITIVE DATA TYPES
• JavaScript has three “primitive” types: number, string,
and Boolean
• Numbers are always stored as floating-point values
• Hexadecimal numbers begin with 0x
• Some platforms treat 0123 as octal, others treat it as
decimal

• Strings may be enclosed in single quotes or double
quotes
• Strings can contains n (newline), " (double quote), etc.

• Booleans are either true or false
• 0, "0", empty strings, undefined, null, and NaN are false ,
other values are true
11/25/2013

Developed By: Saif Ullah Dar

5
PRIMITIVE DATA TYPES

11/25/2013

Developed By: Saif Ullah Dar

6
COMPOSITE DATA TYPES
• A composite data type stores a collection of
multiple related values, unlike primitive data types.
• JavaScript supports a composite data type known
as objects, Functions, Arrays
• This will be discussed in the next Chapter in details.

11/25/2013

Developed By: Saif Ullah Dar

7
NOTE
• Java does not make a distinction between integer
values and floating-point values. All numbers in
JavaScript are represented as floating-point values.
JavaScript represents numbers using the 64-bit
floating-point format defined by the IEEE 754
standard.

11/25/2013

Developed By: Saif Ullah Dar

8
TRIVIAL DATA TYPES
JavaScript also defines two trivial data
types, null and undefined, each of which defines
only a single value.
The null keyword specifies that a variable does not
hold any value. (the null value is not equal to zero
because zero is a calculate value while null refers to
the absence of a value)

11/25/2013

Developed By: Saif Ullah Dar

9
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.

11/25/2013

Developed By: Saif Ullah Dar

10
DEFINING VARIABLES
<script type="text/javascript">
<!–
var money;
var name;
//-->
</script>

11/25/2013

<script type="text/javascript">
<!–
var money, name;
//-->
</script>

Developed By: Saif Ullah Dar

11
RULES TO DEFINED VARIABLES
Java Script is a case-sensitive language.
These rules are that a variable name:
Can consist of digit, underscore, and alphabets.
Must begin with a letter or underscore character
Cannot begin with a number and cannot contain
any punctuation marks.
• Cannot contain any kind of special characters such
as +,*,%,and so on.
• Cannot contain spaces
• Cannot be a Java Script keyword
•
•
•
•
•

11/25/2013

Developed By: Saif Ullah Dar

12
VARIABLE INITIALIZATION
• Storing a value in a
variable is called variable
initialization.
• You can do variable
initialization at the time of
variable creation or later
point in time when you
need that variable.
• For instance, you might
create a variable
named money and
assign the value 2000.50
to it later. For another
variable you can assign a
value the time of
initialization as follows:
11/25/2013

<script
type="text/javascript">
<!–
var name = “Saif Ullah";
var money;
money = 2000.50;
//-->
</script>

Developed By: Saif Ullah Dar

13
JAVA SCRIPT IMPORTANT HINTS
• Use the var keyword only for declaration or
initialization. Once for the life of any variable name
in a document. You should not re-declare same
variable twice.
• JavaScript is untyped language. This means that a
JavaScript variable can hold a value of any data
type. Unlike many other languages, you don't have
to tell JavaScript during variable declaration what
type of value the variable will hold. The value type
of a variable can change during the execution of a
program and JavaScript takes care of it
automatically.
11/25/2013

Developed By: Saif Ullah Dar

14
JAVA SCRIPT KEYWORDS
• The following are reserved
words in JavaScript.
• They cannot be used as
JavaScript
variables, functions, metho
ds, loop labels, or any
object names.

11/25/2013

abstract
boolean
break
byte
case
catch
char
class
const
continue
debugg
er
default
delete
do
double

Developed By: Saif Ullah Dar

else
enum
export
extends
false
final
finally
float
for
function
goto
if
impleme
nts
import
in

instance
of
int
interface
long
native
new
null
package
private
protecte
d
public
return
short
static
super

switch
synchroni
zed
this
throw
throws
transient
true
try
typeof
var
void
volatile
while
with

15
ESCAPE SEQUENCES CHARACTERS


There are multiple escape sequence characters in JavaScript that
provides various kind of formatting.

11/25/2013

Developed By: Saif Ullah Dar

16
SCOPE OF VARIABLES
The scope of a variable is the region of your program in which
it is defined. JavaScript variable will have only two scopes.
a) Global Variables: A global variable has global scope which
means it is defined everywhere in your JavaScript code.
b) Local Variables: A local variable will be visible only within a
function where it is defined. Function parameters are
always local to that function.
Within the body of a function, a local variable takes
precedence over a global variable with the same name. If
you declare a local variable or function parameter with the
same name as a global variable, you effectively hide the
global variable.
EXAMPLE OF DYNAMIC VARIABLES
• JavaScript has dynamic types.
• This means that the same variable
can be used as different types:
Example
var x;
// Now x is undefined
var x = 5;
// Now x is a Number
var x = “Saif Ullah Dar";
// Now x is a
String

11/25/2013

Developed By: Saif Ullah Dar

18
JAVA SCRIPT STRINGS
• A string is a variable which stores a series of
characters like “Saif Ullah Dar".
• A string can be any text inside quotes. You can
use single or double quotes:
Example
var carname="Volvo XC60";
var carname='Volvo XC60';
 You can use quotes inside a string, as long as they don't
match the quotes surrounding the string:

Example
var answer="It's alright";
var answer="He is called ‘Saif'";
var answer='He is called “Mr Dar"';
11/25/2013

Developed By: Saif Ullah Dar

19
JAVASCRIPT NUMBERS
• JavaScript has only one type of numbers.
• Numbers can be written with, or without decimals:
Example
var x1=34.00;
// Written with
decimals
var x2=34;
// Written without
decimals
 Extra large or extra small numbers can be written with scientific
(exponential) notation:
Example
var y=123e5;
var z=123e-5;

11/25/2013

// 12300000
// 0.00123

Developed By: Saif Ullah Dar

20
JAVA SCRIPT BOOLEANS
• Booleans can only have two values: true or false.
• Booleans are often used in conditional testing.
You will learn more about conditional testing in a
later chapter of this tutorial.

var x=true;
var y=false;

11/25/2013

Developed By: Saif Ullah Dar

21
<!DOCTYPE html>
<html>
<body>
<script>
var firstname;
firstname=“Saif";
document.write(firstname);
document.write("<br>");
firstname=“Ullah";
document.write(firstname);
</script>

<p>The script above declares a
variable,
assigns a value to it, displays the value,
changes the value,
and displays the value again.</p>
<body>
</html>
11/25/2013

Developed By: Saif Ullah Dar

22
QUIZ:1
Inside which HTML element do we put the JavaScript?
(1)<javascript>
(2)<js>
(3)<script>
(4)<scripting>

11/25/2013

Developed By: Saif Ullah Dar

23
ANS:1
Inside which HTML element do we put the JavaScript?
(1)<javascript>
(2)<js>
(3)<script>
(4)<scripting>

11/25/2013

Developed By: Saif Ullah Dar

24
QUIZ:2
What is the correct JavaScript syntax to write "Hello World"?
(1)document.write("Hello World");
(2)echo "Hello World";
(3)("Hello World");
(4)response.write("Hello World");

11/25/2013

Developed By: Saif Ullah Dar

25
ANS:2
What is the correct JavaScript syntax to write "Hello World"?
(1)document.write("Hello World");
(2)echo "Hello World";
(3)("Hello World");
(4)response.write("Hello World");

11/25/2013

Developed By: Saif Ullah Dar

26
THANK YOU
SAIF ULLAH DAR

11/25/2013

Developed By: Saif Ullah Dar

27

More Related Content

What's hot (20)

Javascript
JavascriptJavascript
Javascript
Momentum Design Lab
 
Introduction to Javascript programming
Introduction to Javascript programmingIntroduction to Javascript programming
Introduction to Javascript programming
Fulvio Corno
 
Java Script An Introduction By HWA
Java Script An Introduction By HWAJava Script An Introduction By HWA
Java Script An Introduction By HWA
Emma Wood
 
JavaScript Jump Start 20220214
JavaScript Jump Start 20220214JavaScript Jump Start 20220214
JavaScript Jump Start 20220214
Haim Michael
 
Introduction to java_script
Introduction to java_scriptIntroduction to java_script
Introduction to java_script
Basavaraj Hampali
 
JavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScriptJavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScript
Laurence Svekis ✔
 
Javascript
JavascriptJavascript
Javascript
Nagarajan
 
Wt unit 6 ppts web services
Wt unit 6 ppts web servicesWt unit 6 ppts web services
Wt unit 6 ppts web services
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
JavaScript - Chapter 3 - Introduction
 JavaScript - Chapter 3 - Introduction JavaScript - Chapter 3 - Introduction
JavaScript - Chapter 3 - Introduction
WebStackAcademy
 
Introduction to Javascript By Satyen
Introduction to Javascript By  SatyenIntroduction to Javascript By  Satyen
Introduction to Javascript By Satyen
Satyen Pandya
 
Node.js Crash Course (Jump Start)
Node.js Crash Course (Jump Start) Node.js Crash Course (Jump Start)
Node.js Crash Course (Jump Start)
Haim Michael
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
Marlon Jamera
 
Java script
Java scriptJava script
Java script
Sadeek Mohammed
 
Wt unit 2 ppts client side technology
Wt unit 2 ppts client side technologyWt unit 2 ppts client side technology
Wt unit 2 ppts client side technology
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
Wt unit 5 client &amp; server side framework
Wt unit 5 client &amp; server side frameworkWt unit 5 client &amp; server side framework
Wt unit 5 client &amp; server side framework
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
From User Action to Framework Reaction
From User Action to Framework ReactionFrom User Action to Framework Reaction
From User Action to Framework Reaction
jbandi
 
[2015/2016] Require JS and Handlebars JS
[2015/2016] Require JS and Handlebars JS[2015/2016] Require JS and Handlebars JS
[2015/2016] Require JS and Handlebars JS
Ivano Malavolta
 
Javascript
JavascriptJavascript
Javascript
Mallikarjuna G D
 
Introduction To JavaScript
Introduction To JavaScriptIntroduction To JavaScript
Introduction To JavaScript
Reema
 
Java script
Java scriptJava script
Java script
Rajkiran Mummadi
 
Introduction to Javascript programming
Introduction to Javascript programmingIntroduction to Javascript programming
Introduction to Javascript programming
Fulvio Corno
 
Java Script An Introduction By HWA
Java Script An Introduction By HWAJava Script An Introduction By HWA
Java Script An Introduction By HWA
Emma Wood
 
JavaScript Jump Start 20220214
JavaScript Jump Start 20220214JavaScript Jump Start 20220214
JavaScript Jump Start 20220214
Haim Michael
 
JavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScriptJavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScript
Laurence Svekis ✔
 
JavaScript - Chapter 3 - Introduction
 JavaScript - Chapter 3 - Introduction JavaScript - Chapter 3 - Introduction
JavaScript - Chapter 3 - Introduction
WebStackAcademy
 
Introduction to Javascript By Satyen
Introduction to Javascript By  SatyenIntroduction to Javascript By  Satyen
Introduction to Javascript By Satyen
Satyen Pandya
 
Node.js Crash Course (Jump Start)
Node.js Crash Course (Jump Start) Node.js Crash Course (Jump Start)
Node.js Crash Course (Jump Start)
Haim Michael
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
Marlon Jamera
 
From User Action to Framework Reaction
From User Action to Framework ReactionFrom User Action to Framework Reaction
From User Action to Framework Reaction
jbandi
 
[2015/2016] Require JS and Handlebars JS
[2015/2016] Require JS and Handlebars JS[2015/2016] Require JS and Handlebars JS
[2015/2016] Require JS and Handlebars JS
Ivano Malavolta
 
Introduction To JavaScript
Introduction To JavaScriptIntroduction To JavaScript
Introduction To JavaScript
Reema
 

Viewers also liked (15)

Session No1
Session No1 Session No1
Session No1
Saif Ullah Dar
 
Session no 4
Session no 4Session no 4
Session no 4
Saif Ullah Dar
 
C programming session 09
C programming session 09C programming session 09
C programming session 09
Dushmanta Nath
 
C programming session 11
C programming session 11C programming session 11
C programming session 11
Dushmanta Nath
 
Session no 2
Session no 2Session no 2
Session no 2
Saif Ullah Dar
 
C programming session 07
C programming session 07C programming session 07
C programming session 07
Dushmanta Nath
 
C programming session 03
C programming session 03C programming session 03
C programming session 03
Dushmanta Nath
 
C programming session 04
C programming session 04C programming session 04
C programming session 04
Dushmanta Nath
 
C programming session 02
C programming session 02C programming session 02
C programming session 02
Dushmanta Nath
 
C programming session 05
C programming session 05C programming session 05
C programming session 05
Dushmanta Nath
 
C programming session 08
C programming session 08C programming session 08
C programming session 08
Dushmanta Nath
 
C programming session 01
C programming session 01C programming session 01
C programming session 01
Dushmanta Nath
 
An Overview of HTML, CSS & Java Script
An Overview of HTML, CSS & Java ScriptAn Overview of HTML, CSS & Java Script
An Overview of HTML, CSS & Java Script
Fahim Abdullah
 
Session 3 Java Script
Session 3 Java ScriptSession 3 Java Script
Session 3 Java Script
Muhammad Hesham
 
C language (Collected By Dushmanta)
C language  (Collected By Dushmanta)C language  (Collected By Dushmanta)
C language (Collected By Dushmanta)
Dushmanta Nath
 
C programming session 09
C programming session 09C programming session 09
C programming session 09
Dushmanta Nath
 
C programming session 11
C programming session 11C programming session 11
C programming session 11
Dushmanta Nath
 
C programming session 07
C programming session 07C programming session 07
C programming session 07
Dushmanta Nath
 
C programming session 03
C programming session 03C programming session 03
C programming session 03
Dushmanta Nath
 
C programming session 04
C programming session 04C programming session 04
C programming session 04
Dushmanta Nath
 
C programming session 02
C programming session 02C programming session 02
C programming session 02
Dushmanta Nath
 
C programming session 05
C programming session 05C programming session 05
C programming session 05
Dushmanta Nath
 
C programming session 08
C programming session 08C programming session 08
C programming session 08
Dushmanta Nath
 
C programming session 01
C programming session 01C programming session 01
C programming session 01
Dushmanta Nath
 
An Overview of HTML, CSS & Java Script
An Overview of HTML, CSS & Java ScriptAn Overview of HTML, CSS & Java Script
An Overview of HTML, CSS & Java Script
Fahim Abdullah
 
C language (Collected By Dushmanta)
C language  (Collected By Dushmanta)C language  (Collected By Dushmanta)
C language (Collected By Dushmanta)
Dushmanta Nath
 
Ad

Similar to Java script session 3 (20)

04-JS.pptx
04-JS.pptx04-JS.pptx
04-JS.pptx
RazanMazen4
 
04-JS.pptx
04-JS.pptx04-JS.pptx
04-JS.pptx
RazanMazen4
 
04-JS.pptx
04-JS.pptx04-JS.pptx
04-JS.pptx
RazanMazen4
 
WT Unit-3 PPT.pptx
WT Unit-3 PPT.pptxWT Unit-3 PPT.pptx
WT Unit-3 PPT.pptx
TusharTikia
 
data-types-operators-datatypes-operators.ppt
data-types-operators-datatypes-operators.pptdata-types-operators-datatypes-operators.ppt
data-types-operators-datatypes-operators.ppt
Gagan Rana
 
Web programming
Web programmingWeb programming
Web programming
Leo Mark Villar
 
Javascript
JavascriptJavascript
Javascript
20261A05H0SRIKAKULAS
 
Javascript Tlabs
Javascript TlabsJavascript Tlabs
Javascript Tlabs
msneha
 
JavaScript.pptx
JavaScript.pptxJavaScript.pptx
JavaScript.pptx
KennyPratheepKumar
 
Java script
Java scriptJava script
Java script
Jay Patel
 
javascript client side scripting la.pptx
javascript client side scripting la.pptxjavascript client side scripting la.pptx
javascript client side scripting la.pptx
lekhacce
 
Java script
Java scriptJava script
Java script
Shyam Khant
 
Javascript Journey
Javascript JourneyJavascript Journey
Javascript Journey
Wanqiang Ji
 
Js datatypes
Js datatypesJs datatypes
Js datatypes
Sireesh K
 
Unit 3-Javascript.pptx
Unit 3-Javascript.pptxUnit 3-Javascript.pptx
Unit 3-Javascript.pptx
AmanJha533833
 
javascriptPresentation.pdf
javascriptPresentation.pdfjavascriptPresentation.pdf
javascriptPresentation.pdf
wildcat9335
 
Lecture 5 javascript
Lecture 5 javascriptLecture 5 javascript
Lecture 5 javascript
Mujtaba Haider
 
Chapter 3 INTRODUCTION TO JAVASCRIPT S.pptx
Chapter 3 INTRODUCTION TO JAVASCRIPT S.pptxChapter 3 INTRODUCTION TO JAVASCRIPT S.pptx
Chapter 3 INTRODUCTION TO JAVASCRIPT S.pptx
KelemAlebachew
 
chap04.ppt
chap04.pptchap04.ppt
chap04.ppt
Varsha Uchagaonkar
 
Javascript
JavascriptJavascript
Javascript
Manav Prasad
 
WT Unit-3 PPT.pptx
WT Unit-3 PPT.pptxWT Unit-3 PPT.pptx
WT Unit-3 PPT.pptx
TusharTikia
 
data-types-operators-datatypes-operators.ppt
data-types-operators-datatypes-operators.pptdata-types-operators-datatypes-operators.ppt
data-types-operators-datatypes-operators.ppt
Gagan Rana
 
Javascript Tlabs
Javascript TlabsJavascript Tlabs
Javascript Tlabs
msneha
 
javascript client side scripting la.pptx
javascript client side scripting la.pptxjavascript client side scripting la.pptx
javascript client side scripting la.pptx
lekhacce
 
Javascript Journey
Javascript JourneyJavascript Journey
Javascript Journey
Wanqiang Ji
 
Js datatypes
Js datatypesJs datatypes
Js datatypes
Sireesh K
 
Unit 3-Javascript.pptx
Unit 3-Javascript.pptxUnit 3-Javascript.pptx
Unit 3-Javascript.pptx
AmanJha533833
 
javascriptPresentation.pdf
javascriptPresentation.pdfjavascriptPresentation.pdf
javascriptPresentation.pdf
wildcat9335
 
Chapter 3 INTRODUCTION TO JAVASCRIPT S.pptx
Chapter 3 INTRODUCTION TO JAVASCRIPT S.pptxChapter 3 INTRODUCTION TO JAVASCRIPT S.pptx
Chapter 3 INTRODUCTION TO JAVASCRIPT S.pptx
KelemAlebachew
 
Ad

More from Saif Ullah Dar (7)

Session no 3
Session no 3Session no 3
Session no 3
Saif Ullah Dar
 
Session no 1
Session no 1Session no 1
Session no 1
Saif Ullah Dar
 
Session no 1 html
Session no 1 htmlSession no 1 html
Session no 1 html
Saif Ullah Dar
 
Session no 3 bzu
Session no 3 bzuSession no 3 bzu
Session no 3 bzu
Saif Ullah Dar
 
Session no 2 For BZU
Session no 2 For BZUSession no 2 For BZU
Session no 2 For BZU
Saif Ullah Dar
 
Java script session 4
Java script session 4Java script session 4
Java script session 4
Saif Ullah Dar
 
Xml Session No 1
Xml Session No 1Xml Session No 1
Xml Session No 1
Saif Ullah Dar
 

Recently uploaded (20)

Improving Developer Productivity With DORA, SPACE, and DevEx
Improving Developer Productivity With DORA, SPACE, and DevExImproving Developer Productivity With DORA, SPACE, and DevEx
Improving Developer Productivity With DORA, SPACE, and DevEx
Justin Reock
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
Edge AI and Vision Alliance
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy SurveyTrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyesEnd-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
ThousandEyes
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use CasesDomino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
Jeremy Millul - A Talented Software Developer
Jeremy Millul - A Talented Software DeveloperJeremy Millul - A Talented Software Developer
Jeremy Millul - A Talented Software Developer
Jeremy Millul
 
What is Oracle EPM A Guide to Oracle EPM Cloud Everything You Need to Know
What is Oracle EPM A Guide to Oracle EPM Cloud Everything You Need to KnowWhat is Oracle EPM A Guide to Oracle EPM Cloud Everything You Need to Know
What is Oracle EPM A Guide to Oracle EPM Cloud Everything You Need to Know
SMACT Works
 
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
Edge AI and Vision Alliance
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training RoadblocksDown the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfHow Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
Introduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUEIntroduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUE
Google Developer Group On Campus European Universities in Egypt
 
LSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection FunctionLSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection Function
Takahiro Harada
 
Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.
hok12341073
 
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdfBoosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
DevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical PodcastDevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical Podcast
Chris Wahl
 
Jira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : IntroductionJira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : Introduction
Ravi Teja
 
GIS and FME: The Foundation to Improve the Locate Process of Utilities
GIS and FME: The Foundation to Improve the Locate Process of UtilitiesGIS and FME: The Foundation to Improve the Locate Process of Utilities
GIS and FME: The Foundation to Improve the Locate Process of Utilities
Safe Software
 
How to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptxHow to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Improving Developer Productivity With DORA, SPACE, and DevEx
Improving Developer Productivity With DORA, SPACE, and DevExImproving Developer Productivity With DORA, SPACE, and DevEx
Improving Developer Productivity With DORA, SPACE, and DevEx
Justin Reock
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
Edge AI and Vision Alliance
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy SurveyTrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyesEnd-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
ThousandEyes
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use CasesDomino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
Jeremy Millul - A Talented Software Developer
Jeremy Millul - A Talented Software DeveloperJeremy Millul - A Talented Software Developer
Jeremy Millul - A Talented Software Developer
Jeremy Millul
 
What is Oracle EPM A Guide to Oracle EPM Cloud Everything You Need to Know
What is Oracle EPM A Guide to Oracle EPM Cloud Everything You Need to KnowWhat is Oracle EPM A Guide to Oracle EPM Cloud Everything You Need to Know
What is Oracle EPM A Guide to Oracle EPM Cloud Everything You Need to Know
SMACT Works
 
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
Edge AI and Vision Alliance
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training RoadblocksDown the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfHow Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
LSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection FunctionLSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection Function
Takahiro Harada
 
Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.
hok12341073
 
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdfBoosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
DevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical PodcastDevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical Podcast
Chris Wahl
 
Jira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : IntroductionJira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : Introduction
Ravi Teja
 
GIS and FME: The Foundation to Improve the Locate Process of Utilities
GIS and FME: The Foundation to Improve the Locate Process of UtilitiesGIS and FME: The Foundation to Improve the Locate Process of Utilities
GIS and FME: The Foundation to Improve the Locate Process of Utilities
Safe Software
 
How to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptxHow to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptx
Version 1 Analytics
 

Java script session 3

  • 1. JAVA SCRIPT SESSION NO 3 11/25/2013 Developed By: Saif Ullah Dar 1
  • 2. SESSION OBJECTIVES 1) Java Script Data Types. 2) Primitive Data Types. 3) Composite Data Types. 4) Trivial Data Types. 5) Java Script Variables. 6) Rules for Declaration of Variables 7) Java Script Keywords. 8) Scope of Variables. 9) Examples 10) Quiz 11/25/2013 Developed By: Saif Ullah Dar 2
  • 3. JAVA SCRIPT DATA TYPES • Data is the information and Data Types means the ways in which we can retrieve the data. • There are two Main types of the Data Types in Java Script Language 1. Primitive Data Types 2. Composite Data Types 11/25/2013 Developed By: Saif Ullah Dar 3
  • 4. JAVA SCRIPT DATA TYPES 11/25/2013 Developed By: Saif Ullah Dar 4
  • 5. PRIMITIVE DATA TYPES • JavaScript has three “primitive” types: number, string, and Boolean • Numbers are always stored as floating-point values • Hexadecimal numbers begin with 0x • Some platforms treat 0123 as octal, others treat it as decimal • Strings may be enclosed in single quotes or double quotes • Strings can contains n (newline), " (double quote), etc. • Booleans are either true or false • 0, "0", empty strings, undefined, null, and NaN are false , other values are true 11/25/2013 Developed By: Saif Ullah Dar 5
  • 7. COMPOSITE DATA TYPES • A composite data type stores a collection of multiple related values, unlike primitive data types. • JavaScript supports a composite data type known as objects, Functions, Arrays • This will be discussed in the next Chapter in details. 11/25/2013 Developed By: Saif Ullah Dar 7
  • 8. NOTE • Java does not make a distinction between integer values and floating-point values. All numbers in JavaScript are represented as floating-point values. JavaScript represents numbers using the 64-bit floating-point format defined by the IEEE 754 standard. 11/25/2013 Developed By: Saif Ullah Dar 8
  • 9. TRIVIAL DATA TYPES JavaScript also defines two trivial data types, null and undefined, each of which defines only a single value. The null keyword specifies that a variable does not hold any value. (the null value is not equal to zero because zero is a calculate value while null refers to the absence of a value) 11/25/2013 Developed By: Saif Ullah Dar 9
  • 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. 11/25/2013 Developed By: Saif Ullah Dar 10
  • 11. DEFINING VARIABLES <script type="text/javascript"> <!– var money; var name; //--> </script> 11/25/2013 <script type="text/javascript"> <!– var money, name; //--> </script> Developed By: Saif Ullah Dar 11
  • 12. RULES TO DEFINED VARIABLES Java Script is a case-sensitive language. These rules are that a variable name: Can consist of digit, underscore, and alphabets. Must begin with a letter or underscore character Cannot begin with a number and cannot contain any punctuation marks. • Cannot contain any kind of special characters such as +,*,%,and so on. • Cannot contain spaces • Cannot be a Java Script keyword • • • • • 11/25/2013 Developed By: Saif Ullah Dar 12
  • 13. VARIABLE INITIALIZATION • Storing a value in a variable is called variable initialization. • You can do variable initialization at the time of variable creation or later point in time when you need that variable. • For instance, you might create a variable named money and assign the value 2000.50 to it later. For another variable you can assign a value the time of initialization as follows: 11/25/2013 <script type="text/javascript"> <!– var name = “Saif Ullah"; var money; money = 2000.50; //--> </script> Developed By: Saif Ullah Dar 13
  • 14. JAVA SCRIPT IMPORTANT HINTS • Use the var keyword only for declaration or initialization. Once for the life of any variable name in a document. You should not re-declare same variable twice. • JavaScript is untyped language. This means that a JavaScript variable can hold a value of any data type. Unlike many other languages, you don't have to tell JavaScript during variable declaration what type of value the variable will hold. The value type of a variable can change during the execution of a program and JavaScript takes care of it automatically. 11/25/2013 Developed By: Saif Ullah Dar 14
  • 15. JAVA SCRIPT KEYWORDS • The following are reserved words in JavaScript. • They cannot be used as JavaScript variables, functions, metho ds, loop labels, or any object names. 11/25/2013 abstract boolean break byte case catch char class const continue debugg er default delete do double Developed By: Saif Ullah Dar else enum export extends false final finally float for function goto if impleme nts import in instance of int interface long native new null package private protecte d public return short static super switch synchroni zed this throw throws transient true try typeof var void volatile while with 15
  • 16. ESCAPE SEQUENCES CHARACTERS  There are multiple escape sequence characters in JavaScript that provides various kind of formatting. 11/25/2013 Developed By: Saif Ullah Dar 16
  • 17. SCOPE OF VARIABLES The scope of a variable is the region of your program in which it is defined. JavaScript variable will have only two scopes. a) Global Variables: A global variable has global scope which means it is defined everywhere in your JavaScript code. b) Local Variables: A local variable will be visible only within a function where it is defined. Function parameters are always local to that function. Within the body of a function, a local variable takes precedence over a global variable with the same name. If you declare a local variable or function parameter with the same name as a global variable, you effectively hide the global variable.
  • 18. EXAMPLE OF DYNAMIC VARIABLES • JavaScript has dynamic types. • This means that the same variable can be used as different types: Example var x; // Now x is undefined var x = 5; // Now x is a Number var x = “Saif Ullah Dar"; // Now x is a String 11/25/2013 Developed By: Saif Ullah Dar 18
  • 19. JAVA SCRIPT STRINGS • A string is a variable which stores a series of characters like “Saif Ullah Dar". • A string can be any text inside quotes. You can use single or double quotes: Example var carname="Volvo XC60"; var carname='Volvo XC60';  You can use quotes inside a string, as long as they don't match the quotes surrounding the string: Example var answer="It's alright"; var answer="He is called ‘Saif'"; var answer='He is called “Mr Dar"'; 11/25/2013 Developed By: Saif Ullah Dar 19
  • 20. JAVASCRIPT NUMBERS • JavaScript has only one type of numbers. • Numbers can be written with, or without decimals: Example var x1=34.00; // Written with decimals var x2=34; // Written without decimals  Extra large or extra small numbers can be written with scientific (exponential) notation: Example var y=123e5; var z=123e-5; 11/25/2013 // 12300000 // 0.00123 Developed By: Saif Ullah Dar 20
  • 21. JAVA SCRIPT BOOLEANS • Booleans can only have two values: true or false. • Booleans are often used in conditional testing. You will learn more about conditional testing in a later chapter of this tutorial. var x=true; var y=false; 11/25/2013 Developed By: Saif Ullah Dar 21
  • 22. <!DOCTYPE html> <html> <body> <script> var firstname; firstname=“Saif"; document.write(firstname); document.write("<br>"); firstname=“Ullah"; document.write(firstname); </script> <p>The script above declares a variable, assigns a value to it, displays the value, changes the value, and displays the value again.</p> <body> </html> 11/25/2013 Developed By: Saif Ullah Dar 22
  • 23. QUIZ:1 Inside which HTML element do we put the JavaScript? (1)<javascript> (2)<js> (3)<script> (4)<scripting> 11/25/2013 Developed By: Saif Ullah Dar 23
  • 24. ANS:1 Inside which HTML element do we put the JavaScript? (1)<javascript> (2)<js> (3)<script> (4)<scripting> 11/25/2013 Developed By: Saif Ullah Dar 24
  • 25. QUIZ:2 What is the correct JavaScript syntax to write "Hello World"? (1)document.write("Hello World"); (2)echo "Hello World"; (3)("Hello World"); (4)response.write("Hello World"); 11/25/2013 Developed By: Saif Ullah Dar 25
  • 26. ANS:2 What is the correct JavaScript syntax to write "Hello World"? (1)document.write("Hello World"); (2)echo "Hello World"; (3)("Hello World"); (4)response.write("Hello World"); 11/25/2013 Developed By: Saif Ullah Dar 26
  • 27. THANK YOU SAIF ULLAH DAR 11/25/2013 Developed By: Saif Ullah Dar 27