“Супер ключевое слово в JavaScript” Ответ

Числа суперпидных явов Java

// Java Superscript Numbers
//	Base	Char	Code
	0		⁰		\u2070
	1		¹		\u00B9
	2		²		\u00B2
	3		³		\u00B3
	4		⁴		\u2074
    5		⁵		\u2075
    6		⁶		\u2076
    7		⁷		\u2077
    8		⁸		\u2078
    9		⁹		\u2079
Embarrassed Earthworm

Метод вызова расширенного класса из Super in javascript

// this is how we call method from a super class(i.e MAIN CLASS) to extended class
class Person {
 constructor(name, age) {
  this.name = name;
  this.age = age;
 }
greet() {
  console.log(`Hi, all my name is ${this.name}`);
 }
}

class Employee extends Person {
 constructor(name, age, employer) {
  super(name, age);  // NOTE : super must call before accessing (this)
  this.employer = employer;
 }

 greeting() {
  super.greet();  // this is how we call
  console.log(`I'm working at ${this.employer}`);
 }
}

let Steve = new Employee('Xman', 25 , 'Skynet');
Steve;
Steve.greeting(); // check by consoling MATE
Outlander

Супер ключевое слово в JavaScript

<!DOCTYPE html>
<html>
    <head> </head>
    <body>
        <script>
            class Person {
                constructor(name, age) {
                    this.name = name;
                    this.age = age;
                }
                atWork() {
                    return this.name + " is at work, ";
                }
                atHome() {
                    return this.name + " is at home";
                }
                sleeping() {
                    return this.name + " is sleeping";
                }
            }
            class FashionDesigner extends Person {
                constructor(name, age) {
                    super(name, age);
                }
                profession() {
                    return this.name +
                      " is a Fashion Designer";
                }
                doTasks() {
                    return super.atWork() + this.profession();
                }
            }
            function display(content) {
                console.log(content);
            }
            const character =
            new FashionDesigner("Sayan", 30);
            display(character.profession());
            display(character.atHome());
            display(character.doTasks());
        </script>
    </body>
</html>
Otmane TOUHAMI

JavaScript super () ключевое слово

// parent class
class Person { 
    constructor(name) {
        this.name = name;
    }
    greet() {
        console.log(`Hello ${this.name}`);
    }
}
// inheriting parent class
class Student extends Person {
    constructor(name) {
            console.log("Creating student class");
                // call the super class constructor and pass in the name parameter
        super(name);
    }
}
let student1 = new Student('Jack');
student1.greet();
SAMER SAEID

Ответы похожие на “Супер ключевое слово в JavaScript”

Вопросы похожие на “Супер ключевое слово в JavaScript”

Больше похожих ответов на “Супер ключевое слово в JavaScript” по JavaScript

Смотреть популярные ответы по языку

Смотреть другие языки программирования