>>It has no decent practical use I can think of.

It allows you to evaluate an expression but not be beholden to its
return value - this is occasionally useful for conditional
operations.

See this reply by Brendan Eich himself to one of my blog posts :-)
http://javascriptweblog.wordpress.com/2010/10/11/rethinking-javascript-for-loops/#comment-806

  for (var i=arr.length, r=0; i-- || void (r = r*x); r += arr[i]);


On Jan 10, 9:56 am, Tim Down <[email protected]> wrote:
> On 10 January 2011 17:48, Fran <[email protected]> wrote:
>
> > Hi there,
>
> > I have a couple question:
>
> > Why does "void(any_input)" return "undefined" ?
> > Why does "typeof void" throw an exception ?
> > What is "void" for or what use can I give to it ?
>
> > I'm quite curious about this reserved word and I'd like to know more about
> > it and if it has any interesting use.
> n
> > Thanks in advance.
>
> 1. `void` is a unary operator. It is defined to return `undefined`,
> regardless of operand.
> 2. `void` is an operator and therefore not a valid operand for the
> `typeof` operator.
> 3. See 1. It has no decent practical use I can think of.
>
> Tim

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to