if (something1 == true) SomeFunction('a:link', 'a:visited', 'a:hover, a:focus, a:active');
在每个元素之后添加*
的聪明方法是什么?这是意思;
else (something2 == true) SomeFunction('a:link *', 'a:visited *', 'a:hover *, a:focus *, a:active *');
答案 0 :(得分:1)
使用ES6:
let args = ['a:link', 'a:visited', 'a:hover', 'a:focus', 'a:active'];
let modifiedArgs = args.map((arg) => arg + ' *');
if (condition) SomeFunction(...args);
else SomeFunction(...modifiedArgs);