Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80522 views
1
var inherits = require('./inherits.js')
2
var assert = require('assert')
3
4
function test(c) {
5
assert(c.constructor === Child)
6
assert(c.constructor.super_ === Parent)
7
assert(Object.getPrototypeOf(c) === Child.prototype)
8
assert(Object.getPrototypeOf(Object.getPrototypeOf(c)) === Parent.prototype)
9
assert(c instanceof Child)
10
assert(c instanceof Parent)
11
}
12
13
function Child() {
14
Parent.call(this)
15
test(this)
16
}
17
18
function Parent() {}
19
20
inherits(Child, Parent)
21
22
var c = new Child
23
test(c)
24
25
console.log('ok')
26
27