tc39 / proposal-optional-chaining

https://tc39.github.io/proposal-optional-chaining/
4.94k stars 75 forks source link

`delete` should return true in case of short-circuiting #92

Closed raulsebastianmihaila closed 5 years ago

raulsebastianmihaila commented 5 years ago

As the title says, I'd be surprised if the delete operator would ever produce a non-Boolean. Since deleting non-existing references in sloppy mode produces true I think true should be produced by delete a?.x when a is null or undefined.

ljharb commented 5 years ago

I believe delete returns false when the property is not deleted, for example when it’s nonconfigurable.

As for semantics, what does deleting a nonexistent property do in strict mode?

claudepache commented 5 years ago

There was an error in the README, the result of delete null?.foo is the same as delete (0,undefined). Thanks for noticing.

@ljharb The delete operator returns true if the (own) property is not present.