Reputation: 19723
Whats the simplest / most efficient way to log a Javascript / jQuery output?
At the moment, I am using something like alert('foobar');
blocks in my code.
Upvotes: 0
Views: 258
Reputation: 324567
You could use log4javascript (disclosure: I wrote it), which works in all major browsers, has a nice logging console with search and filtering and can also be used to send log messages to the server.
Upvotes: 0
Reputation: 451
Absolute simplest, use Firebug Lite.
Include the following code at the top of the
<head>
of your page:
<script type="text/javascript" src="https://getfirebug.com/firebug-lite.js"></script>
That's it! It will bootstrap a logging console in your browser window, no matter which (modern) browser you're working with.
The Firebug console API can be found at the Firebug wiki.
There are a few other options for logging in JavaScript, but if you just want something simple that works... Firebug Lite is the best option.
Upvotes: 1
Reputation: 5628
console.log is better if the browser supports it.
if (window.console)
console.log('foobar');
Upvotes: 3