2
2

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のお勉強

Last updated at Posted at 2018-03-03

#オブジェクトとは
配列と同じようにグループ化された値.
配列とは違い,名前(プロパティ名)と値がペアになっているのが特徴

#例文

object.js
    var user = {  //オブジェクトの設定
      mail: "example1@mail.com",
      score: 80,
      apeal: function(name){  //メソッド
        console.log("Hi! I'm " + name + "from " + this.mail);
      }
    };

    console.log(user["mail"]);
    //添字にプロパティ名をいれることでそこにアクセスできます
    user.score = 100;
    console.log(user.score);
    //このような方法で値を変えることもできる
    user.apeal("Tom");

#実行結果
image.png
わかりやすい

#考察
ソースコードをかなり見やすくできる.
webサービスを作るにあたってデータ管理がしやすそう.

#最後に
JavaScriptがもともと用意しているオブジェクトもある.
引用:オブジェクトの利用

2
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?