I'm getting this error with JSLint: Only properties should be deleted
Why doesn't it like this? The variable I am attempting to delete is very large, so I was hoping to get a jump on the garbage collection. Is this not ok?
delete
is meant to delete properties on an object, not regular variables (properties on a VariableObject).
Instead, you could set all references to the value as null
. JavaScript's GC will clean it up when it feels it needs to.
if you just want to get rid of the jslint warning, you can try this:
var myHugeVariable = ...;
// do stuff with huge variable
delete window.myHugeVariable;
This should work since all global variables are actually properties of the global object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With