“Super mot-clé en javascript” Réponses codées

Nombres en exposant 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

Méthode d'appel de classe étendue de super en 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

Super mot-clé en 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

Mot-clé 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

Réponses similaires à “Super mot-clé en javascript”

Questions similaires à “Super mot-clé en javascript”

Plus de réponses similaires à “Super mot-clé en javascript” dans JavaScript

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code