Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript vererbung Klasse extends super constructor

class Rectangle {
  constructor(height, width) {
    this.name = 'Rectangle';
    this.height = height;
    this.width = width;
  }
  sayName() {
    console.log('Hi, I am a ', this.name + '.');
  }
  get area() {
    return this.height * this.width;
  }
  set area(value) {
    this.height = this.width = Math.sqrt(value);
  }
}

class Square extends Rectangle {
  constructor(length) {
    this.height; // ReferenceError, super needs to be called first!
    
    // Here, it calls the parent class' constructor with lengths
    // provided for the Polygon's width and height
    super(length, length);
    
    // Note: In derived classes, super() must be called before you
    // can use 'this'. Leaving this out will cause a reference error.
    this.name = 'Square';
  }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: cadena promesas javascript 
Javascript :: how to send array to js file in wplms 
Javascript :: javascipt toggle two buttons 
Javascript :: valueof in react native 
Javascript :: checkPalindrome 
Javascript :: get value in maps loop using enzym 
Javascript :: how to pass property component in react enzyme 
Javascript :: what does god expect of me 
Javascript :: paamayim nekudotayim 
Javascript :: [ERROR -]<ng-select {{items}}="cities" 
Javascript :: left_field in jsgrid 
Javascript :: how to set Json node in java 
Javascript :: ejs-multiselect 
Javascript :: tf js change weighs 
Javascript :: vuetify checkbox click firing twice 
Javascript :: how to exclude required files from grunt merge 
Javascript :: isogram 
Javascript :: redblobgames pathfinding 
Javascript :: multimap in javascript 
Javascript :: chrome add bookmark that prefixes text 
Javascript :: vuejs use set to prevent duplicates 
Javascript :: angular specific attributes and locators list 
Javascript :: javascript es6 quizes 
Javascript :: menu open onload problem 
Javascript :: $(document).ready( function(){ $("#titolo").append(" Ciao").FadeIn(1500); } ); 
Javascript :: 4. You want to print the incremental count each time you instantiate a object using new in JS 
Javascript :: what is @ atsign in first of file path nodejs 
Javascript :: how to set input of time type to current time on initialization 
Javascript :: angular browser detector 
Javascript :: querySelector a slot vuejs 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =