-
• #2
This is nasty!
Does 'delete varname' clean up after it?
-
• #3
Hi DrAzzy,
Yes as any other variable it could be deleted. It gives the mem back.
Sacha
-
• #4
I believe it's this one https://github.com/espruino/Espruino/issues/63
Just an idea I didn't test, but how about
if (Object.keys(test).indexOf("bar") !== -1) {...}
Would that make sense?
-
• #5
Yes, it looks like. Thanks. Will try it.
Sacha
-
• #6
Or you can do
if ("bar" in test) ...
which is a bit faster/easier.At the moment this is a frustrating issue - but it's surprising how rarely it's actually a problem if your code is working as expected.
Hi Espruinos,
I just searching a proper way to detect if a variable is defined/exists without loosing memory. Yes it's all about memory....
I tried it in two ways:
and
Here is the memory loosing code:
Each test if the variable exists creates the variable as undefined and uses memory.
You will see it when you output the array like this:
Output:
Many thanks for your help
Sacha