I am playing with native JavaScript and stumbled upon something strange not sure why this is happening. I have plain html button
. All I did is, set the onclick="onclick()"
. When I run it and click on button I see that there's an error in console.
Console:
Uncaught RangeError: Maximum call stack size exceeded
I don't know why this error is coming. I am seeing this for the very first time. Even when I provide definition of onclick
then also the error persists. Can anyone this why this is happening?
console.log(window.onclick);//It logs null
<button onclick="onclick()">Hit me
</button>