As a feature in a sort of game created in HTML5/CSS in combination with javascript, I would like to show some randomly looking code which scrolls in a div.
An easy way to accomplish this would be to actually print the code used to create the game, but I cannot seem to manage to do so.
I have tried to call .toString() on an object I have defined, but it only prints [Object Object], which obviously isn't preferably. The desired effect is basically the same as calling .toString() on a single function, however I would like to do so on the entire code/all objects that I use.
How could I accomplish this?
Edit: Some clarification, I have an object
var Foo = {
stuff: [],
function1: function() { /* code */ }
}
And I would like to be able to use it as follows:
var string = Foo.toString();
$("#myDiv").html(string);
Which will result in myDiv containing the source code of the object called Foo.