Javascript – Print an object in console

The toSource() function, which we talk about yesterday(Javascript – Print an object with alert()), only works in Firefox, a more proper way which work in non Gecko engine browser like Chrome and Safari is using console.



Try the following example.

    <script type="text/javascript" src=""></script>
    <script type="text/javascript">
      $(document).ready(function() {
        myWebsite = new Object(); = 'Eureka!';
        myWebsite.url = '';



See what you get in Firebug.

Done =)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.