共计 308 个字符,预计需要花费 1 分钟才能阅读完成。
运算符:
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…
正文完
发表至: javascript
2019-05-23