Published
Edited
Sep 22, 2020
Insert cell
Insert cell
{
class Ancestor {
constructor() {
this.prop = 0;
this.prop2 = 2;
}
a1() {
console.log('a1() called');
}
}
class Klass extends Ancestor {
constructor() {
super();
this.prop = 1;
this[Symbol('something')] = 0;
}
m1() {
console.log('m1() called');
}
m2() {
console.log('m2() called');
}
}
const klass = new Klass();
let allProps = new Set();
let current = klass;
do {
Object.getOwnPropertyNames(current).forEach(p => allProps.add(p));
Object.getOwnPropertySymbols(current).forEach(p => allProps.add(p));
current = Object.getPrototypeOf(current);
} while (current != null);
return Array.from(allProps).sort((a, b) => {
if (typeof a === 'symbol' && typeof b === 'symbol') return 0;
if (typeof a === 'symbol') return -1;
if (typeof b === 'symbol') return 1;
if (a < b) return -1;
if (a > b) return 1;
return 0;
});
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more