Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

classes in javascript mdn

class Polygon {
  constructor(...sides) {
    this.sides = sides;
  }
  // Method
  *getSides() {
    for(const side of this.sides){
      yield side;
    }
  }
}

const pentagon = new Polygon(1,2,3,4,5);

console.log([...pentagon.getSides()]); // [1,2,3,4,5]
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to sort an array in js 
Javascript :: how to open cypress 
Javascript :: bind() method 
Javascript :: string to code javascript 
Javascript :: utc clock 
Javascript :: javascript test cases 
Javascript :: big.js 
Javascript :: how to control where the text cursor on div 
Javascript :: airbnb and eslint react native 
Javascript :: web storage api 
Javascript :: discordjs 
Javascript :: map values in range js 
Javascript :: react native image picker 
Javascript :: error: Error: Unable to resolve module `crypto` from `node_modulescrypto-jscore.js`: crypto could not be found within the project. 
Javascript :: req is not defined 
Javascript :: tinymce react 
Javascript :: java script 
Javascript :: express example 
Javascript :: Promise.prototype.finally 
Javascript :: lazy loading by scroll vue 
Javascript :: pass props from child to parent 
Javascript :: how to rerender a page in React when the user clicks the back button 
Javascript :: call javascript function from python 
Javascript :: how to pass props in react 
Javascript :: slice js 
Javascript :: JavaScript ForEach This Argument 
Javascript :: Set an onclick function with a parameter for an element 
Javascript :: javascript static class variable 
Javascript :: how to append an element to an array in javascript 
Javascript :: project to do with javascript 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =