I have a global variable in JavaScript (actually a window
property, but I don\'t think it matters) which was already populated by a previous script but I don\'t
In addition to what everyone had written, also note that delete
returns boolean. It can tell you if the delete was successful or not.
Testing on Chrome, everything except let
was deletable. when delete
returned true
it actually removed them:
implicit_global = 1;
window.explicit_global = 1;
function_set = function() {};
function function_dec() { };
var declared_variable = 1;
let let_variable = 1;
delete implicit_global; // true, tested on Chrome 52
delete window.explicit_global; // true, tested on Chrome 52
delete function_set; // true, tested on Chrome 52
delete function_dec; // true, tested on Chrome 52
delete declared_variable; // true, tested on Chrome 52
delete let_variable; // false, tested on Chrome 78