LoginSignup
0
0

More than 3 years have passed since last update.

【JavaScript】JSのオブジェクトの書き方【初心者】

Posted at
index.html
<!DOCTYPE html>
<html lang="ja">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <h1>object更新</h1>

  <script>

    // 定数を設定して配列を代入する
    const person = {
      id: 1,
      name: "suzuki",
      age: 29,
    };

    // 配列の中の名前をtanakaに変更する場合
    person.name = "tanaka";

    // 関数を定義して、コンソールに配列の中身をそれぞれ表示させる処理を書く。
    const write = () => {
      console.log(person.id);
      console.log(person.name);
      console.log(person.age);
    }
    // 実際に関数を実行
    write();

  </script>
</body>
</html>
0
0
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
0