feige
2024-11-10 b075e99a05e05649d24ed59a74cae29fc3192875
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
var inherits = require('./inherits.js')
var assert = require('assert')
 
function test(c) {
  assert(c.constructor === Child)
  assert(c.constructor.super_ === Parent)
  assert(Object.getPrototypeOf(c) === Child.prototype)
  assert(Object.getPrototypeOf(Object.getPrototypeOf(c)) === Parent.prototype)
  assert(c instanceof Child)
  assert(c instanceof Parent)
}
 
function Child() {
  Parent.call(this)
  test(this)
}
 
function Parent() {}
 
inherits(Child, Parent)
 
var c = new Child
test(c)
 
console.log('ok')