Testing a Media field for content

Is there a way to test a media field for the presence (or absence) of content?

if ( mediafield )
{
     // do something
}

yields:

Invalid JavaScript value of Type [B