console.log was originally a "patent" of Firefox. Strictly speaking, it is a unique debugging "trick" of Firefox after installing Firebugs.
IE8 has learned this trick, but it is more troublesome to use than Firebugs. Console.log can only produce results when the debugging window (F12) is opened, otherwise an error will be reported.
Today I saw that Opera also has something called dragonfly. Using this tool to view the DOM is comparable to Firebug. However, console.log still cannot be used. So someone provided these two lines of code:
window. console = window.console || {};
console.log || (console.log = opera.postError);
After testing, the above code works well.
At this point, Firefox/IE/Opera can all use console.log.
Of course, the console.log under IE and Opera is still too simple compared to the original console.log in Firebugs. For example, if the parameter is an Object or an array, there is no further display function.
]
Script Home Note: IE browser does not support console.log by default. Instead, an error will be reported because of this code. It is better to comment it out under IE.