The following features are common to all conforming ECMAScript implementations, unless explicitly specified otherwise.
Imperative and structured
- dynamic typing
- As in most scripting languages, types are associated with values, not variables. For example, a variable
- object based
obj.x = 10and
obj["x"] = 10are equivalent, the dot notation being syntactic sugar. Properties and their values can be added, changed, or deleted at run-time. Most properties of an object (and those on its prototype inheritance chain) can be enumerated using a
- run-time evaluation
- first-class functions
- Functions are first-class; they are objects themselves. As such, they have properties and can be passed around and interacted with like any other object.
- inner functions and closures
- functions as object constructors
- Functions double as object constructors along with their typical role. Prefixing a function call with
newcreates a new object and calls that function with its local
thiskeyword bound to that object for that invocation. The constructor’s
Array, also have prototypes that can be modified.
- functions as methods
- Unlike many object-oriented languages, there is no distinction between a function definition and a method definition. Rather, the distinction occurs during function calling; a function can be called as a method. When a function is called as a method of an object, the function’s local
thiskeyword is bound to that object for that invocation.
- run-time environment
- variadic functions
- An indefinite number of parameters can be passed to a function. The function can access them through formal parameters and also through the local
- array and object literals
- Like many scripting languages, arrays and objects (associative arrays in other languages) can each be created with a succinct shortcut syntax. In fact, these literals form the basis of the JSON data format.
- regular expressions
- property getter and setter functions (also supported by WebKit, Opera, ActionScript, and Rhino)
- iterator protocol adopted from Python
- shallow generators/coroutines also adopted from Python
- array comprehensions and generator expressions also adopted from Python
- proper block scope via new
- array and object destructuring (limited form of pattern matching)
- concise function expressions (