What does javascript:void(0) mean?

02/14/2022

Contents

In this article, you will learn what javascript:void(0) means.

What does javascript:void(0) mean?

The void operator is an operator that returns “undefined” no matter what value you enter.
So whether it’s void (0), void (123) or void (“ABC”), all the results will be returned as “undefined”.
By convention, void (0) is now used.

And when to use it, use it when you want to disable the operation.
Generally, it has been used when you want to invalidate the screen transition of a tag link.

<a href="javascript:void(0)" onclick="window.open('https://www.google.com/')">Click</a>

These days, this style of writing is not highly recommended.
Also, please note that it may not be available on older browsers.