mirror of
https://github.com/flynx/object.js.git
synced 2025-10-29 18:40:08 +00:00
doc...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
7cbc64cd3a
commit
314358ac5f
53
README.md
53
README.md
@ -38,16 +38,22 @@ Here is a basic comparison:
|
|||||||
|
|
||||||
_object.js_
|
_object.js_
|
||||||
```javascript
|
```javascript
|
||||||
var L = object.Constructor('L', Array, {
|
var A = object.Constructor('A', {
|
||||||
constructor_attr: 'constructor',
|
|
||||||
|
|
||||||
method: function(){
|
|
||||||
return 'constructor'
|
|
||||||
},
|
|
||||||
}, {
|
|
||||||
// prototype attribute (inherited)...
|
// prototype attribute (inherited)...
|
||||||
attr: 'prototype',
|
attr: 'prototype',
|
||||||
|
|
||||||
|
method: function(){
|
||||||
|
// ...
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
var B = object.Constructor('B', A, {
|
||||||
|
constructor_attr: 'constructor',
|
||||||
|
|
||||||
|
constructor_method: function(){
|
||||||
|
return 'constructor'
|
||||||
|
},
|
||||||
|
}, {
|
||||||
get prop(){
|
get prop(){
|
||||||
return 42 },
|
return 42 },
|
||||||
|
|
||||||
@ -58,8 +64,8 @@ var L = object.Constructor('L', Array, {
|
|||||||
```
|
```
|
||||||
|
|
||||||
- Clear separation of constructor and `.prototype` data:
|
- Clear separation of constructor and `.prototype` data:
|
||||||
- First block (optional) is merged with `L`,
|
- First block (optional) is merged with `B`,
|
||||||
- Second block _is_ the `L.prototype`,
|
- Second block _is_ the `B.prototype`,
|
||||||
- no direct way to do "private" definitions.
|
- no direct way to do "private" definitions.
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
@ -67,16 +73,22 @@ var L = object.Constructor('L', Array, {
|
|||||||
|
|
||||||
_ES6_
|
_ES6_
|
||||||
```javascript
|
```javascript
|
||||||
class L extends Array {
|
class A {
|
||||||
static constructor_attr = 'class'
|
|
||||||
|
|
||||||
static method(){
|
|
||||||
return 'class'
|
|
||||||
}
|
|
||||||
|
|
||||||
// instance attribute (copied)...
|
// instance attribute (copied)...
|
||||||
attr = 'instance'
|
attr = 'instance'
|
||||||
|
|
||||||
|
method(){
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class B extends A {
|
||||||
|
static constructor_attr = 'class'
|
||||||
|
|
||||||
|
static constructor_method(){
|
||||||
|
return 'class'
|
||||||
|
}
|
||||||
|
|
||||||
get prop(){
|
get prop(){
|
||||||
return 42 }
|
return 42 }
|
||||||
|
|
||||||
@ -91,6 +103,15 @@ class L extends Array {
|
|||||||
- `static` and instance definitions are not ordered,
|
- `static` and instance definitions are not ordered,
|
||||||
- `.attr` is copied to every instance
|
- `.attr` is copied to every instance
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<td>
|
||||||
|
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user