DEV Community

Cover image for Filter function of javascript
Dezina
Dezina

Posted on • Updated on

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)