JavaScript --- Find out the specified condition data from json array

Description of the problem: the json array to find out the predetermined condition satisfies the specified data.

Solution: [filter ()]

var employeesData = [
  { name: "王小明", mobile: "13900008789" },
  { name: "陈霞", mobile: "13900008789" },
  { name: "张悦", mobile: "13900008789" }
]

var queryData = employeesData.filter(function(fp) {
  return fp.name === "王小明"
})
console.log(queryData)

 

Published 147 original articles · won praise 33 · views 30000 +

Guess you like

Origin blog.csdn.net/maidu_xbd/article/details/103189801