In javascript, I often want to access the attribute of an object that may not exist.
For example:
var foo = someObject.myProperty
However this will throw an error if someObject is not defined. What is the conventional way to access properties of potentially null objects, and simply return false or null if it does not exist?
In Ruby, I can do someObject.try(:myProperty)
. Is there a JS equivalent?