Credit: Kirk Born (St Sci/NASA)
Elements of JavaScript
We will explain JavaScript mostly through examples. We assume that
you are familiar with "C-like" languages and so will not explain those
elements of the language that are similar to "C". Client-Side JavaScript:
The main components of JavaScript are:
- Expressions and operators: the usual "C-like" with a few
exceptions: "new ", "typeof", and "+" used for
string concatenation
- Statements: the usual "C-like" statements with a few
exceptions: "for (prop in object)...", "with (object)..."
- Strings: declaration, concatenation, length, split,
concatenation with numbers, charAt, substring, indexOf.
See
Test of Strings
- Functions: these differ in many ways from "C-like" languages. See
Functions and Arguments.
for many of the important features of JavaScript functions.
- Arrays: these differ from most other languages. See
Test of Arrays
for many of their features.
JavaScript, like many languages, makes a distinction between value versus
reference, particularly
in terms of copies, comparisons,
and arguments. Basically,
Booleans, numbers, and strings are copied, passed, and compared
by value, where as all others (objects, arrays, and
functions) are copied, passed, and compared by reference.
See
this for some effects of value-versus-reference handling in functions.
|
|
 |
|
 |