I am looking for a way for Javascript to read itself in as a String.
For example, take the following code.
var Object = {
myFunction: function() {
console.log("FUNCTION!");
}
}
I would like some way of getting that code as a String, line breaks and all. Exactly as it comes down to the user.
I haven't found any similar questions on my investigations, and I've been looking for a good few hours.
EDIT
Note, I didn't specify the serialisation of an Object. I specified the serialisation of code.
var n = 1;
var x = "hello";
var something = "hi";
How can I get that as a String, as well as the Object declaration?