angularjs:dynamic key:value pair作为函数的参数

时间:2017-10-18 07:11:26

标签: javascript angularjs

我有一个动态的键值对。

myObj = { 
    category1: ["a","b","c"], 
    category2: ["a","d","e"],
    category3: ["a","f","g"],
    ...
    ..
    .
}

我需要将交叉值视为“a”。为此,我使用下划线js _.intersection()功能

根据动态类别,我需要将动态参数传递给_.intersection()

喜欢

_.intersection(myObj[category1], myObj[category2], ..., ..., myObj[categoryN]);

1 个答案:

答案 0 :(得分:3)

尝试:

_.intersection.apply(_, Object.values(myObj));