Type checking instead of referencing for localstorage detection.

Referencing throw error in Google Packaged Apps.