This shows the execution order given JavaScript's Call Stack, Event Loop, and any asynchronous APIs provided in the JS execution environment (in this example; Web APIs in a Browser environment)
Given the code
const sessionStorageData = JSON.parse(sessionStorage.getItem("indexSelectedFilters")) || []; | |
for (let i = 0; i < sessionStorageData.length; i++){ | |
const value = sessionStorageData[i]; | |
const checkbox = document.querySelector(`#${value}`); | |
if (checkbox) { | |
checkbox.checked = true; | |
} | |
} |
let form = document.querySelector('#wf-form-Search-Bar'); | |
let submitButton = document.querySelector('#form-button'); | |
const selectedFilters = sessionStorage.getItem('indexSelectedFilters'); | |
let tempSelectedFilters; | |
if (selectedFilters === null) { | |
sessionStorage.setItem('indexSelectedFilters', ''); | |
tempSelectedFilters = []; | |
} else { | |
tempSelectedFilters = JSON.parse(selectedFilters); | |
} |
console.log('hello simon') | |
document.addEventListener("DOMContentLoaded", () => { | |
// 🍪 on init check the monto cookie | |
function getCookieValue(name) { | |
const regex = new RegExp(`(^| )${name}=([^;]+)`); | |
const match = document.cookie.match(regex); | |
if (match) { | |
return match[2]; |
https://l55hw2.csb.app/ds |