Javascript equivalent of Python's dict.setdefault?
10:37 19 Apr 2013

In Python, for a dictionary d,

d.setdefault('key', value)

sets d['key'] = value if 'key' was not in d, and otherwise leaves it as it is.

Is there a clean, idiomatic way to do this on a Javascript object, or does it require an if statement?

javascript dictionary