SlideShare ist ein Scribd-Unternehmen logo
1 von 10
JavaScript
Variables
Charles Russell
Bennu Bird Media
Statement and
Expressions
●
A Statement requests an action.
●
An Expression sets a value.
●
Variables are used in both
●
They are passed into functions and used to control
branching and iteration
●
They can be the target of the expression or the value
of the expression
– In computer books you may see L value and R Value when
referring to expressions
So What are they
●
A variable a just a place to put things you want to
use later. A good anology would be a box
●
In JavaScript anything can go into a box
●
In this language the boxes are a little magical
– Boxes can resize themselves to hold anything you put in
them.
– Dumping from one box into another makes what was
already the box you are dumping into vanish
Labeling the Boxes
●
To name a variable just type a name and set a
value. You will not only named it you have
created and sized it.
●
var myVariable=“Some really cool stuff“;
– Note the var while not required leaving it off has some
implications that we will get into later
●
Another word for name is identifier and in computer
books it is more common to use identifier.
●
In general you can use any name you want, but
there are a few rules
Whats in a name
●
In Javascript a name must begin with a letter _ or
$
●
Names beginning with _ are generally used by
the system
●
Names beginning with $ are commonly used by
libraries
●
After the first character you can use as many
letters and numbers $ and _ as you want after
that
●
Name are case sensitive Name and name are not
Forbiden Names
●
Use of these words as names will cause an error
abstract debugger final instanceof protected throws
boolean default finally int public transient
break delete float interface return true
byte do for let short try
case double function long static typeof
catch else goto native super var
char enum if new switch void
class export implements null synchronized volatile
const extends import package this while
continue false in private throw with
Names with Baggage
●
Some names are used by Javascript
implementations and while legal should be
avoided. A partial list is below for more go to
http://www.javascripter.net/faq/reserved.htm
alert clearInterval decodeURIComponent
all clearTimeout defaultStatus
anchor clientInformation document
anchors close element
area closed elements
Array confirm embed
assign constructor embeds
blur crypto encodeURI
button Date encodeURIComponent
checkbox decodeURI escape
Weak Typing
●
JavaScript is a weakly typed language
●
This does not mean that it is type unaware
●
This means that you do not have to declare the
type of the variable
Summary
●
Variables are used in statements and expressions
●
The are just a way to store things for later use
●
There are rules to names
●
You cant use reserved words as names
●
Some legal names are not a good Idea
●
Java Script is a weekly typed language
Next Datatypes

Weitere ähnliche Inhalte

Was ist angesagt?

Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
Varun C M
 
JavaScript: Variables and Functions
JavaScript: Variables and FunctionsJavaScript: Variables and Functions
JavaScript: Variables and Functions
Jussi Pohjolainen
 

Was ist angesagt? (20)

JavaScript Data Types
JavaScript Data TypesJavaScript Data Types
JavaScript Data Types
 
JavaScript - Chapter 7 - Advanced Functions
 JavaScript - Chapter 7 - Advanced Functions JavaScript - Chapter 7 - Advanced Functions
JavaScript - Chapter 7 - Advanced Functions
 
2. Classes | Object Oriented Programming in JavaScript | ES6 | JavaScript
2. Classes | Object Oriented Programming in JavaScript | ES6 | JavaScript2. Classes | Object Oriented Programming in JavaScript | ES6 | JavaScript
2. Classes | Object Oriented Programming in JavaScript | ES6 | JavaScript
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
A Brief Introduction to React.js
A Brief Introduction to React.jsA Brief Introduction to React.js
A Brief Introduction to React.js
 
JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events
 
JavaScript & Dom Manipulation
JavaScript & Dom ManipulationJavaScript & Dom Manipulation
JavaScript & Dom Manipulation
 
Java script
Java scriptJava script
Java script
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
 
Java script errors & exceptions handling
Java script  errors & exceptions handlingJava script  errors & exceptions handling
Java script errors & exceptions handling
 
