getElementsByClassName('.js-date-years')
[flight: true, passengers: true, customer: true, history: true]
const obj = {flight: true, passengers: true, customer: true, history: true}
Object.keys(obj).forEach(key => obj[key] = false)
Правильно ли я предполагаю, что интерпретатор каким-то образом умеет оптимизировать и пропускать такие действия?
И если нет, то почему бы не делать так?
var Human = (function() {
function Human(name) {
this._name = name;
}
Human.prototype.sayName = function() {
alert('My name is ' + this.name);
}
return Human;
})()
class Human {
constructor(name) {
this.name = name;
}
sayName() {
alert('My name is '+ this.name);
}
}
document.querySelector(".p").innerHTML = "<sc" + "ript>document.body.style.backgroundColor = 'white';</sc" + "ript>";
средствами JS?
document.body.innerHTML += arr;
- сбрасывает все обработчики событий. Т.к. innerHTML += something не инкрементирует а заменяет на текущий контент + something. Следовательно ни var input = document.querySelector(".input");
, ни var button = document.querySelector(".button");
уже не существует.<form role="search" id="search" method="get" class="search" action="http://ablethink.ru/">
<input type="text" value="" name="s" class="search-field" placeholder="Поиск">
<img class="search-image" src="http://ablethink.ru/wp-content/themes/ablethink/img/search.svg" style="cursor:pointer; cursor:hand" onclick="search.submit()">
</form>