Chapter 1. Introduction to JavaScript
JavaScript is an interpreted programming language with
object-oriented (OO) capabilities. Syntactically, the core JavaScript
language resembles C, C++, and Java, with programming constructs such as the if statement, the while loop, and the && operator. The similarity ends with
this syntactic resemblance, however. JavaScript is a loosely typed
language, which means that variables do not need to have a type specified.
Objects in JavaScript map property names to arbitrary property values. In
this way, they are more like hash tables or associative arrays (in Perl)
than they are like structs (in C) or objects (in C++ or Java). The OO inheritance mechanism of JavaScript is prototype-based like that of the
little-known language Self. This is quite different from inheritance in
C++ and Java. Like Perl, JavaScript is an interpreted language, and it
draws inspiration from Perl in a number of areas, such as its
regular-expression and array-handling features.
The core JavaScript language supports numbers, strings, and Boolean values as primitive datatypes. It also includes built-in support for array, date, and regular-expression objects.
JavaScript is most commonly used in web browsers, and, in that context, the general-purpose core is extended with objects that allow scripts to interact with the user, control the web browser, and alter the document content that appears within the web browser window. This embedded version of JavaScript runs scripts embedded ...