I know how to check whether an Object property exists.
This can complicate my code if I have several properties which may or may not be present in my Object. Python's solution is to use .get()
:
>>> a = {'x': 1, 'y': 2}
>>> a.get('z')
>>> a.get('z', 'hello')
'hello'
In the first case, a None
(boolean-y speaking, a False
) is returned.
Is there such a construction in JS (pure of tainted with a library)?