“super palavra -chave em javascript” Respostas de código

Números sobrescritos de 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étodo de chamada de classe estendida da Super em 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 palavra -chave em 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 () Palavra -chave

// 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

Respostas semelhantes a “super palavra -chave em javascript”

Perguntas semelhantes a “super palavra -chave em javascript”

Mais respostas relacionadas para “super palavra -chave em javascript” em JavaScript

Procure respostas de código populares por idioma

Procurar outros idiomas de código