On Jan 10, 11:48 am, Fran <m...@fran.ie> wrote:
> Hi there,
>
> I have a couple question:
>
> Why does "void(any_input)" return "undefined" ?

Because void is an operator that always returns undefined for any
valid input

> Why does "typeof void" throw an exception ?

Because void needs an argument. void is not a function in the normal
sense.

> 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.


To add another use case where void can be useful:

var myValue = doSomeTest ? someValue    :
                        anotherTest  ? anotherValue :
                        void 0;   //otherwise I don't care, but I have
to put something here
                                     //for it to be valid syntax and I
don't want a dummy value

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com

Reply via email to