I am trying to write the global object to file from a node application.
As a starting point I know that writing Function('return this')
in the console outputs the global object with all members.
So I am trying the following:
var fs = require("fs");
fs.writeFile("/Users/myuser/Desktop/log.txt", Function('return this')());
But it just writes [object global]
to the file
- Why is the output in the file different than the output in the console?
- How can I output the entire global object to file?