I have a JavaScript object that looks something like this:
{ bacon: [Function], hello: [Function], tables: [Function] }
Where [Function] is an actual JavaScript function.
I want to write this to a .js file with contents like:
var Templates = /*source code here*/
How can I get the source code for the object and function properties as a string, such that eval'ing this "source code string" will give me back the same object?
toStringon the function? For an object you could just use a JSON parser..toString()also gives back "[object Object]".toString()seems to work on the functions actually, but not on the object.eval()on it will yield exactly the same object. JSON cannot represent functions.