- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the easiest code for array intersection in JavaScript?
For array intersection, you can try to run the following code in JavaScript −
Example
<html> <body> <script> let intersection = function(x, y) { x = new Set(x), y = new Set(y); return [...x].filter(k => y.has(k)); }; document.write(intersection([5,7,4,8], [3,9,8,4,3])); </script> </body> </html>
Advertisements