Javascript Reference Card

ADVERTISEMENT

Addison-Wesley’ s
JavaScript Reference Card
Kathleen M. Goelz and Carol J. Schwartz, Rutgers University
Javascript: A scripting language designed to be integrated
VARIABLES
into HTML code to produce enhanced, dynamic, interac-
Definition: A placeholder for storing data. In JavaScript, a
tive web pages.
declaration statement consists of the reserved word var and
the name (identifier) of one or more variables.
DATA TYPES
Format:
Definition: The classification of values based on the specific
var variable_name
categories in which they are stored.
[var command is used to declare (create) variables]
Primitive Types: String, Boolean, Integer, Floating Point,
Examples:
Null, Void
var myHouseColor
Composite Types: Object, Array, Function. Composite data
var myAddress
types are in separate sections of the code.
var vacation_house, condominium,
primaryResidence
NUMERIC
Rules for Naming Variables:
Integer: Positive or negative numbers with no fractional
1. Variables cannot be reserved words.
parts or decimal places.
2. Variables must begin with a letter or underscore and
Floating Point: Positive or negative numbers that contain a
cannot begin with symbols, numbers, or arithmetic
decimal point or exponential notations.
notations.
String: A sequence of readable characters or text, surround-
3. Spaces cannot be included in a variable name.
ed by single or double quotes.
Hints:
Boolean: The logical values True/False, etc. used to com-
1. Although variables in JavaScript can be used without
pare data or make decisions.
being declared, it is good programming practice to
Null: The variable does not have a value; nothing to report.
declare (initialize), all variables.
Null is not the same as zero, which is a numeric value.
2. Variable names are case sensitive; for example X does
Casting: Moving the contents of a variable of one type to a
not equal x.
variable of a different type. You don’t move the contents to
a different variable; it stays in the same variable but the
data type is changed or “re-cast”.
,! 7 IA3C1-dcahfj! : t; K ; k ; K ; k
ISBN 0-321-32075-1

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education
Go
Page of 6