JavaScript

JavaScript and Events

JavaScript event handlers
Event Handler What Caused It
onAbort Image loading was interrupted.
onBlur The user moved away from a form element.
onChange The user changed a value in a form element.
onClick The user clicked on a button-like form element.
onError The program had an error when loading an image.
onFocus The user activated a form element.
onLoad The document finished loading.
onMouseOut The mouse moved away from an object.
onMouseOver The mouse moved over an object.
onSubmit The user submitted a form.
onUnLoad The user left the window or frame.

JavaScript and JScript

JavaScript and JScript
JavaScript or JScript Version Browsers Supported
JavaScript 1.0 Netscape Navigator 2.0, Internet Explorer 3.0
JavaScript 1.1 Netscape Navigator 3.0, Internet Explorer 4.0
JavaScript 1.2 Netscape Navigator 4.0–4.05, Internet Explorer 4.0
JavaScript 1.3 Netscape Navigator 4.06–4.7x, Internet Explorer 5.0
JavaScript 1.5 Netscape Navigator 6.0+, Mozilla (open source browser), Internet Explorer 5.5+
JScript 1.0 Internet Explorer 3
JScript 2.0 Internet Explorer 3
JScript 3.0 Internet Explorer 4
JScript 4.0 Internet Explorer 4
JScript 5.0 Internet Explorer 5
JScript 5.5 Internet Explorer 5
JavaScript is supported by Netscape 2, Explorer 3, Opera 3, and all newer versions of these browsers. In addition, HotJava 3 supports JavaScript, as do iCab for the Mac, WebTV, OmniWeb for OS X, QNX Voyager and Konqueror for the Linux KDE environment. NetBox for TV, AWeb and Voyager 3 for Amiga, and SEGA Dreamcast and ANT Fresco on RISC OS also support JavaScript.

Reserved keywords


Reserved keywords
abstract boolean break byte case catch
char class const continue default delete
do double else extends false final
finally float for function goto if
implements import in instanceof int interface
long native new null package private
protected public return short static super
switch synchronized this throw throws transient
true try typeof var void volatile
while with

Data Types

  1. Primitive Data Types
  2. Primitive data types are the simplest building blocks of a program. They are types that can be assigned a single literal value such as the number 5.7, or a string of characters such as "hello". JavaScript supports three core or basic data types:

    • numeric
    • string
    • Boolean
    • In addition to the three core data types, there are two other special types that consist of a single value:

    • null
    • undefined
  3. Composite Data Types

Escape Sequence


Reserved keywords
Escape Sequence What It Represents
\' Single quotation mark
\" Double quotation mark
\t Tab
\n Newline
\r Return
\f Form feed
\b Backspace
\e Escape
\\ Backslash

Variables

Variables are fundamental to all programming languages. They are data items that represent a memory storage location in the computer. Variables are containers that hold data such as numbers and strings. Variables have a name, a type, and a value.

num = 5;           // name is "num", value is 5, type is numeric
friend = "Peter";  // name is "friend", value is "Peter", type is string

How JavaScript converts datatypes

How JavaScript converts datatypes

Variable Assignment     Conversion
var item = 5.5;             Assigned a float
item = 44;                  Converted to integer
item = "Today was bummer";  Converted to string
item = true;                Converted to Boolean
item = null;                Converted to the null value