Save an object with properties and methods to localStorage