LoginSignup
2
1

More than 5 years have passed since last update.

ECMAScript Classes の継承関係の確認

Posted at
const assert = require('assert');

class Super {}
class Sub extends Super {}
class SubSub extends Sub {}

assert.strictEqual(Sub.prototype instanceof Super, true);
assert.strictEqual(SubSub.prototype instanceof Super, true);

assert.strictEqual(Super.prototype instanceof Sub, false);
assert.strictEqual(SubSub.prototype instanceof Sub, true);

assert.strictEqual(Super.prototype instanceof SubSub, false);
assert.strictEqual(Sub.prototype instanceof SubSub, false);
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1