const keys = global.keys();
keys.forEach( element => console.log( JSON.stringify('\/'+'\/'+'global.set('+'\'' +element +'\'' +'\,' +'undefined)' ) ) );
I am trying to remove the quotes, but i haven’t have success. I use JSON. stringify because the list is to long for the noramlly used JSON. The reason for this script is having an easy method for removing too many global variables
I have no idea what you’re trying to do, can you explain a bit more? Do you want to remove all global variables?
What i want is a list of all globals. Like this:
//global.set(‘variable’, undefined). That way i can delete the global variables i want by deleting the slashes. At this moment i get the next output: “//global.set(‘variable’, undefined)”.
As i am fooling around with a script, i have to many variables, this way i can delete those variables by hand that i don’t need anymore .
this is an example of a part of the list;
“//global.set(‘offPeakMonth2022’,undefined)”
“//global.set(‘offPeakContractPeriodMonth2023’,undefined)”
“//global.set(‘producedPeakMonth2022’,undefined)”
“//global.set(‘producedPeakContractPeriodMonth2023’,undefined)”
“//global.set(‘producedOffPeakMonth2022’,undefined)”
“//global.set(‘producedOffPeakContractPeriodMonth2023’,undefined)”
“//global.set(‘powerMonth2022’,undefined)”
“//global.set(‘powerContractPeriodMonth2023’,undefined)”
Something like this?
for (const key of global.keys()) {
console.log(`// global.set('${ key }', undefined)`);
}
1 Like
exactly what i needed. thx
I tried this to see if it would help me solve my problem with global.get and global.set. I got this result.
// global.set(‘DischargeState’, undefined)
// global.set(‘ChargeState’, undefined)
// global.set(‘preserveState’, undefined)
I know these variable. They are logical variable set to No, although preserveState is actually spelt PreserveState.
Why are these the only variables found? Is there something I need to do to make them global? I though Global was the default.
Is it something about lodash? I admit I don’t understand lodash.