<div class="ranging-box">
<div id="ranging_1" class="ranging js-ranging">
... еще много дочерних элементов разного типа ...
</div>
<div id="ranging_1" class="ranging js-ranging d-none">
... еще много дочерних элементов разного типа ...
</div>
</div>
<div id="selectorList" class="selector-list">
<a class="selector js-selector-active" href="#ranging_1">Клац</a>
<a class="selector" href="#ranging_2">Клац</a>
</div>
.d-none { display: none; }
document.getElementById('selectorList').addEventListener('click', function(e) {
if(e.target.nodeType === "A") {
var activeSelector = document.querySelector('.js-selector-active');
document.getElementById(e.target.href).className -= " d-none";
document.getElementById(activeSelector.href).className += " d-none";
activeSelector.className -= " js-selector-active";
e.target.className += " js-active-selector";
}
})
function test(arr, callback) {
return "New value: " + arr.map(callback).join(', ')
}
function callback(el) {
return el.name + ' is ' + el.age
}
test([{age: 45, name: 'John'}, {age: 20, name: 'Aaron'}], callback)
$('#sync1').clone(true).unwrap().appendTo('#sync2');
$('#sync1').clone(true).unwrap().appendTo( $('#sync2').empty() );
var cond = '';
var options = {
'cabel': 'attach a wire',
'router': 'check your router',
'computer': 'reload your MacBook',
'': 'Call Technical Support, Thanks!'
}
console.log(options[cond]);
function logMessage(cond) {
var options = {
'cabel': 'attach a wire',
'router': 'check your router',
'computer': 'reload your MacBook',
'': 'Call Technical Support, Thanks!'
}
console.log(options[cond]);
}
logMessage(''); // Call Technical Support, Thanks!
logMessage('computer'); // reload your MacBook
Treating promises as tasks leads to performance problems, as callbacks may be unnecessarily delayed by task-related things such as rendering. It also causes non-determinism due to interaction with other task sources, and can break interactions with other APIs, but more on that later.
console.log('promise')
выполнится в контексте таска x(в самом его конце, аккурат перед началом выполнения следующего таска), а console.log('timer')
- в котексте таска y.