A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/javascript/operators/void below:

void · WebPlatform Docs

void Summary

The void operator evaluates an expression and then returns undefined.

Syntax
void expression
Examples

In this example, void(0) is used to return undefined to the link’s href property, so that the browser will not attempt to load a URL and the function in the onclick event can be executed instead.

<!DOCTYPE html>
<html>
<head>
<title>JavaScript void example</title>
</head>
<body>
<a href="javascript:void(0)" onclick="myFunction()">Click here to execute the function.</a>
</body>
</html>
Remarks

The expression argument is any valid JavaScript expression.

The void operator evaluates its expression and returns undefined. It is useful in situations where an expression should be evaluated but you do not want a result returned to the rest of the script.

Void works only on unary expressions, thus: void x, y; will set only the x variable to undefined.

Notes

void(0) is equivalent to void 0 and returns the undefined value.

Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4