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-05-07

はじめに

関数の引数を使ってオブジェクトの値を取得する方法を綴ります。

実装方法

オブジェクトを用意する

const user = {
  name: '太郎',
  age: 18,
}

関数を用意する

const userValue = (key) => {
  return user[key];
}

これだけです。
user.keyとするとundefinedになってしまうので注意が必要です🤣

0
0
1

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?