0

I am reading jshint source code and found return void error("E009"); line.

I know void means return nothing in languages such as C and C++. But what does it mean in javascript and how can it be used? Or is it good practice to use it in Javascript?

Boaz
  • 17,982
  • 8
  • 55
  • 62
Om3ga
  • 24,135
  • 40
  • 122
  • 201
  • you can also check this one. http://stackoverflow.com/questions/1291942/what-does-javascriptvoid0-mean – Sumit Pathak Mar 24 '14 at 08:43
  • 1
    Both the linked answers show usage in links, where you don't want the page to change. This usage is similar but different. Compared to "error(x); return void 0;" it saves on 1 line and the braces on the conditional. Compared to "return error(x);" it saves you having to read the code for error() and figuring out that it returns undefined - which, in fact, it does. Neither of these advantages add up to much, it just seems to be this coder's style (he calls the commit just a 'minor refactoring' https://github.com/jshint/jshint/commit/bb04a20796f50ba30498c947f4f9271a03362bde) – bazzargh Mar 24 '14 at 09:37

0 Answers0