mirror of
https://github.com/flynx/object.js.git
synced 2025-10-30 02:50:10 +00:00
docs...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
027ccd8e86
commit
5f85e29f3e
17
README.md
17
README.md
@ -167,7 +167,7 @@ Create a basic constructor...
|
|||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// NOTE: new is optional here...
|
// NOTE: new is optional here...
|
||||||
var A = new object.Constructor('A')
|
var A = new object.Constructor('A', {})
|
||||||
|
|
||||||
var B = object.Constructor('B', A, {})
|
var B = object.Constructor('B', A, {})
|
||||||
|
|
||||||
@ -183,6 +183,12 @@ c instanceof B // -> true
|
|||||||
c instanceof A // -> true
|
c instanceof A // -> true
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Note:**
|
||||||
|
- in `object.Constructor('X', A)` the second argument is used as the
|
||||||
|
_prototype_, to use `A` as a parent constructor add an empty object
|
||||||
|
as a third argument, i.e. 'object.Constructor('X', A, {})'
|
||||||
|
(see: [`Constructor(..)` / `C(..)`](#constructor--c) for more info)
|
||||||
|
|
||||||
|
|
||||||
### Inheritance
|
### Inheritance
|
||||||
```javascript
|
```javascript
|
||||||
@ -626,6 +632,15 @@ The resulting _constructor_ function when called will:
|
|||||||
- call instance's `.__init__(..)` if present.
|
- call instance's `.__init__(..)` if present.
|
||||||
|
|
||||||
|
|
||||||
|
Note that `Constructor(<name>, <prototype>)` is intentionally set as default
|
||||||
|
instead of having the _parent-constructor_ as the last argument, this is
|
||||||
|
done for two reasons:
|
||||||
|
- The main cause to inherit from a constructor is to extend it,
|
||||||
|
- In real code the `Constructor(<name>, <prototype>)` is more common than
|
||||||
|
empty inheritance.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Shorthand to `Constructor(..)`
|
Shorthand to `Constructor(..)`
|
||||||
```
|
```
|
||||||
C(<name>, ..)
|
C(<name>, ..)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user