delete is definitely slower, but it removes the key (completely cleans the object of the assignment).
This can matter if you are using an object as a hashmap with a large key domain, for example if the keys are UUIDs.
Over prolonged/intensive use, this can result in a large object.
But no reason to mess around with disposing of the object and using a new one, or using delete - just don't use objects for such cases, use the new Map type instead. The .delete(key) method there is very fast.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
delete
is definitely slower, but it removes the key (completely cleans the object of the assignment).This can matter if you are using an object as a hashmap with a large key domain, for example if the keys are UUIDs.
Over prolonged/intensive use, this can result in a large object.
But no reason to mess around with disposing of the object and using a new one, or using
delete
- just don't use objects for such cases, use thenew Map
type instead. The.delete(key)
method there is very fast.