function intersection(...arrays) { let result = arrays.shift(); // let func = arrays.pop(); let len = arrays.length >>> 0; for (let i = result.length - 1; i >= 0; i--) { for (const array of arrays) { if (array.indexOf(result[i]) === -1) { result.splice(i, 1) } } } return result; } console.log(intersection([2, 1, 3], [4, 2, 3], [1, 3, 2]))