N
N
ncoxall2016-09-07 07:25:13
JavaScript
ncoxall, 2016-09-07 07:25:13

How to deep nest classes in javascript?

I used to write like this: (simple example)
var Root = {};
Root Pages = {};
Root.Pages.Home = function(){};
Root.Pages.Reg = function(){};
Root.Pages.Login = function(){};
Now I want to switch to Classes, but I don't understand how to make such an attachment in them... (Root.Pages.Login)
Are there any similar examples?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sugadu, 2016-09-07
@ncoxall

class Polygon {
  constructor() {
    this.height = 11;
    this.width = 22;
  }
}

var myObj = {};
myObj.Polygon = Polygon;

console.log((new myObj.Polygon).height)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question