0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

オブジェクトの一つだけ抜き出したいマン

Last updated at Posted at 2024-04-01

オブジェクト配列の欲しい一つだけ抜き出したいメーン

ほいさ、こんな感じ

const hogeList = [
  {
    name: "saburo",
    number: "3",
  },
  {
    name: "ziro",
    number: "2",
  },
  {
    name: "taro",
    number: "1",
  },
]


const newArray = hogeList.filter(value => {
  return value.name === "taro"
})

console.log(newArray)

しかも新しい配列として用意できる

もちのろんで変数も渡して比較できる
多分もっと色々できる(見てる感じいっぱい条件つけていろんなことしてる)

前も使ったのに忘れて毎度調べてしまう、、、、トリ頭や、、、、🐔

なのでメモ投稿

追記
今回の大切な知識、実務で使いそうなこと
・オブジェクトのkeyを指定し、それに対して検索ができること
・検索結果は一つのレコード?まとまりで取れること

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?