SlideShare ist ein Scribd-Unternehmen logo
1 von 27
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

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction to Javascript programming
Introduction to Javascript programmingIntroduction to Javascript programming
Introduction to Javascript programmingFulvio Corno
 
Java Script An Introduction By HWA
Java Script An Introduction By HWAJava Script An Introduction By HWA
Java Script An Introduction By HWAEmma Wood
 
JavaScript Jump Start 20220214
JavaScript Jump Start 20220214JavaScript Jump Start 20220214
JavaScript Jump Start 20220214Haim Michael
 
Introduction to java_script
Introduction to java_scriptIntroduction to java_script
Introduction to java_scriptBasavaraj Hampali
 
JavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScriptJavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScriptLaurence Svekis ✔
 
Javascript
JavascriptJavascript
JavascriptNagarajan
 
JavaScript - Chapter 3 - Introduction
 JavaScript - Chapter 3 - Introduction JavaScript - Chapter 3 - Introduction
JavaScript - Chapter 3 - IntroductionWebStackAcademy
 
Introduction to Javascript By Satyen
Introduction to Javascript By  SatyenIntroduction to Javascript By  Satyen
Introduction to Javascript By SatyenSatyen 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 JavaScriptMarlon Jamera
 
From User Action to Framework Reaction
From User Action to Framework ReactionFrom User Action to Framework Reaction
From User Action to Framework Reactionjbandi
 
