Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-05-06 13:11:54 +03:00
parent 7cbc64cd3a
commit 314358ac5f

View File

@ -38,16 +38,22 @@ Here is a basic comparison:
_object.js_
```javascript
var L = object.Constructor('L', Array, {
constructor_attr: 'constructor',
method: function(){
return 'constructor'
},
}, {
var A = object.Constructor('A', {
// prototype attribute (inherited)...
attr: 'prototype',
method: function(){
// ...
},
})
var B = object.Constructor('B', A, {
constructor_attr: 'constructor',
constructor_method: function(){
return 'constructor'
},
}, {
get prop(){
return 42 },
@ -58,8 +64,8 @@ var L = object.Constructor('L', Array, {
```
- Clear separation of constructor and `.prototype` data:
- First block (optional) is merged with `L`,
- Second block _is_ the `L.prototype`,
- First block (optional) is merged with `B`,
- Second block _is_ the `B.prototype`,
- no direct way to do "private" definitions.
</td>
@ -67,16 +73,22 @@ var L = object.Constructor('L', Array, {
_ES6_
```javascript
class L extends Array {
static constructor_attr = 'class'
static method(){
return 'class'
}
class A {
// instance attribute (copied)...
attr = 'instance'
method(){
// ...
}
}
class B extends A {
static constructor_attr = 'class'
static constructor_method(){
return 'class'
}
get prop(){
return 42 }
@ -91,6 +103,15 @@ class L extends Array {
- `static` and instance definitions are not ordered,
- `.attr` is copied to every instance
</td>
</tr>
<td>
</td>
<td>
</td>
</tr>
</table>