Teste
8/13/04
11:41 AM
Page 1
Addison-Wesley’s
JavaScript Reference Card
Kathleen M. Goelz and Carol J. Schwartz, Rutgers University
Javascript: A scripting language designed to be integrated into HTML code to produce enhanced, dynamic, interactive web pages.
DATA TYPES
Definition: The classification of values based on the specific categories in which they are stored.
Primitive Types: String, Boolean, Integer, Floating Point,
Null, Void
Composite Types: Object, Array, Function. Composite data types are in separate sections of the code.
NUMERIC
Integer: Positive or negative numbers with no fractional parts or decimal places.
Floating Point: Positive or negative numbers that contain a decimal point or exponential notations.
String: A sequence of readable characters or text, surrounded by single or double quotes.
Boolean: The logical values True/False, etc. used to compare data or make decisions.
Null: The variable does not have a value; nothing to report.
Null is not the same as zero, which is a numeric value.
Casting: Moving the contents of a variable of one type to a 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”.
VARIABLES
Definition: A placeholder for storing data. In JavaScript, a declaration statement consists of the reserved word var and the name (identifier) of one or more variables.
Format:
var variable_name
[var command is used to declare (create) variables]
Examples:
var myHouseColor var myAddress var vacation_house, condominium, primaryResidence Rules for Naming Variables:
1. Variables cannot be reserved words.
2. Variables must begin with a letter or underscore and cannot begin with symbols, numbers, or arithmetic notations. 3. Spaces cannot be included in a variable name.
Hints:
1. Although variables in JavaScript can be used without being declared, it is good