jList: listIntersection

Examples of the listIntersection function from the jList library.

by tsongas

HTML

<script src="https://rawgithub.com/tsongas/jList/master/jlist-min.js"></script>
<div id="output"></div>

CSS

#output {font-size: 30px;}

JavaScript

// listIntersection: Gets the elements that are common to each of two different lists.


var o = document.getElementById('output');


o.innerHTML += '1. ' + jList.listIntersection('elem1,elem2', 'elem2,elem3') + '<br>';

o.innerHTML += '2. ' + jList.listIntersection('', 'elem1,elem2') + '<br>';

o.innerHTML += '3. ' + jList.listIntersection('elem1,elem2', '') + '<br>';

o.innerHTML += '4. ' + jList.listIntersection('cat-dog-mouse','cat-rabbit-dog-rabbit-hamster','-');