var o={flag:true}; var test=!!o.flag;//equivalent to var test=o.flag||false; alert(test);
Since the ! operator for null and undefined will produce a true result, the effect of using two exclamation marks is that if the value of flag in o is explicitly set (non-null/undefined/0""/equivalent), naturally test will take the same value as o.flag; if not set, test will default to false, not null or undefined.