Operator in can be used to check if given object has given property:
While checking if object has given property in also checks
But we cannot delete anything from prototype chain:
Also in strict mode we cannot delete global functions and variables
but we can delete properties of window object:
And what if you want to make one of your own properties undeletable?
No problem just mark is as a non configurable prop:
The last thing about delete to remember is that it returns true
when it manages to remove property and false otherwise.
If you think that this may be useful, look at the example below:
OK OK to be honest delete returns true when object
doesn’t have own property after executing delete operation.
In other words if delete returns true we may be certain
that property name doesn’t appear
in array returned by Object.keys().