Category : settimeout

const sayHello = function () { console.log("hello"); }; sayHello; sayHello(); setTimeout(sayHello, 1000); setTimeout(sayHello(), 1000); I’m a little confused as to why line 5 ‘does nothing’ but also doesn’t throw an error, whereas line 8 runs as expected but line 9 throws the invalid callback error. I’m running this code is Visual Studio Code if it ..

Read more

I was just going through a scenario where I needed to customize a checkbox so that it can be checked and unchecked not instantly, but when some button is clicked. While working on that, I used preventDefault followed by stopPropagation to stop the checkbox from following default behavior and make it check or uncheck conditionally. ..

Read more

I recently coded a project with somewhat complex SVG SMIL multi-animations occurring every 7th second all together, by triggering the animation via: function startMyCustomAnim() { myElement.beginElement(); } window.setInterval( startMyCustomAnim, 7000 ); When doing this, weird things occurred after some time in my SVG, like elements of it disappearing, etc. (the SVG SMIL animation duration is ..

Read more