This section describes the small set of features Duktape borrows from the current ES6 draft ("Version: Rev 24, April 27, 2014 Draft"). These features are not fully compliant; the intent is to minimize custom features and to align with the coming ES6 specification.
Object.setPrototypeOf
allows user to set the internal prototype of an object which is not supported in
Ecmascript E5. The Ecmascript E6 draft 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
.
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 the
ES6 draft (Rev 24). The following traps are implemented:
Trap | Implemented | Notes |
---|---|---|
getPrototypeOf | no | |
setPrototypeOf | no | |
isExtensible | no | |
preventExtension | no | |
getOwnPropertyDescriptor | no | |
defineProperty | no | |
has | yes | Object.hasOwnProperty() does not invoke the trap at the moment, key in obj does |
get | yes | |
set | yes | |
deleteProperty | yes | |
enumerate | yes | |
ownKeys | yes | Object.keys() enumerability check limitation |
apply | no | |
construct | no |
Limitations include:
Object.defineProperty()
on a proxy object.Object.keys()
invokes the ownKeys
trap, cleans up the trap
result to a gap-free string list, but does not check that the property names returned
by the trap are enumerable. Object.keys()
and Object.getOwnPropertyNames()
thus currently return the same value for a proxy object implementing the ownKeys
trap.new Proxy()
cannot
be proxy objects themselves. ES6 poses no such limitation, but Duktape
enforces it to simplify the internal implementation.This custom feature can be disabled with the feature option
DUK_OPT_NO_ES6_PROXY
.