// This is OK. document === undefined ? document.writeln("==") : document.writeln("!="); // Some bad guy did this.. undefined = document; // Then your code is totally messed document === undefined ? document.writeln("==") : document.writeln("!=");