if (i > 10) {
history.shift();
}localStorage.removeItem(history[0]), то это не удаление нулевого элемента массива, хранящегося в localStorage, а удаление из localStorage свойства с именем, соответствующим значению нулевого элемента массива history.
<div id="quote_text"></div>
<button id="get_quote">Get quote</button>const url = 'https://api.forismatic.com/api/1.0/?method=getQuote&format=jsonp&jsonp=parseQuote&lang=ru&key=';
document.querySelector('#get_quote').addEventListener('click', function() {
const script = document.createElement('script');
script.src = url + (Math.random() * 10e5 | 0);
document.body.append(script);
});
function parseQuote(data) {
document.querySelector('#quote_text').innerHTML = data.quoteText;
}
var
alphabet = 'абвгдеёжзийклмнопрстуфхцчшщъыьэюя',
randomString = '';
while (randomString.length < 6) {
randomString += alphabet[Math.floor(Math.random() * alphabet.length)];
}
console.log(randomString);lenght вместо length (randomSymbol в результате всегда изначально равен 0).; после условия в цикле while, что делало цикл бесконечным.
const classes = {
test1: 'div1',
test2: 'div2'
};
container.innerHTML = response.map(n => `<div class="${classes[n.Title]}"></div>`).join('');
$('.typeahead').typeahead({
minLength: 0,
}, {
name: 'stocks',
displayKey: 'company_name',
source: function(q, sync) {
if (q === '') {
sync(stocks.all());
} else {
stocks.search(q, sync);
}
},
}).on('typeahead:selected', function(event, data) {
$('.typeahead').val(data.code);
});
$("body").on("click", "#mobile-menu a", function() { $wrapper.css({overflow:"auto"}); $("body").removeClass( 'js-nav' ); $( "#slide-out-open" ).removeClass('slide-out-close').addClass('slide-out-open'); return false; });
return false в конце выглядит подозрительным. Что если его вырезать?
промисы же сами по себе асинхронны
Если такой возможности нет, поделитесь ссылками на хорошие календари.
constructor({ closable = true }) {
this.isClosable = closable;
}this.isClosable = props.hasOwnProperty('closable') ? props.closable : true;this.isClosable = props.closable === undefined ? true : props.closable;this.isClosable = typeof props.closable !== 'boolean' || props.closable;
function insert(selector, html, offset) {
var el = document.querySelector(selector);
var text = el.innerText;
el.innerHTML = text.slice(0, offset) + html + text.slice(offset);
}
insert('#text', '<span class="red">###</span>', 15);<div id="text">0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ</div>.red {
color: red;
}
var i = 0;
setInterval(function() {
document.writeln(i++);
}, 666);function xxx(i) {
document.writeln(i);
setTimeout(xxx, 666, i + 1);
}
xxx(0);
function* cyclicSequence(items) {
for (var i = 0; ; i = (i + 1) % items.length) {
yield items[i];
}
}
var color = cyclicSequence([ 'green', 'red', 'blue', 'yellow' ]);
$('#typeProject').click(function() {
$('.typeProject').css('background-color', color.next().value);
});