Pls what could void keyword be mainly use for in JavaScript | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Pls what could void keyword be mainly use for in JavaScript

Void keyword

9th Jul 2019, 11:04 PM
Nwankwo Valentine
Nwankwo Valentine - avatar
2 Answers
+ 6
Thanks to Google! This might help you 👇 https://www.quackit.com/javascript/tutorial/javascript_void_0.cfm What Does JavaScript Void(0) Mean? - Quackit Tutorials
9th Jul 2019, 11:16 PM
KingDaniel2004
KingDaniel2004 - avatar
+ 1
The void operator evaluates the given expression and then returns undefined. If you have pass 0 as the unary expression operand to the void operator, JavaScript coerces 0 to "false" and returns, but void doesn't care and simply returns undefined, which means "do nothing" . Put them together and you have composed a way to programmatically "do nothing" when a link is clicked. JavaScript Void(0) is often used when, inserting an expression into a web page may produce an unwanted side-effect. More examples on JavaScript void(0): http://net-informations.com/js/iq/void.htm
10th Feb 2020, 9:54 AM
rahul kumar
rahul kumar - avatar