JavaScript
- 23 ответа
- 0 вопросов
21
Вклад в тег
function startAfter (delay, callback) {
const elapsed = Date.now() - performance.timing.navigationStart
if (elapsed >= delay) {
callback()
} else {
setTimeout(callback, delay - elapsed)
}
}
document.addEventListener("DOMContentLoaded", () => {
startAfter(2000, () => console.log("DOM fully loaded and parsed"))
})
function addTodo (key, value) {
localStorage.setItem(key, localStorage.getItem(key) + value))
}
function addTodo (key, index, value) {
localStorage.setItem(`${key}${index}`, value)
}
function addTodo (key, value) {
let list = []
try {
list = JSON.parse(localStorage.getItem(key))
} catch (e) {
console.error(e)
}
list.push(value)
localStorage.setItem(key, JSON.stringify(list))
}
img.onload = counter++;
img.onerror = counter++;