# Homeyscript lodash removing Quotes

**URL:** https://community.homey.app/t/homeyscript-lodash-removing-quotes/75201
**Category:** Developers
**Created:** [January 17, 2023, 10:55am UTC](https://community.homey.app/t/homeyscript-lodash-removing-quotes/75201 "2023-01-17T10:55:02Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Marcel\_Ubels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marcel_ubels/32/18860_2.png) [@Marcel\_Ubels](https://community.homey.app/u/Marcel_Ubels)
#### Post date: [January 17, 2023, 10:55am UTC](https://community.homey.app/t/homeyscript-lodash-removing-quotes/75201/1 "2023-01-17T10:55:02Z")

</div>

```auto
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

---

<div class="post-metadata">

### Author: ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)
#### Post date: [January 17, 2023, 11:33am UTC](https://community.homey.app/t/homeyscript-lodash-removing-quotes/75201/2 "2023-01-17T11:33:54Z")

</div>

I have no idea what you’re trying to do, can you explain a bit more? Do you want to remove all global variables?

---

<div class="post-metadata">

### Author: ![Marcel\_Ubels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marcel_ubels/32/18860_2.png) [@Marcel\_Ubels](https://community.homey.app/u/Marcel_Ubels)
#### Post date: [January 17, 2023, 11:41am UTC](https://community.homey.app/t/homeyscript-lodash-removing-quotes/75201/3 "2023-01-17T11:41:20Z")

</div>

What i want is a list of all globals. Like this:  
[//global.set](https://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](https://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](https://global.set)(‘offPeakMonth2022’,undefined)”  
“[//global.set](https://global.set)(‘offPeakContractPeriodMonth2023’,undefined)”  
“[//global.set](https://global.set)(‘producedPeakMonth2022’,undefined)”  
“[//global.set](https://global.set)(‘producedPeakContractPeriodMonth2023’,undefined)”  
“[//global.set](https://global.set)(‘producedOffPeakMonth2022’,undefined)”  
“[//global.set](https://global.set)(‘producedOffPeakContractPeriodMonth2023’,undefined)”  
“[//global.set](https://global.set)(‘powerMonth2022’,undefined)”  
“[//global.set](https://global.set)(‘powerContractPeriodMonth2023’,undefined)”

---

<div class="post-metadata">

### Author: ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)
#### Post date: [January 17, 2023, 11:53am UTC](https://community.homey.app/t/homeyscript-lodash-removing-quotes/75201/4 "2023-01-17T11:53:24Z")

</div>

Something like this?

```auto
for (const key of global.keys()) {
  console.log(`// global.set('${ key }', undefined)`);
}

```

---

<div class="post-metadata">

### Author: ![Marcel\_Ubels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marcel_ubels/32/18860_2.png) [@Marcel\_Ubels](https://community.homey.app/u/Marcel_Ubels)
#### Post date: [January 17, 2023, 12:02pm UTC](https://community.homey.app/t/homeyscript-lodash-removing-quotes/75201/5 "2023-01-17T12:02:54Z")

</div>

> [@robertklep](#):
>
> ```auto
> for (const key of global.keys()) {
> console.log(`// global.set('${ key }', undefined)`);
> }
> 
> ```

exactly what i needed. thx

---

<div class="post-metadata">

### Author: ![Peter\_Bittner](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_bittner/32/16698_2.png) [@Peter\_Bittner](https://community.homey.app/u/Peter_Bittner)
#### Post date: [April 2, 2024, 2:23am UTC](https://community.homey.app/t/homeyscript-lodash-removing-quotes/75201/6 "2024-04-02T02:23:47Z")

</div>

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.