Javascript
JavascriptJavascript
Javascript
 
JavaScript - Chapter 6 - Basic Functions
 JavaScript - Chapter 6 - Basic Functions JavaScript - Chapter 6 - Basic Functions
JavaScript - Chapter 6 - Basic Functions
 
Javascript
JavascriptJavascript
Javascript
 
Java script basics
Java script basicsJava script basics
Java script basics
 
JavaScript: Variables and Functions
JavaScript: Variables and FunctionsJavaScript: Variables and Functions
JavaScript: Variables and Functions
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An Introduction
 
JavaScript Basic
JavaScript BasicJavaScript Basic
JavaScript Basic
 
Javascript
JavascriptJavascript
Javascript
 
Object Oriented Javascript
Object Oriented JavascriptObject Oriented Javascript
Object Oriented Javascript
 

Ähnlich wie JavaScript Variables

Douglas Crockford Presentation Goodparts
Douglas Crockford Presentation GoodpartsDouglas Crockford Presentation Goodparts
Douglas Crockford Presentation Goodparts
Ajax Experience 2009
 
Java (1).ppt seminar topics engineering
Java (1).ppt  seminar topics engineeringJava (1).ppt  seminar topics engineering
Java (1).ppt seminar topics engineering
4MU21CS023
 
The Java Script Programming Language
The  Java Script  Programming  LanguageThe  Java Script  Programming  Language
The Java Script Programming Language
zone
 
Javascript by Yahoo
Javascript by YahooJavascript by Yahoo
Javascript by Yahoo
birbal
 
Java script final presentation
Java script final presentationJava script final presentation
Java script final presentation
Adhoura Academy
 

Ähnlich wie JavaScript Variables (20)

Grooming with Groovy
Grooming with GroovyGrooming with Groovy
Grooming with Groovy
 
8 introduction to_java_script
8 introduction to_java_script8 introduction to_java_script
8 introduction to_java_script
 
Learn To Code: Introduction to java
Learn To Code: Introduction to javaLearn To Code: Introduction to java
Learn To Code: Introduction to java
 
Clean Code
Clean CodeClean Code
Clean Code
 
JavaScript Introductin to Functions
JavaScript Introductin to FunctionsJavaScript Introductin to Functions
JavaScript Introductin to Functions
 
Groovy / comparison with java
Groovy / comparison with javaGroovy / comparison with java
Groovy / comparison with java
 
Douglas Crockford Presentation Goodparts
Douglas Crockford Presentation GoodpartsDouglas Crockford Presentation Goodparts
Douglas Crockford Presentation Goodparts
 
Dart programming language
Dart programming languageDart programming language
Dart programming language
 
Writing Readable Code
Writing Readable CodeWriting Readable Code
Writing Readable Code
 
Java (1).ppt seminar topics engineering
Java (1).ppt  seminar topics engineeringJava (1).ppt  seminar topics engineering
Java (1).ppt seminar topics engineering
 
Cp 111 lecture 3
Cp 111 lecture 3Cp 111 lecture 3
Cp 111 lecture 3
 
Computer programing 111 lecture 3
Computer programing 111 lecture 3Computer programing 111 lecture 3
Computer programing 111 lecture 3
 
Modern_2.pptx for java
Modern_2.pptx for java Modern_2.pptx for java
Modern_2.pptx for java
 
Javascript
JavascriptJavascript
Javascript
 
The Java Script Programming Language
The  Java Script  Programming  LanguageThe  Java Script  Programming  Language
The Java Script Programming Language
 
Les origines de Javascript
Les origines de JavascriptLes origines de Javascript
Les origines de Javascript
 
Javascript by Yahoo
Javascript by YahooJavascript by Yahoo
Javascript by Yahoo
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming Language
 
Java script final presentation
Java script final presentationJava script final presentation
Java script final presentation
 
