Retrieves an integer value from localStorage
Gets a value from localStorage by key and parses it as an integer. Returns null if the key doesn't exist or the value cannot be parsed.
The localStorage key to retrieve
The parsed integer value, or null if not found
const count = getLocalStorageInt({ key: 'visit-count' });if (count !== null) { console.log(`You've visited ${count} times`);} Copy
const count = getLocalStorageInt({ key: 'visit-count' });if (count !== null) { console.log(`You've visited ${count} times`);}
Retrieves an integer value from localStorage
Gets a value from localStorage by key and parses it as an integer. Returns null if the key doesn't exist or the value cannot be parsed.