Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
The delete operator can be used
to completely remove properties from an object. Below, we delete the
bar property from the foo object.
<!DOCTYPE html><html lang="en"><body><script>
var foo = {bar: 'bar'};
delete foo.bar;
console.log('bar' in foo); // logs false, because bar was deleted from foo
</script></body></html>Delete will not delete properties that are found on the prototype chain.
Deleting is the only way to actually remove a property from an
object. Setting the property to undefined or null only changes the value of a property.
It does not remove the property from the object.