Salesforce JavaScript Developer Practice Exam

Question: 1 / 400

What happens to the name property after calling Object.seal(emp) and then delete emp.name?

The name property is deleted successfully

The name property remains unchanged

When you use `Object.seal(emp)`, it prevents the addition of new properties to the object and marks all existing properties as non-configurable. This means that existing properties cannot be deleted or redefined.

In this case, since the `name` property already exists on the `emp` object and you attempt to delete it after sealing the object, the `delete emp.name` statement will have no effect. The `name` property remains unchanged because sealing the object has made it non-configurable, thus preventing its deletion.

This behavior highlights the purpose of the `Object.seal()` method, which is to allow the existing properties to be modified if they are writable, but to protect the structure of the object itself by disallowing any deletions or additions.

Get further explanation with Examzify DeepDiveBeta

A new name property can be added

The object is completely frozen

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy