Object.delete
Object.delete
Function
Delete the specified key.
Syntax
object.delete(key)
Parameters
| Parameters | Type | Required | Default value | Description |
|---|---|---|---|---|
| key | Any | No | '' | The key name to be deleted will be converted to a string first when called. |
Return value
| Type | Description |
|---|---|
| Bool | Returns true if the deletion is successful; returns false if the key does not exist. |
Example
user = {name: 'BT', age: 1} result = user.delete('age') // Output: true print result
Notes
- This method modifies the original object.