dsDate2DDMM = function (date) {
date = date instanceof Date ? date : date.Value;
let year = date.getFullYear();
if (year <= 1900) {
return null;
}
let month = date.getMonth() + 1;
let day = date.getDate();
return ((day < 10 ? '0' + day : day) + '/' + (month < 10 ? '0' + month : month));
}
btns = document.getElementsByClassName("saveBtn");
for (var i = 0; i < btns.length; i++) {
btns[i].addEventListener("click", function () {
//Add function here
});
}
var url = "http://scratch99.com/web-development/javascript/";
var urlParts = url.replace('http://','').replace('https://','').split(/[/?#]/);
var domain = urlParts[0];
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;
}
Comments