another approach is to create a function that checks if the param is
undefined and store a reference to it on to the local scope for brevity.. in
many cases it will be clearer (specially if you have multiple calls)..

function isDef(param){
  //return typeof param !== 'undefined'; //if you prefer not to use
`void(0)`
  return param !== void(0);
}

then check:

if(isDef(foo)){
  alert(foo);
}

instead of:

if(foo !== void(0)){
  alert(foo);
}

if you use google closure compiler it will inline the calls to `isDef()` so
there is no excuse about performance being worse or anything like that..

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