var preloader = document.getElementById("loading");
var body = document.querySelector("body");
var html = document.querySelector("html");
document.addEventListener("DOMContentLoaded", function () {
setTimeout(function loader() {
preloader.style.display = "none";
body.classList.remove("no-scroll-y");
body.classList.add("no-scroll-x");
html.classList.add("no-scroll-x");
}, 1500);
});
btns = document.getElementsByClassName("saveBtn");
for (var i = 0; i < btns.length; i++) {
btns[i].addEventListener("click", function () {
//Add function here
});
}
const isRequired = () => { throw new Error('param is required'); };
const hello = (name = isRequired()) => { console.log(`hello ${name}`) };
// These will throw errors
hello();
hello(undefined);
// These will not
hello(null);
hello('David');
The idea here is that it uses default parameters, like how the b parameter here has a default if you don’t send it anything:
function multiply(a, b = 1) {
return a * b;
}
var specifiedElement = document.getElementById(%27a%27);
//I%27m using "click" but it works with any event
document.addEventListener(%27click%27, function(event) {
var isClickInside = specifiedElement.contains(event.target);
if (!isClickInside) {
//the click was outside the specifiedElement, do something
}
});
Comments