我对一些问题感到震惊。
这是我正在尝试的:
我可以做到这一点:
var case = 'toUpperCase()';
'abcd'.case; //output ===> ABCD
用户将通过案例uppercase
或lowercase
function getIndex(obj){
var index = window[String('someGlobalArray')].indexOf(String(obj.name).case);}
var pass = {name:'helper',case:'toUpperCase'};
someGlobalArray = ['HELPER','A','b','C',.......];
getIndex(pass);
这是可能的,通过使用方括号符号来访问函数:
const caseFunction = 'toUpperCase'
const result = 'abcd'[caseFunction]()
console.log(result)
自从我回答以来,您已经编辑了问题,我会看看我是否能理解您的要求
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句