KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Possible Duplicate: Simplest code for array intersection in javascript Let's say I have arrays: [0,1] and [1,2,3] I need to verify whether these arrays have common elements, for this case it would be 1 Using jQuery i check it following way: 1. get length of 1st array 2. get length of 2nd array 3. merge arrays 4. get length of merged array 5. if lenght of merged array not equal lenghts 2 initial arrays,that they have common elements One line code is: (event2Zone[0].length+event2Zone[1].length)==$.unique($.merge(event2Zone[0].zo,event2Zone[1].zo)).length Is there more standard or gracefull way to do the same operation?
Tags (comma-separated)
Save Edits
Cancel