diff --git a/README.md b/README.md index ecd48eb..f1381d2 100644 --- a/README.md +++ b/README.md @@ -461,33 +461,17 @@ c["key"] === undefined ### Subclassable Built-ins In ES6, built-ins like `Array`, `Date` and DOM `Element`s can be subclassed. -Object construction for a function named `Ctor` now uses two-phases (both virtually dispatched): -- Call `Ctor[@@create]` to allocate the object, installing any special behavior -- Invoke constructor on new instance to initialize - -The known `@@create` symbol is available via `Symbol.create`. Built-ins now expose their `@@create` explicitly. - ```JavaScript -// Pseudo-code of Array -class Array { - constructor(...args) { /* ... */ } - static [Symbol.create]() { - // Install special [[DefineOwnProperty]] - // to magically update 'length' - } -} - -// User code of Array subclass +// Array subclass class MyArray extends Array { constructor(...args) { super(...args); } } -// Two-phase 'new': -// 1) Call @@create to allocate object -// 2) Invoke constructor on new instance var arr = new MyArray(); arr[1] = 12; -arr.length == 2 +arr.length == 2; + +Array.isArray(arr); // true ``` ### Math + Number + String + Object APIs