As shown below, in a loop, after the loop variable is deleted, the loop can still proceed. Is it because this variable is specially defined as non-editable, or because the compiler creates an internal variable with the same name in the context for the loop? use?
for (var j = 0; j < 10; j++) {
delete j;
console.log(j); // 正常输出 0 1 2 3 ...
}
Because delete can only affect instance attributes and cannot directly delete variables or functions.
If you execute the following command, the return value will be false, indicating that the deletion is invalid.
Attachment: delete operator syntax, from MDN documentation
The expression is a reference to an object property