Answers for "javascript call class method"

1

javascript call class method

'use strict' 
class Polygon { 
   constructor(height, width) { 
      this.h = height; 
      this.w = width;
   } 
   test() { 
      console.log("The height of the polygon: ", this.h) 
      console.log("The width of the polygon: ",this. w) 
   } 
} 

//creating an instance  
var polyObj = new Polygon(10,20); 
polyObj.test();
Posted by: Guest on March-31-2020
1

javascript classes

let Person = class {
  constructor(firstName, lastName) {
    this.firstName = firstName;
    this.lastName = lastName;
  }
}
Posted by: Guest on May-05-2020

Code answers related to "javascript call class method"

Code answers related to "Javascript"

Browse Popular Code Answers by Language