I have the following class:
var a = $scope.option.userMap[userId].name;
This fails when there is no value in userMap that has a key of userId. The error message comes up when it tries to do the .name of something that's not defined.
Is there a simple way that I could catch this error? When the error happens I would like the variable a
to be set to "unknown"