简体   繁体   中英

Javascript : Pulling date from array of objects and comparing it

Lets say I have a array with users like this

const users = [
  {
    id: 1,
    first_name: 'Urbain',
    last_name: 'Pluvier',
    gender: 'Male',
    avatar:
      'https://robohash.org/voluptasaccusantiumfugit.png?size=50x50&set=set1',
    dob: '1996-01-18 02:44:17',
  }

How can i pull out 'dob' (date of birth) from it if i want to compare it to the other date to find out if that person is an adult.

users[i].dob // where i is the index of the array's element

of you can get an array of dobs only with.map if that helps you in any way i dunno

users.map(it => it.dob)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM