1The void operator evaluates the given expression and then returns undefined.
2
3The void operator is often used merely to obtain the undefined primitive value,
4usually using “void(0)” (which is equivalent to “void 0”). In these cases,
5the global variable undefined can be used instead (assuming it has not been
6assigned to a non-default value).
7
8An explanation is provided here: void operator.
9
10The reason you’d want to do this with the href of a link is that normally,
11a javascript: URL will redirect the browser to a plain text version of the
12result of evaluating that JavaScript. But if the result is undefined,
13then the browser stays on the same page. void(0) is just a short and
14simple script that evaluates to undefined.
1The void operator evaluates the given expression and then returns undefined.
2
3The void operator is often used merely to obtain the undefined primitive value,
4usually using “void(0)” (which is equivalent to “void 0”). In these cases,
5the global variable undefined can be used instead (assuming it has not been
6assigned to a non-default value).
7
8An explanation is provided here: void operator.
9
10The reason you’d want to do this with the href of a link is that normally,
11a javascript: URL will redirect the browser to a plain text version
12of the result of evaluating that JavaScript. But if the result is undefined,
13then the browser stays on the same page. void(0) is just a short and
14simple script that evaluates to undefined.