DEV Community

Cover image for Filter function of javascript
Dezina
Dezina

Posted on • Edited on

1

Filter function of javascript

Filter string from array

const myArray = ["1", 1, 2, 3, 4, 5,]
const result = myArray.filter((item) => {
if(typeof(item) === 'string')
        return item;
      });

console.log(result);
Enter fullscreen mode Exit fullscreen mode

Filter array object by another array

let array2 = ['senior web developer', ' React-Native Developer']
let backupInterviews = **[{…}, {…}, {…}, {…}, {…}, {…}, {…}]**
 let filterData = backupInterviews.filter(item => 
          array2.includes(item.desig))

 console.log("filterData", filterData)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay