LoginSignup
0
0

More than 3 years have passed since last update.

コンストラクター関数とは

Last updated at Posted at 2020-12-10

一言で言うと、新しくオブジェクトを作成するための雛形
Q.どういう時に使うの? 
A.テンプレート化されたオブジェクトを生成する時に使う。

●要点

Person.prototype.hello = function() {
console.log('hello' + this.name);
}

const bob = new Person('Bob', '18');
const tom = new person('Tom', '38');

中身

Pearson { name: "Bob", age: 18 }
Pearson { name: "Tom", age: 38 }

コンストラクタ関数の呼び出し方

bob.hello();

0
0
1

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