JavaScript 如何获取class的static方法
作者:
罗坤_23333 | 来源:发表于
2020-07-21 18:11 被阅读0次
getOwnPropertyStatics
function getOwnPropertyStatics(_obj){
const KNOWN_STATICS = {
name: true,
length: true,
prototype: true,
caller: true,
callee: true,
arguments: true,
arity: true
};
let result = [];
let keys = Object.getOwnPropertyNames(_obj);
keys = keys.concat(Object.getOwnPropertySymbols(_obj));
for (let i = 0; i < keys.length; ++i) {
const key = keys[i];
if (!KNOWN_STATICS[key]){
result.push(key)
}
}
return result;
}
参考
本文标题:JavaScript 如何获取class的static方法
本文链接:https://www.haomeiwen.com/subject/kxjwkktx.html
网友评论