javascript - Using void(0) when function doesn't return anything -
why isn't practice put void(0) when function doesn't return explicitly?
function somefunc(a) {   // stuffs   return void(0); }   this when debugging stuffs.
thanks.
since void(0) resolves undefined, question "why isn't idea return undefined function?". using void(0) alternative undefined bad idea, relatively speaking, because it's more complex undefined, , less explicit. our goal programmers make simple, readable code others read , make sense of.
it's bad idea explicitly return undefined function same reason, introduces unnecessary complexity. typeof undefined evaluates undefined. makes writing tests more difficult , gives less insight purpose of function does, say, returning false.
Comments
Post a Comment