fix(location.js) check for truthy before using

Check to see if the value exists before attempting to use it

Partially fixes #4442