0

I would like to ask questions about 'delete' operator in Javascript

Why

delete window.document; // returns false

but

delete navigator.geolocation; // returns true

I try other properties of navigator and it still returns true

I have checked the IDL in webkit, document and navigator are both of readonly,
and they dont have DontDelete attribute but why I can delete one but not for the other???

1 Answer 1

1

If you'd like to understand the delete operator, wrap your mind around the javascript spec section 11.4.1

There are several cases where the operator should evaluate to true without mutating any objects.

From 8.12.7, the operator checks checks an internal [[Configurable]] property of the property descriptor to enforce readonly properties.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.