How to safely wrap `console.log`?
问题 Suppose I want to include some calls to console.log for some legitimate production reason, say for something like a unit test harness. Obviously I would not want this to throw a premature exception if the browser doesn't have a console , or if no console is present. What's the best way to create a simple log function to log stuff to the console, or silently fail without error if no console is present? The accepted answer to the question linked above: var log = Function.prototype.bind.call