Погрузитесь с прототипами, чтобы лучше понять, как они работают. Я не могу понять, почему я не могу вызвать hideHeader, тогда как я могу получить доступ к переменной (this.header.el)
function App() {
this.init();
this.el = document.getElementById('box');
}
App.prototype.init = function () {
document.write('hello world');
this.header = new Header();
this.header.hideHeader();
this.header.el.style.display = 'none';
};
new App();
function Header() {
this.el = document.getElementById('header');
}
Header.prototype.hideHeader = function() {
this.el.style.display = 'none';
}