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] すごく初歩のJavaScript (クラス)

Posted at

#JavaScript (クラス)

JavaScript 自分用の覚え書きです。

JavaScriptでのクラスの使用 : コンストラクタ, メソッド, インスタンス

script.js
class Character {
  // コンストラクタ
  constructor(name, level) {
    this.name = name;
    this.level = level;
  }

  // メソッド
  info() {
    console.log(`名前は${this.name}です`);
    console.log(`レベルは${this.level}です`);
  }
}

// インスタンスの生成
const character = new Character("山田", 20);
character.info();
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?