I have stored an object with multiple properties in localStorage. It does not contain a single value like a string or a number. The name of the localStorage key is UserDat
UserDat
Use JSON.parse like
JSON.parse
var userData= JSON.parse(localStorage.getItem('UserData')) this.operatorDni=userData.operatorDni;
Also save it like
localStorage.setItem('UserData',JSON.stringify(yourObject))