Opens in a new tab
A picture of Jeff Brigman
I CODE TODAY FOR
A BETTER TOMORROW

Glossary Term

Map.prototype.getOrInsertComputed()

2 tags 1 category

The getOrInsertComputed() method of Map instances returns the value corresponding to the specified key in this Map. If the key is not present, it inserts a new entry with the key and a default value computed from a given callback, and returns the inserted value.

Use this method instead of Map.prototype.getOrInsert() when the default value is expensive to compute, and you want to avoid computing it unless it’s actually needed.

Return value: The value associated with the specified key in the Map object. If the key can’t be found, the result of callback(key) is inserted and returned.

Syntax example: getOrInsertComputed(key, callback)

Term Connections

Explore related terms connected by shared tags, shared categories, and relationship phrases. This map loads only when it comes into view.

Loading term connections…