University of Sydney_INFO1003_Foundamental of IT_2012 Semester 2
26/08/2012
Variables Variables are used to store a value for your program. Declaring a variable- You can create a variable with the var keyword: yvar total= 100;
- You can also create a variable without the var statement:total= 200; (less preferred!!)
Examples: p<script>var i= 10; var s=“Testing”;</script>
9
JavaScript Data TypesTypeNumbers
DescriptionAre values that can be processed and calculated. You don't don t enclose them in quotation marks. The numbers can be either positive or negative. They can also be integers or floating point. Series of letters and numbers enclosed In Single or double quotation marks. You'll use strings for text you want displayed or values you want passed along. true or false
Examplevar I= 17; var j= 21; var k= -10.005;
Strings
var a=“Hello”; var b=‘goodbye’;
Boolea
n Null is an empty value. Not the same as 0 or“” null is the absence of any value.
var c= true; var d= false; var x= null;
Unlike Java or other programming languages, you do not need to explicitly declare the data type in JavaScript.10