Home  >  Article  >  Web Front-end  >  Summary of usage of console.log() in javascript_javascript skills

Summary of usage of console.log() in javascript_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:52:531267browse

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:

Copy the code The code is as follows:

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.

[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute
]

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.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn