Answer the question
In order to leave comments, you need to log in
How to competently organize JS code in OOP style separated by files?
I can't fully understand the structure of how OOP code should act in order to access the parent properties of a constructor. It is not clear where to create and call objects.
Let's say I have two classes, this is `app` - my main class, `map` - a class with a map, which is a child of the class `app`
I have the following class code `app`
class App {
constructor() {
this.app = document.querySelector('#city');
}
init() {
}
}
const app = new App();
app.init();
export default function () {
return App;
}
import App from '../index.js'; //забираю мой класс
class Map extends App {
constructor() {
super();
console.log(this.app); //здесь почему то приходит undefined??
}
// ... my metods
}
Answer the question
In order to leave comments, you need to log in
JS is far from Java and OOP in it is so-so. See how it is implemented in frameworks, like Angular is well known to everyone, I personally liked EmberJS - it has a good manual.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question