Ecmascript E6 features

This section describes the small set of features Duktape borrows from Ecmascript E6. These features are not fully compliant; the intent is to minimize custom features and to align with the ES6 specification when possible.

Const variables

Duktape has minimal support for const declarations to allow existing code using const to run. However, const is mostly just an alias for var and currently has the following non-standard semantics:

Object.setPrototypeOf and Object.prototype.__proto__

Object.setPrototypeOf allows user to set the internal prototype of an object which is not supported in Ecmascript E5. Ecmascript E6 also provides Object.prototype.__proto__, an accessor property (setter/getter) which provides the same functionality but is compatible with existing code base which has relied on a non-standard __proto__ property for a while. Duktape does not support the __proto__ property name in an object initializer.

These custom features can be disabled with the feature options DUK_OPT_NO_ES6_OBJECT_SETPROTOTYPEOF and DUK_OPT_NO_ES6_OBJECT_PROTO_PROPERTY.

Proxy object (subset)

The Ecmascript E6 Proxy object allows property virtualization and fine-grained access control for accessing an underlying plain object. Duktape implements a strict subset of the Proxy object from ES6. The following traps are implemented:

TrapImplementedNotes
getPrototypeOfno
setPrototypeOfno
isExtensibleno
preventExtensionno
getOwnPropertyDescriptorno
definePropertyno
hasyesObject.hasOwnProperty() does not invoke the trap at the moment, key in obj does
getyes
setyes
deletePropertyyes
enumerateyes
ownKeysyesObject.keys() enumerability check limitation, trap result validation (non-configurable properties, non-extensible target) not done
applyno
constructno

Limitations include:

This custom feature can be disabled with the feature option DUK_OPT_NO_ES6_PROXY.

Typed arrays

Duktape implements Khronos typed array support which is a subset of ES6 typed arrays. Support for typed arrays and Node.js Buffer can be disabled with the feature option DUK_OPT_NO_BUFFEROBJECT_SUPPORT.