JavaScriptのプロトタイプを深く浅く理解する
オブジェクトはキーと値のペアです。オブジェクトを作成する最も一般的な方法は中括弧{}を使用し、ドット表記法でプロパティとメソッドを追加することです。
let creature = {}
creature.name = 'Rex'
creature.stamina = 10
creature.feed = function (quantity) {
console.log(`${this.name} が食べています。`)
this.stamina += quantity
}
creature.rest = funct ...
6月28日 19:21 投稿