Learning puppet chapter 2
Learning puppet chapter 2Learning puppet chapter 2
Learning puppet chapter 2
 

Mehr von Charles Russell (8)

Js objects
Js objectsJs objects
Js objects
 
JavaScript iteration
JavaScript iterationJavaScript iteration
JavaScript iteration
 
Open Source Software
Open Source SoftwareOpen Source Software
Open Source Software
 
JavaScript Tools and Implementation
JavaScript Tools and ImplementationJavaScript Tools and Implementation
JavaScript Tools and Implementation
 
JavaScript Operators
JavaScript OperatorsJavaScript Operators
JavaScript Operators
 
JavaScript Comments and Conditionals
JavaScript Comments and ConditionalsJavaScript Comments and Conditionals
JavaScript Comments and Conditionals
 
JavaScript Introduction
JavaScript IntroductionJavaScript Introduction
JavaScript Introduction
 
Extending drupal authentication
Extending drupal authenticationExtending drupal authentication
Extending drupal authentication
 

Kürzlich hochgeladen

Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
Call Girls In Delhi Whatsup 9873940964 Enjoy Unlimited Pleasure
 
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
nirzagarg
 
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
@Chandigarh #call #Girls 9053900678 @Call #Girls in @Punjab 9053900678
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
ydyuyu
 

Kürzlich hochgeladen (20)

Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceBusty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
 
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
 
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
 
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
 
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
 
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
 
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
 
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
 
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
 
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls DubaiDubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
 
Real Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtReal Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirt
 
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
 
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
 
Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
Russian Call Girls in %(+971524965298  )#  Call Girls in DubaiRussian Call Girls in %(+971524965298  )#  Call Girls in Dubai
Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
 

JavaScript Variables

  • 2. Statement and Expressions ● A Statement requests an action. ● An Expression sets a value. ● Variables are used in both ● They are passed into functions and used to control branching and iteration ● They can be the target of the expression or the value of the expression – In computer books you may see L value and R Value when referring to expressions
  • 3. So What are they ● A variable a just a place to put things you want to use later. A good anology would be a box ● In JavaScript anything can go into a box ● In this language the boxes are a little magical – Boxes can resize themselves to hold anything you put in them. – Dumping from one box into another makes what was already the box you are dumping into vanish
  • 4. Labeling the Boxes ● To name a variable just type a name and set a value. You will not only named it you have created and sized it. ● var myVariable=“Some really cool stuff“; – Note the var while not required leaving it off has some implications that we will get into later ● Another word for name is identifier and in computer books it is more common to use identifier. ● In general you can use any name you want, but there are a few rules
  • 5. Whats in a name ● In Javascript a name must begin with a letter _ or $ ● Names beginning with _ are generally used by the system ● Names beginning with $ are commonly used by libraries ● After the first character you can use as many letters and numbers $ and _ as you want after that ● Name are case sensitive Name and name are not
  • 6. Forbiden Names ● Use of these words as names will cause an error abstract debugger final instanceof protected throws boolean default finally int public transient break delete float interface return true byte do for let short try case double function long static typeof catch else goto native super var char enum if new switch void class export implements null synchronized volatile const extends import package this while continue false in private throw with
  • 7. Names with Baggage ● Some names are used by Javascript implementations and while legal should be avoided. A partial list is below for more go to http://www.javascripter.net/faq/reserved.htm alert clearInterval decodeURIComponent all clearTimeout defaultStatus anchor clientInformation document anchors close element area closed elements Array confirm embed assign constructor embeds blur crypto encodeURI button Date encodeURIComponent checkbox decodeURI escape
  • 8. Weak Typing ● JavaScript is a weakly typed language ● This does not mean that it is type unaware ● This means that you do not have to declare the type of the variable
  • 9. Summary ● Variables are used in statements and expressions ● The are just a way to store things for later use ● There are rules to names ● You cant use reserved words as names ● Some legal names are not a good Idea ● Java Script is a weekly typed language