I have a newby question in Javascript. If I call console.log(something) before the following MyInit function is called (in a simple html page), I get an exception because console is not defined. That's ok. But I don't see what the MyInit function does to make it work: It looks like it is defining the log function as something empty that does nothing. How does it get from the definition I provide to the actual console log function that writes to the console?
function MyInit()
{
if (!window.console) console = { log: function () { } };
}
...
<!-- later -->
console.log("OnMouseOver occurred.");