Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

find and filter

const persons = [
  {name:"Shirshak",gender:"male"},
  {name:"Amelia",gender:"female"},
  {name:"Amand",gender:"male"}
]
//filter return all objects in array
let male = persons.filter(function(person){
return person.gender==='male'
})
console.log(male) //[{name:"Shirshak",gender:"male"},{name:"Amand",gender:"male"}]

//find return first object that match condition
let female = persons.find(function(person){
return person.gender==='female'
})
Comment

PREVIOUS NEXT
Code Example
Javascript :: axios post form data and json 
Javascript :: add two strings javascript 
Javascript :: To get thumbnail image from video file 
Javascript :: javascript format date to dd-mm-yyyy 
Javascript :: javascript anagram two strings 
Javascript :: javascript set variable if not defined 
Javascript :: javascript stop execution 
Javascript :: how to scrape the web with javascript 
Javascript :: Round to at most 2 decimal places 
Javascript :: react current path 
Javascript :: vue js import css from node modules 
Javascript :: js send file as form input 
Javascript :: angular passing data to child component 
Javascript :: how to render react native app under the status bar 
Javascript :: discord.js MessageEmbed 
Javascript :: check if string matches a regex 
Javascript :: disable javascript chrome 
Javascript :: how to check if checkbox is checked in jquery 
Javascript :: javascript variable with multiline text 
Javascript :: tolocalestring format dd-mm-yyyy 
Javascript :: add table row jquery 
Javascript :: what is currying in javascript 
Javascript :: reactsj substring 
Javascript :: create csv file nodejs 
Javascript :: add class with javascript 
Javascript :: run onclick function once js 
Javascript :: create a download file from blob url 
Javascript :: Lazy Loading Routes vue 
Javascript :: jQuery onclick not firing on dynamically inserted HTML elements 
Javascript :: find all voice chanels in category 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =