describes the new features in the 1.5 release.
chapter contains the following sections:
is Netscape's cross-platform, object-oriented scripting language.
standalone language, but is designed for easy embedding in other products
and applications, such as web browsers. Inside a host environment,
programmatic control over them.
and a core set of language elements such as operators, control
variety of purposes by supplementing it with additional objects;
Java objects and access their public methods and fields. From Java, you
language by supplying objects to control a browser (Navigator or
another web browser) and its Document Object Model (DOM). For
example, client-side extensions allow an application to place
elements on an HTML form and respond to user events such as mouse
clicks, form input, and page navigation.
server. For example, server-side extensions allow an application to
communicate with a relational database, provide continuity of
information from one invocation to another of the application, or
perform file manipulations on a server.
and Java are similar in some ways but fundamentally different in others.
syntax and basic control-flow constructs.
contrast to Java's compile-time system of classes built by
number of data types representing numeric, Boolean, and string values.
common class-based object model. The prototype-based model provides
dynamic inheritance; that is, what is inherited can vary for individual
declarative requirements. Functions can be properties of objects,
executing as loosely typed methods.
is a very free-form language compared to Java. You do not have to
declare all variables, classes, and methods. You do not have to be
concerned with whether methods are public, private, or protected, and
you do not have to implement interfaces. Variables, parameters, and
function return types are not explicitly typed.
Java is a
class-based programming language designed for fast execution and type
safety. Type safety means, for instance, that you can't cast a Java
integer into an object reference or access private memory by corrupting
Java bytecodes. Java's class-based model means that programs consist
exclusively of classes and their methods. Java's class inheritance and
strong typing generally require tightly coupled object hierarchies.
dynamically typed languages such as HyperTalk and dBASE. These
scripting languages offer programming tools to a much wider audience
because of their easier syntax, specialized built-in functionality, and
minimal requirements for object creation.
Object-oriented. No distinction between
types of objects. Inheritance is through the prototype
mechanism, and properties and methods can be added to any
Class-based. Objects are divided into
classes and instances with all inheritance through the class
hierarchy. Classes and instances cannot have properties or
methods added dynamically.
Variable data types not declared (dynamic
Variable data types must be declared
Cannot automatically write to hard disk.
Cannot automatically write to hard disk.
Chapter 8, "Details of the Object
and the ECMA Specification
browsers. However, Netscape is working with ECMA (European Computer Manufacturers
Association) to deliver a standardized, international programming
association for information and communication systems. This
way in all applications that support the standard. Companies can use
the open standard language to develop their implementation of
ECMA-262 standard is also approved by the ISO (International Organization for
Standards) as ISO-16262. You can find a PDF version of ECMA-262here. You can also find the
on the ECMA Web site. The ECMA specification does not describe the
Document Object Model (DOM), which is standardized by the
World Wide Web Consortium (W3C).
The DOM defines the way in which HTML document objects are exposed
to your script.
works closely with ECMA to produce the ECMA specification. The
Relationship to ECMA version
ECMA-262, Edition 1 is based on
ECMA-262 was not complete when
fully compatible with ECMA-262, Edition 1, for the following
Netscape developed additional
ECMA-262 adds two new features:
internationalization using Unicode, and uniform behavior
across all platforms. Several features of
were platform-dependent and used platform-specific
with ECMA-262, Edition 1.
while keeping all the additional features of
conform with ECMA-262.
with ECMA-262, Edition 1.
The third version of the ECMA
with ECMA-262, Edition 3.
ECMA-262, Edition 2 consisted of minor editorial changes and bug
fixes to the Edition 1 specification. The TC39 working group of
ECMA is currently working on ECMAScript Edition 4, which will
language are ECMA-compliant.
with ECMA, while providing additional features.
ECMA specification is a set of requirements for implementing
ECMAScript; it is useful if you want to determine whether a
may need to review the ECMA specification.
ECMA document is not intended to help script programmers; use the
and ECMA Terminology
ECMA specification uses terminology and syntax that may be
the language may differ in ECMA, the language itself remains the
The global object is not discussed in the
methods and properties of the global object, which you do use,
top-level functions and properties.
The no parameter (zero-argument)
constructor with the Number and
what is generated is of little use. A Number constructor
without an argument returns +0, and a String constructor
without an argument returns "" (an empty string).
New Features in this Release
new features and enhancements:
Runtime errors. Runtime errors are
now reported as exceptions.
Number formatting enhancements.
Number formatting has been enhanced to include Number.prototype.toExponential,
methods. See page 109.
Regular expression enhancements. The
following regular expression enhancements have been added:
Quantifiers — +,
can now be followed by a ? to force
them to be non-greedy. See the entry for ? on
can be used instead of capturing parentheses(x). When
non-capturing parentheses are used, matched
subexpressions are not available as back-references. See
the entry for (?:x) on
negative lookahead assertions are supported. Both assert a
match depending on what follows the string being matched. See
the entries for x(?=y) and
The m flag has been
added to specify that the regular expression should match
over multiple lines. See page 63.
Conditional function declarations.
Functions can now be declared inside an if clause. See
Function expressions. Functions can now be
declared inside an expression. See page 85.
clauses. Multiple catch clauses in a
statement are supported. See page 80.
writers can now add getters and setters to their objects. This
See page 98.
Constants. Read only named constants
are supported. This feature is available only in the C