a debugging tool for JavaScript. It is method of the console object which logs the given object in the Browser's JS console.
log
method of the console
object is a method mainly used for debugging purposes.
Syntax
console.log(obj1 [, obj2, ..., objN]);
Parameters
obj1
...objN
-
A list of JavaScript objects to output. The string representations of each of these objects are appended together in the order listed and output.
Example
Here is a simple JavaScript example which illustrates the use of console.log
:
var foo = {'id':7, 'name':'John Doe'};
console.log(foo);
Output (in the console
) - {id:7, name:"John Doe"}.
Note - The result my vary depending upon the browser's implementation of console.
Browser Compatibility
This feature is fully-supported on the latest versions of all the major browsers.
- Mozilla Firefox 4+
- Microsoft Internet Explorer 8+ (only after opening the F12 developer tools)
- Google Chrome 1+
- Opera 10.50+
- Apple Safari 3+