Why does the code at this JS fiddle not work? I want it to log a blank string, but it’s logging a Pointer Event.
https://jsfiddle.net/wvom7k2f/
let c = document.getElementById('c');
c.onclick = test;
function test(a='', b=''){
console.log(a);
}
>Solution :
An onclick event handler will put the event as the first parameter. If you want to call test with no parameters you should change c.onclick = test; to the following:
c.onclick = () => test();