0
1

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.

オブジェクトについて

Last updated at Posted at 2020-05-29

#オブジェクトとは
値とその名前のセットをひとまとまりとし、それら複数を管理するのに用いられる。
また、その管理においては、それぞれの値に対しプロパティと呼ばれる名前を付ける
{プロパティ1:値1, プロパティ2:値2}

#定数への代入

const menu = {name:"ラーメン", price:500};
console.log(menu)
console.log(menu.name)

#####表示例
{name:"ラーメン",price:500}
ラーメン

#オブジェクトを要素に持つ配列
###配列
配列とは、複数の値(要素)をまとめて管理する際に用いられる。
#####入力例

const taste = ["醤油","味噌",""];
console.log(taste);
console.log(taste[1])

#####表示例
["醤油","味噌","塩"]
味噌

###要素がオブジェクトの時
#####入力例

const ramen = [
{taste:"醤油", price:650},
{taste:"味噌", price:800},
{taste:"", price:750}
];

console.log(ramen[0]);
console.log(ramen[2].price);

#####出力例
{taste:"醤油", price:650}
750

0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?