logo
Search
showing results for - "classes in javascript mdn"
Callen
25 Feb 2016
1class Polygon {
2  constructor(...sides) {
3    this.sides = sides;
4  }
5  // Method
6  *getSides() {
7    for(const side of this.sides){
8      yield side;
9    }
10  }
11}
12
13const pentagon = new Polygon(1,2,3,4,5);
14
15console.log([...pentagon.getSides()]); // [1,2,3,4,5]
16
source
similar questions
how to create a class javascriptjavascript new function as classjavascript create element with classjavascript classesclass keyword es6create element javascript with classclasses in es6javascript class methodshow to create object in javascript with classjavascript es6 classjs create element with classjavascript classjavascript create classjavascript class exampleget methods of class javascriptclass in javascriptcreate a class variable jsclass javascriptjs classjs css class
queries leading to this page
mdn javascript classesmdn js classmdn classmdn class jscreate class js mdnjs classes mdnmdn javascript classjavascript class mdnclasses in javascript mdn
privacy policyterms of useinstagram
Crafted with  ♥  for everyone

sign in to continue
your answer for
you will get a confirmation link on this - you will have to click that for successful submission of your answer. we require this to keep the website free of spam, bots and unhelpful content
please ensure to add code which is syntactically corrent and executes properly
sign in to continue
ask question on maxinterview
you will get a confirmation link on this - you will have to click that for successful submission of your question. we require this to keep the website free of spam, bots and unhelpful content
please be clear, to the point and respectful
sign in to continue