Every object in javascript have a toString() method that is called when a string is required in different contexts. And every of these objects implement this method in different ways so you will receive different string for different objects. You could even override this method.
If you want to print/show the structure of an object you could transform it to a JSON string.
alert(JSON.stringify(b))