136
110

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 5 years have passed since last update.

【javascript】オブジェクトにプロパティを追加する

Posted at

オブジェクトにプロパティを追加する方法です。

var user = {
  id: 1,
  name: "name",
};

user.country = "Japan";
user["language"] = "jp";

console.log("user", user);

// user Object {id: 1, name: "name", country: "Japan", language: "jp"}

オブジェクト.プロパティに値を入れる、もしくは、オブジェクト["プロパティ"]に値を入れることで、オブジェクトにプロパティを追加することができます。

136
110
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
136
110

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?