0
Why are use the void keyword in JS?
Why are use the void keyword in JS?
The void is an important keyword in JavaScript. which can be used as an operator. which may be any type of data for access. It returns undefined values.
<head>
<script type = 'text/javascript'>
void func(){
javascript:void func()
} // or:
void(func())
javascript:void(func())
</script>
</head>
The most common use of void is in client-side JavaScript URLs. we can not change the page after clicking the link then we can add these void keywords on the click event.
<html>
<head>
<script type = 'text/javascript'>
</script>
</head>
<body>
<p>Click the following, This won't react at all...</p>
<a href = 'javascript:void(alert('Warning !!!'))'>Click me!</a>
</body>
</html>
<html>
<head>
<script type = 'text/javascript'>
</script>
</head>
<body>
<a href = 'javascript:void(0)'>Click me !!!</a>
</body>
</html>