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?

More than 3 years have passed since last update.

JavaScriptでオブジェクトのパラメータ指定を省略する

Last updated at Posted at 2021-06-02

例えば、

const setParameter = 1;

const sendParameter = { id: setParameter }

という変数とオブジェクトがまとまったコードがあったとします。

こういったコードは

const id = 1;

const sendParameter = { id };

のように
{ プロパティ名: 値 }
のような書き方を省略することができます。

この書き方はReactやVueなどでよくある

actionMethod(value) {
  const parameter = { value }
  this.vuexMethods(parameter);
}

の状態管理ライブラリ(ReduxやVuex)を使って状態を変更する際に便利だったりします。

0
0
2

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?