Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

extended class call method from 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
Comment

PREVIOUS NEXT
Code Example
Javascript :: local storage for chrome extension 
Javascript :: js falsy values 
Javascript :: sub array javascript 
Javascript :: how to get css property of div after rendering in react js 
Javascript :: prevent click other tab bootstrap tabs 
Javascript :: getJSON how to set async to false 
Javascript :: jest testing with ResizeObserver 
Javascript :: nestjs 
Javascript :: nodejs heap usage 
Javascript :: uncheck checkbox based on id js 
Javascript :: js loop through function arguments 
Javascript :: get location from brwoser react 
Javascript :: jquery placeholder 
Javascript :: js validation library 
Javascript :: javascript array.contains 
Javascript :: json.stringify 
Javascript :: js select get all options value 
Javascript :: array from string js 
Javascript :: next js redirect if not logged in 
Javascript :: animejs reduce the speed 
Javascript :: react icon 
Javascript :: reactjs date display 
Javascript :: install express generator 
Javascript :: button dropdown not working on datatable search 
Javascript :: javascript quick float to integer 
Javascript :: javascript swap images on mouseover 
Javascript :: search string javascript 
Javascript :: scrollout js 
Javascript :: AngularJS how to use btn-group or radio group in list 
Javascript :: jquery sticky sidebar on scroll 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =