Subj : Dump Globals
To : Mortifis
From : echicken
Date : Sat Feb 16 2019 11:36 am
Re: Dump Globals
By: Mortifis to All on Sat Feb 16 2019 11:26:39
Mo> Is there a js function similar to php var_dump($GLOBALS); ?
Not that I'm aware of. It's easier and less verbose to target the variable
that you want rather than dumping the entire global space:
writeln(JSON.stringify(my_var));
You could use this to dump the global scope of your script:
function scope_dump() {
Object.keys(js.scope).forEach(function (e) {
const exclude = [
'conio',
'js',
'stderr',
'stdin',
'stdout'
];
if (exclude.indexOf(e) > -1) return;
writeln(e + ':\r\n' + JSON.stringify(js.scope[e]) + '\r\n');
});
}
Tweak the 'exclude' array to filter unneeded stuff like 'system', 'msg_area',
'file_area', 'xtrn_area'. The defaults are there to avoid problems and should
be left in, though some don't matter in certain contexts (like the webserver).
---
echicken
electronic chicken bbs - bbs.electronicchicken.com - 416-425-5435
� Synchronet � electronic chicken bbs - bbs.electronicchicken.com