0

I have a key value pair which is dynamic.

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

I need to get intersection value as "a". For that I'm using underscore js's _.intersection() function

Depending on dynamic categories, I need to pass dynamic arguments to _.intersection()

like

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

1 Answer 1

3

Try:

_.intersection.apply(_, Object.values(myObj));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.