Object.clear
Object.clear
Function
Clear the object and return the original object.
Syntax
object.clear()
Parameters
No parameters.
Return value
| Type | Description |
|---|---|
| Object | Returns the original object. |
Return object fields
clear() returns the same object reference that it was called on. All fields in the object will be deleted after the call, so the returned object is an empty Object.
Example
cache = {a: 1, b: 2} cache.clear() // Output: 0 echo(cache.len())
Notes
- clear will modify the original object.
- clear will reuse the object container, which is suitable for scenarios where writing continues after clearing in the resident process.