Home >Web Front-end >JS Tutorial >Explanation of the specific meaning of void(0) in JavaScript_Basic knowledge

Explanation of the specific meaning of void(0) in JavaScript_Basic knowledge

WBOY
WBOYOriginal
2016-05-16 19:18:451088browse

void is an operator in JavaScript that specifies to evaluate an expression but does not return a value.

void operator usage format is as follows:
1. javascript:void (expression)
2. javascript:void expression

expression is a JavaScript standard expression to be calculated . The parentheses outside the expression are optional, but it is a good practice to write them. (Implementation version Navigator 3.0 )

You can use the void operator to specify a hyperlink. The expression is evaluated but nothing is loaded into the current document.

The following code creates a hyperlink that does nothing when the user clicks on it. When the user clicks the link, void(0) evaluates to 0, but has no effect on JavaScript.

Click here and nothing will happen

The code below creates a hyperlink that when clicked by the user will submit the form.