in JavaScript by
What is a void operator in Javascript?

1 Answer

0 votes
by

The void operator evaluates the given expression and then returns undefined(i.e, without returning value). The syntax would be as below,

void expression;
void expression;

Let's display a message without any redirection or reload

<a href="javascript:void(alert('Welcome to JS world'))">
  Click here to see a message
</a>

Note: This operator is often used to obtain the undefined primitive value, using "void(0)".

...