Is there a null-coalescing (Elvis) operator or safe navigation operator in javascript?

You can use the logical ‘OR’ operator in place of the Elvis operator: For example displayname = user.name || “Anonymous” . But Javascript currently doesn’t have the other functionality. I’d recommend looking at CoffeeScript if you want an alternative syntax. It has some shorthand that is similar to what you are looking for. For example … Read more