JavaScript - Part 3

JavaScript - Part 3 - CIS 4004: Web Based Information...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
CIS 4004: JavaScript – Part 3 Page 1 © Dr. Mark Llewellyn CIS 4004: Web Based Information Technology Spring 2011 Introduction To JavaScript – Part 3 Department of Electrical Engineering and Computer Science University of Central Florida Instructor : Dr. Mark Llewellyn markl@cs.ucf.edu HEC 236, 407-823-2790 http://www.cs.ucf.edu/courses/cis4004/spr2011
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CIS 4004: JavaScript – Part 3 Page 2 © Dr. Mark Llewellyn The values a program stores in computer memory are called variables . Technically speaking, a variable is actually a specific address in the computer memory. The data stored in a variable often changes. Think of a variable like a book bag or back pack. You can put any book you want in the bag and retrieve it later for use. The books in your bag this semester will probably not be the same ones in your bag next semester. Many programming languages, such as Java and C++ have a very large set of rules that apply to variables. JavaScript is very loose in how variables can be used. More JavaScript - Variables
Background image of page 2
CIS 4004: JavaScript – Part 3 Page 3 © Dr. Mark Llewellyn The name you assign to a variable is called an identifier . Although technically different, you can use the terms variable and identifier interchangeably. JavaScript defines the following rules for naming a variable: Identifiers must begin with an uppercase or lowercase ASCII letter, dollar sign ($) or underscore(_). (Older browsers will not accept $.) Numbers can appear in the identifier, but not as the first character. No spaces are allowed in the identifier. You cannot use any reserved word as an identifier (see page 5.) Naming Variables
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CIS 4004: JavaScript – Part 3 Page 4 © Dr. Mark Llewellyn Some examples: Valid identifiers: Angela, num1, _newt, $amount, debi Invalid identifiers: Didi Thurau, 16_Nov, *69 Variable names should be descriptive not cryptic. Convention dictates that variable names begin with a lowercase letter and each additional word in the identifier begins with an uppercase letter. Some examples of conventional variable names are: productDate, myLastName, birthDate, and myLastLapTime . Naming Variables
Background image of page 4
CIS 4004: JavaScript – Part 3 Page 5 © Dr. Mark Llewellyn Reserved Words In JavaScript abstract else instanceof switch boolean enum int synchronized break export interface this byte extends long throw case false native throws catch final new transient char finally null true class float package try const for private typeof continue function protected var debugger goto public void default if return volatile delete implements short while do import static with double in super
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CIS 4004: JavaScript – Part 3 Page 6 © Dr. Mark Llewellyn Before you can use a variable, you need to declare it (basically it means create it). While there are different techniques to create variables, we’ll stick with the most common and simplest form which uses the reserved word var . For example, to create a variable named
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 38

JavaScript - Part 3 - CIS 4004: Web Based Information...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online