'use strict'; { class Post { constructor(text) { this.text = text; this.likeCount = 0; } show() { console.log(`${this.text} - ${this.likeCount}いいね`); } like() { this.likeCount++; this.show(); } } class PpoPost { constructor(text, sponsor) { this.text = text; this.likeCount = 0; this.sponsor = sponsor; } show() { console.log(`${this.text} - ${this.likeCount} likes`); console.log(`... sponsored by ${this.sponsor}`); } like() { this.likeCount++; this.show(); } } const posts = [ new PpoPost('JavaScriptの勉強中'), new PpoPost('プログラミング楽しい!'), // new poPost('3分動画をマスターしよう', 'dotinstol'), ]; posts[2].show(); posts[2].like(); posts[2].like(); posts[2].like(); }