mirror of https://github.com/svaarala/duktape.git
Sami Vaarala
8 years ago
5 changed files with 23 additions and 142 deletions
@ -1,126 +0,0 @@ |
|||
<h1 id="es6features">Ecmascript 2015 (E6) features</h1> |
|||
|
|||
<p>This section describes the current set of features Duktape implements from |
|||
<a href="http://www.ecma-international.org/ecma-262/6.0/index.html">Ecmascript 2015 (E6)</a>. |
|||
Many of the features can be disabled through config options such as |
|||
<code>DUK_USE_ES6_PROXY</code> and <code>DUK_USE_BUFFEROBJECT_SUPPORT</code>.</p> |
|||
|
|||
<h2 id="es6-regexp-syntax">ES6 Annex B RegExp syntax</h2> |
|||
|
|||
<p>Duktape supports some of the additional RegExp syntax defined in |
|||
<a href="http://www.ecma-international.org/ecma-262/6.0/#sec-regular-expressions-patterns">ES6 Annex B.1.4</a>.</p> |
|||
|
|||
<h2 id="es6-const">Const variables</h2> |
|||
|
|||
<p>Duktape has minimal support for |
|||
<a href="http://www.ecma-international.org/ecma-262/6.0/#sec-let-and-const-declarations">const</a> |
|||
declarations to allow existing code using <code>const</code> to run. However, |
|||
<code>const</code> is mostly just an alias for <code>var</code> and currently has |
|||
the following non-standard semantics:</p> |
|||
<ul> |
|||
<li>Unlike <code>var</code> declarations, <code>const</code> declarations are |
|||
required to have an initializer.</li> |
|||
<li>Const variables are writable. In ES6 <code>const</code> variables are |
|||
not writable.</li> |
|||
<li>Const variables are function scoped and "hoisted" to the top of the |
|||
function like <code>var</code> declarations. In ES6 <code>const</code> |
|||
has block scoping like <code>let</code>.</li> |
|||
</ul> |
|||
|
|||
<h2 id="es6-computed-property-names">Computed property names</h2> |
|||
|
|||
<p>Computed property names are supported and allow syntax like |
|||
<code>{ [1 + 2]: "three" }</code>.</p> |
|||
|
|||
<h2 id="es6-number-literals">Octal and binary number literals</h2> |
|||
|
|||
<p>The <code>0o755</code> and <code>0b10001010</code> literal formats |
|||
are supported. Legacy octal literals like <code>0755</code> are also |
|||
supported.</p> |
|||
|
|||
<h2 id="es6-unicode-escape">\u{H+} escape syntax</h2> |
|||
|
|||
<p>The <code>\u{H+}</code> escape syntax is supported in source code string |
|||
literals and identifier names. Codepoints above non-BMP, for example |
|||
<code>\u{1f4a9}</code>, are decoded into surrogate pairs during parsing. |
|||
RegExps don't yet support this escape format as it requires currently |
|||
unsupported RegExp Unicode mode (<code>/u</code>).</p> |
|||
|
|||
<h2 id="es6-proto">Object.setPrototypeOf and Object.prototype.__proto__</h2> |
|||
|
|||
<p><a href="http://www.ecma-international.org/ecma-262/6.0/index.html#sec-object.setprototypeof">Object.setPrototypeOf</a> |
|||
allows user to set the internal prototype of an object which is not supported in |
|||
Ecmascript E5. Ecmascript E6 also provides |
|||
<a href="http://www.ecma-international.org/ecma-262/6.0/index.html#sec-object.prototype.__proto__">Object.prototype.__proto__</a>, |
|||
an accessor property (setter/getter) which provides the same functionality |
|||
but is compatible with existing code base which has relied on a non-standard |
|||
<code>__proto__</code> property for a while. Duktape does not support the |
|||
<a href="http://www.ecma-international.org/ecma-262/6.0/index.html#sec-__proto__-property-names-in-object-initializers">__proto__ property name in an object initializer</a>.</p> |
|||
|
|||
<h2 id="es6-reflect">Reflect built-in</h2> |
|||
|
|||
<p>The <code>Reflect</code> built-in provides access to several fundamental |
|||
Ecmascript primitives as function calls. For example, <code>Reflect.has()</code> |
|||
works like the <code>in</code> operator, and <code>Reflect.construct()</code> |
|||
is like <code>new</code>. It also serves as a namespace for several functions |
|||
previously exposed through <code>Object</code>, such as |
|||
<code>Reflect.defineProperty()</code>.</p> |
|||
|
|||
<h2 id="es6-proxy">Proxy object (subset)</h2> |
|||
|
|||
<p>The Ecmascript E6 <code>Proxy</code> object allows property virtualization |
|||
and fine-grained access control for accessing an underlying plain object. |
|||
Duktape implements a strict subset of the <code>Proxy</code> object from |
|||
ES6. The following traps are implemented:</p> |
|||
|
|||
<table> |
|||
<thead> |
|||
<tr><th>Trap</th><th>Implemented</th><th>Notes</th></tr> |
|||
</thead> |
|||
<tbody> |
|||
<tr><td class="propname">getPrototypeOf</td><td>no</td><td></td></tr> |
|||
<tr><td class="propname">setPrototypeOf</td><td>no</td><td></td></tr> |
|||
<tr><td class="propname">isExtensible</td><td>no</td><td></td></tr> |
|||
<tr><td class="propname">preventExtension</td><td>no</td><td></td></tr> |
|||
<tr><td class="propname">getOwnPropertyDescriptor</td><td>no</td><td></td></tr> |
|||
<tr><td class="propname">defineProperty</td><td>no</td><td></td></tr> |
|||
<tr><td class="propname">has</td><td>yes</td><td><code>Object.hasOwnProperty()</code> does not invoke the trap at the moment, <code>key in obj</code> does.</td></tr> |
|||
<tr><td class="propname">get</td><td>yes</td><td></td></tr> |
|||
<tr><td class="propname">set</td><td>yes</td><td></td></tr> |
|||
<tr><td class="propname">deleteProperty</td><td>yes</td><td></td></tr> |
|||
<tr><td class="propname">enumerate</td><td>no (*)</td><td>The "enumerate" trap was removed in ES7 and for-in uses "ownKeys" trap; Duktape 1.x supports "enumerate" trap in for-in.</td></tr> |
|||
<tr><td class="propname">ownKeys</td><td>yes</td><td>Some trap result validation (non-configurable properties, non-extensible target) not yet implemented.</td></tr> |
|||
<tr><td class="propname">apply</td><td>no</td><td></td></tr> |
|||
<tr><td class="propname">construct</td><td>no</td><td></td></tr> |
|||
</tbody> |
|||
</table> |
|||
|
|||
<p>Limitations include:</p> |
|||
<ul> |
|||
<li>Only about half of the ES6 traps have been implemented. This causes odd behavior |
|||
if you e.g. call <code>Object.defineProperty()</code> on a proxy object.</li> |
|||
<li>Proxy trap results are not validated, e.g. <code>ownKeys</code> trap result validation |
|||
steps described in <a href="http://www.ecma-international.org/ecma-262/6.0/#sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys">[[OwnPropertyKeys]] ()</a> |
|||
for non-configurable target properties and/or non-extensible target object are not |
|||
yet implemented.</li> |
|||
<li>Proxy revocation feature of ES6 is not supported.</li> |
|||
<li>The target and handler objects given to <code>new Proxy()</code> cannot |
|||
be proxy objects themselves. ES6 poses no such limitation, but Duktape |
|||
enforces it to simplify the internal implementation.</li> |
|||
</ul> |
|||
|
|||
<h2 id="es6-typedarray">Typed arrays</h2> |
|||
|
|||
<p>Duktape implements Khronos typed array support which is a subset of ES6 |
|||
typed arrays.</p> |
|||
|
|||
<h2 id="es6-enum-order">Enumeration order</h2> |
|||
|
|||
<p><code>Object.getOwnPropertyNames()</code> follows the |
|||
<a href="http://www.ecma-international.org/ecma-262/6.0/#sec-ordinary-object-internal-methods-and-internal-slots-ownpropertykeys">ES6 [[OwnPropertyKeys]]</a> |
|||
enumeration order: (1) array indices in ascending order, (2) other properties |
|||
in insertion order, (3) symbols in insertion order. While ES6 or ES7 doesn't |
|||
require it, Duktape follows this same order also for <code>for-in</code>, |
|||
<code>Object.keys()</code>, and <code>duk_enum()</code> in general. As in V8, |
|||
the rule is applied for every "inheritance level" in turn, i.e. inherited |
|||
non-duplicate properties always follow child properties.</p> |
@ -1,10 +0,0 @@ |
|||
<h1 id="es7features">Ecmascript 2016 (E7) features</h1> |
|||
|
|||
<p>This section describes the current set of features Duktape implements from |
|||
<a href="http://www.ecma-international.org/ecma-262/7.0/index.html">Ecmascript 2016 (E7)</a>. |
|||
Some features can be disabled through config options such as |
|||
<code>DUK_USE_ES7_EXP_OPERATOR</code>.</p> |
|||
|
|||
<h2 id="es7-exp-operator">ES7 exponentiation operator (** and **=)</h2> |
|||
|
|||
<p>The <code>**</code> and <code>**=</code> operators are supported.</p> |
@ -0,0 +1,20 @@ |
|||
<a name="es6features"></a> |
|||
<a name="es6-regexp-syntax"></a> |
|||
<a name="es6-const"></a> |
|||
<a name="es6-computed-property-names"></a> |
|||
<a name="es6-number-literals"></a> |
|||
<a name="es6-unicode-escape"></a> |
|||
<a name="es6-proto"></a> |
|||
<a name="es6-reflect"></a> |
|||
<a name="es6-proxy"></a> |
|||
<a name="es6-typedarray"></a> |
|||
<a name="es6-enum-order"></a> |
|||
<a name="es7features"></a> |
|||
<a name="es7-exp-operator"></a> |
|||
|
|||
<h1 id="postes5features">Post-ES5 features</h1> |
|||
|
|||
<p>Duktape implements features from ES2015 (ES6), ES2016 (ES7), and later |
|||
specification drafts. See Wiki article |
|||
<a href="http://wiki.duktape.org/PostEs5Features.html">Post-ES5 features</a> |
|||
for current status.</p> |
Loading…
Reference in new issue