[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 JSIvano Malavolta
 
Introduction To JavaScript
Introduction To JavaScriptIntroduction To JavaScript
Introduction To JavaScriptReema
 

Was ist angesagt? (20)

Javascript
JavascriptJavascript
Javascript
 
Introduction to Javascript programming
Introduction to Javascript programmingIntroduction to Javascript programming
Introduction to Javascript programming
 
Java Script An Introduction By HWA
Java Script An Introduction By HWAJava Script An Introduction By HWA
Java Script An Introduction By HWA
 
JavaScript Jump Start 20220214
JavaScript Jump Start 20220214JavaScript Jump Start 20220214
JavaScript Jump Start 20220214
 
Introduction to java_script
Introduction to java_scriptIntroduction to java_script
Introduction to java_script
 
JavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScriptJavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScript
 
Javascript
JavascriptJavascript
Javascript
 
Wt unit 6 ppts web services
Wt unit 6 ppts web servicesWt unit 6 ppts web services
Wt unit 6 ppts web services
 
JavaScript - Chapter 3 - Introduction
 JavaScript - Chapter 3 - Introduction JavaScript - Chapter 3 - Introduction
JavaScript - Chapter 3 - Introduction
 
Introduction to Javascript By Satyen
Introduction to Javascript By  SatyenIntroduction to Javascript By  Satyen
Introduction to Javascript By Satyen
 
Node.js Crash Course (Jump Start)
Node.js Crash Course (Jump Start) Node.js Crash Course (Jump Start)
Node.js Crash Course (Jump Start)
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Java script
Java scriptJava script
Java script
 
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
 
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
 
From User Action to Framework Reaction
From User Action to Framework ReactionFrom User Action to Framework Reaction
From User Action to Framework Reaction
 
[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
 
Javascript
JavascriptJavascript
Javascript
 
Introduction To JavaScript
Introduction To JavaScriptIntroduction To JavaScript
Introduction To JavaScript
 
Java script
Java scriptJava script
Java script
 

Andere mochten auch

C programming session 09
C programming session 09C programming session 09
C programming session 09Dushmanta Nath
 
C programming session 11
C programming session 11C programming session 11
C programming session 11Dushmanta Nath
 
C programming session 07
C programming session 07C programming session 07
C programming session 07Dushmanta Nath
 
C programming session 03
C programming session 03C programming session 03
C programming session 03Dushmanta Nath
 
C programming session 04
C programming session 04C programming session 04
C programming session 04Dushmanta Nath
 
C programming session 02
C programming session 02C programming session 02
C programming session 02Dushmanta Nath
 
C programming session 05
C programming session 05C programming session 05
C programming session 05Dushmanta Nath
 
C programming session 08
C programming session 08C programming session 08
C programming session 08Dushmanta Nath
 
C programming session 01
C programming session 01C programming session 01
C programming session 01Dushmanta 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 ScriptFahim Abdullah
 
Session 3 Java Script
Session 3 Java ScriptSession 3 Java Script
Session 3 Java ScriptMuhammad Hesham
 
C language (Collected By Dushmanta)
C language  (Collected By Dushmanta)C language  (Collected By Dushmanta)
C language (Collected By Dushmanta)Dushmanta Nath
 

Andere mochten auch (15)

Session No1
Session No1 Session No1
Session No1
 
Session no 4
Session no 4Session no 4
Session no 4
 
C programming session 09
C programming session 09C programming session 09
C programming session 09
 
C programming session 11
C programming session 11C programming session 11
C programming session 11
 
Session no 2
Session no 2Session no 2
Session no 2
 
C programming session 07
C programming session 07C programming session 07
C programming session 07
 
C programming session 03
C programming session 03C programming session 03
C programming session 03
 
C programming session 04
C programming session 04C programming session 04
C programming session 04
 
C programming session 02
C programming session 02C programming session 02
C programming session 02
 
C programming session 05
C programming session 05C programming session 05
C programming session 05
 
C programming session 08
C programming session 08C programming session 08
C programming session 08
 
C programming session 01
C programming session 01C programming session 01
C programming session 01
 
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
 
Session 3 Java Script
Session 3 Java ScriptSession 3 Java Script
Session 3 Java Script
 
C language (Collected By Dushmanta)
C language  (Collected By Dushmanta)C language  (Collected By Dushmanta)
C language (Collected By Dushmanta)
 

Ähnlich wie Java script session 3

WT Unit-3 PPT.pptx
WT Unit-3 PPT.pptxWT Unit-3 PPT.pptx
WT Unit-3 PPT.pptxTusharTikia
 
Js datatypes
Js datatypesJs datatypes
Js datatypesSireesh K
 
JavaScript
JavaScriptJavaScript
JavaScriptBIT DURG
 
javascript client side scripting la.pptx
javascript client side scripting la.pptxjavascript client side scripting la.pptx
javascript client side scripting la.pptxlekhacce
 
Final Java-script.pptx
Final Java-script.pptxFinal Java-script.pptx
Final Java-script.pptxAlkanthiSomesh
 
JavaScript Comprehensive Overview
JavaScript Comprehensive OverviewJavaScript Comprehensive Overview
JavaScript Comprehensive OverviewMohamed Loey
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScriptAndres Baravalle
 
Java script
Java scriptJava script
Java scriptGowriLatha1
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to javarishi ram khanal
 
JavaScript New Tutorial Class XI and XII.pptx
JavaScript New Tutorial Class XI and XII.pptxJavaScript New Tutorial Class XI and XII.pptx
JavaScript New Tutorial Class XI and XII.pptxrish15r890
 
Java Script
Java ScriptJava Script
Java ScriptSarvan15
 
Java Script
Java ScriptJava Script
Java ScriptSarvan15
 
Introduction to Scala JS
Introduction to Scala JSIntroduction to Scala JS
Introduction to Scala JSKnoldus Inc.
 
WTA-MODULE-4.pptx
WTA-MODULE-4.pptxWTA-MODULE-4.pptx
WTA-MODULE-4.pptxChayapathiAR
 
Oop java Concept
Oop java ConceptOop java Concept
Oop java ConceptTanvir Ahmed
 
JavaScript for ABAP Programmers - 2/7 Data Types
JavaScript for ABAP Programmers - 2/7 Data TypesJavaScript for ABAP Programmers - 2/7 Data Types
JavaScript for ABAP Programmers - 2/7 Data TypesChris Whealy
 

Ähnlich wie Java script session 3 (20)

WT Unit-3 PPT.pptx
WT Unit-3 PPT.pptxWT Unit-3 PPT.pptx
WT Unit-3 PPT.pptx
 
Js datatypes
Js datatypesJs datatypes
Js datatypes
 
Java script basics
Java script basicsJava script basics
Java script basics
 
Lecture7
Lecture7Lecture7
Lecture7
 
JavaScript
JavaScriptJavaScript
JavaScript
 
javascript client side scripting la.pptx
javascript client side scripting la.pptxjavascript client side scripting la.pptx
javascript client side scripting la.pptx
 
Java script
Java scriptJava script
Java script
 
Final Java-script.pptx
Final Java-script.pptxFinal Java-script.pptx
Final Java-script.pptx
 
JavaScript Comprehensive Overview
JavaScript Comprehensive OverviewJavaScript Comprehensive Overview
JavaScript Comprehensive Overview
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Java script
Java scriptJava script
Java script
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
js.pptx
js.pptxjs.pptx
js.pptx
 
JavaScript New Tutorial Class XI and XII.pptx
JavaScript New Tutorial Class XI and XII.pptxJavaScript New Tutorial Class XI and XII.pptx
JavaScript New Tutorial Class XI and XII.pptx
 
Java Script
Java ScriptJava Script
Java Script
 
Java Script
Java ScriptJava Script
Java Script
 
Introduction to Scala JS
Introduction to Scala JSIntroduction to Scala JS
Introduction to Scala JS
 
WTA-MODULE-4.pptx
WTA-MODULE-4.pptxWTA-MODULE-4.pptx
WTA-MODULE-4.pptx
 
Oop java Concept
Oop java ConceptOop java Concept
Oop java Concept
 
JavaScript for ABAP Programmers - 2/7 Data Types
JavaScript for ABAP Programmers - 2/7 Data TypesJavaScript for ABAP Programmers - 2/7 Data Types
JavaScript for ABAP Programmers - 2/7 Data Types
 

Mehr von Saif Ullah Dar

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

Mehr von Saif Ullah Dar (7)

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

KĂźrzlich hochgeladen

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

KĂźrzlich hochgeladen (20)

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

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