运算符:
let firstProperty = {
foo: 'abc',
bar: 123
}::getPropertyByIndex(0);
function getPropertyByIndex(index) {
let keys = Object.keys(this);
let key = keys[index];
return this[key];
}
或者 getter:
Object.defineProperty(Object.prototype, ‘properties’, {
get() {
return Object
.keys(this)
.map(key => this[key]);
}
});
https://www.jianshu.com/p/575…