親クラスと同じ変数名だと子クラスの値が優先されるという認識でよろしいでしょうか?

それでOKです。
2021年11月22日
ユーザー

本講義の内容で super(text); は、

this.text = text;
this.likeCount = 0;

を継承しているという元、以下のパターンを試してみました。

  1. this.likeCount = 10; を追加した場合、親クラスと同じ変数名だと、子クラスの値が優先されるという認識でよろしいでしょうか。
class SponsoredPost extends Post {
constructor(text, sponsor){
super(text);
this.likeCount = 10;
this.sponsor = sponsor;
}
  1. this.likeCount = likeCount++; を追加してみたところ、likeCount is not defined となりました。この結果がよくわからず、this.likeCount =this.likeCount++; と変更したところ、posts[2].show(); にはlikeCount++ が反映されず 0 likes と表示されました。どの辺の理解ができていないのかご指摘頂けると助かります。
class SponsoredPost extends Post {
constructor(text, sponsor){
super(text);
this.likeCount = likeCount++;
this.sponsor = sponsor;
}
show() {
super.show();
console.log(`... sponsored by ${this.sponsor}`);
}
const posts = [
  new Post('JavaScriptの勉強中…'),
  new Post('プログラミング楽しい!'),
  new SponsoredPost('3分動画でマスターしよう', 'dotinstall'),
];
posts[2].show();

この回答を見るにはプレミアムプランへの登録が必要です

プレミアムプランとは?