"use strict";
console.log("==== Test delete Array.prototype[Symbol.iterator] ====");
function assert(b, msg) {
if (!b) {
throw new Error("Assertion failed: " + msg);
}
}
assert(Array.prototype[Symbol.iterator], "Symbol.iterator should exist initially");
let deleted = delete Array.prototype[Symbol.iterator];
assert(deleted, "delete should return true");
if (Array.prototype[Symbol.iterator]) {
console.log("Symbol.iterator STILL EXISTS after delete");
console.log("Value:", Array.prototype[Symbol.iterator]);
} else {
assert(!Array.prototype[Symbol.iterator], "Symbol.iterator should be gone after delete");
}
let arr = [1, 2, 3];
try {
let [x] = arr;
assert(false, "Destructuring should have failed without iterator");
} catch (e) {
assert(e instanceof TypeError, "Error should be TypeError");
}