Javascript Void Keyword

Basically in JavaScript it is an unary operator which will be appear before its single operands. This operator defines an expression which will be evaluated without returning a value.

The void keyword is used in a function signature to indicate that the function does not return any value. It takes an expression of any type as its operand and returns undefined. The void(0) function actually returns null and works wonderfully by cancelling the page load.

Example1

<html>
<head>
<title>Javascript Void Keyword Example</title>
</head>
<body>
<form name="myform">
<a href="javascript:void(alert('You ckicked on this hyperlink!'))"/>Click Here!</a>
</form>
</body>
</html>
Try Now

Example2

<html>
<head>
<title>Javascript Void Keyword Example</title>
</head>
<body>
<form name="myform">
<a href="javascript:void(0)">Click Here!</a>
</form>
</body>
</html>
Try Now

Example3

<html>
<head>
<title>Javascript Void Keyword Example</title>
<SCRIPT LANGUAGE="JavaScript">
function generateVal() {
   var num1, num2, num3;
   num1 = void (num2 = 15, num3 = 45);
 document.write('num1 value = ' + num1 + ', num2 value = ' + num2 + ', num3 value =' + num3);
}
</SCRIPT>
</head>
<body>
<form name="myform">
<input id="btnFindVal" type="button" value="Find Value" onclick="generateVal()" />
</form>
</body>
</html>
Try Now

See Also

Javascript Built in String Object
Javascript Built in Number Object
Javascript Built in Math Object
Javascript Built in Date Object
Javascript Built in Arrays Object
Javascript Built in Boolean Object
Javascript Built in RegExp Object
Javascript Built in JSON Object


 
SHARE THIS IF YOU LIKE!
submit to reddit
SUBSCRIBE FOR LATEST UPDATES
HAVE WE CONNECTED ON FACEBOOK?
TOP TUTORIALSTOP CODE EXAMPLESTOP LIVE DEMOLINKSSTAY CONNECTED
HTML Tutorial
HTML5 Tutorial
Bootstrap3 Tutorial
Javascript Tutorial
TypeScript Tutorial
AngularJS Tutorial
CSharp Tutorial
PHP Tutorial
Developer Tools
Javascript
AngularJS
Google MAP API V3
ASP.NET
Javascript
AngularJS
Google MAP API V3
Contact Us
Advertise with Us
Privacy Policy
Disclaimer
Stay connected. We actually like you. If you want to get up to the minute updates, then connect with us on your fav below.
 
Twitter   Linkedin   Facebook   Google+    RSS   Pinterest
 
Protected by Copyscape Original Content Checker
 
 
Copyright ©2017 www.techstrikers.com Unauthorized reproduction/replication of any part of this site is prohibited.