delete

delete obj.key removes an own property. Setting it to undefined instead keeps the key, so in still finds it. delete cannot remove variables, leaves a hole in arrays without changing length (use splice()), and throws in strict mode on a non-configurable property such as Object.prototype.

delete versus undefined, and an array holeJavaScriptLive
const o = { a: 1, b: 2 }, arr = [1, 2, 3];
delete o.a;
o.b = undefined;                  // key stays, value cleared
delete arr[1];                    // leaves a hole
console.log("a" in o, "b" in o, JSON.stringify(o), arr, arr.length);

In V8 86,723 , objects that often lose properties fall back from shared hidden classes to slower dictionary storage, so hot code should build a new object with ...rest or use a Map.