JavaScriptメモ:ES6 Class(承継)サンプルコード

class Bags {
  constructor(options) {
    this.type = options.type;
  }
  discount(){
    return "No discounts";
  }

}

const bags = new Bags({type: "raffia"});
bags
bags.discount();

 

class Bags {
  constructor(options) {
    this.type = options.type;
  }
  discount(){
    return "No discounts";
  }

}


class Gnome extends Bags {
  constructor(options) {
    super(options);
    this.color = options.color;
  }
  country() {
    return "Singapore";

  }
}

const gnome = new Gnome({color: "red", type: "leather"});
gnome;
gnome.country();
gnome.discount();

 

 

 

 

About TIER

TIERは、Global、DX、HRの3軸により 大手企業から中小企業、民間企業から行政まで、海外展開に必要なサービスをワンストップで支援しております。海外マーケティングセールスからデジタルマーケティング、多言語サイトや越境ECサイト制作等の海外向けクリエイティブ制作、グローバル人材採用支援まで幅広く対応しております。お気軽にお問い合わせください。

Check Also

python

Pythonメモ:Pathlibのサンプルコード

■ 特定フォルダの中身を一覧取 …