Why am i getting 'uncaught quotaexceedederror' in web storage?

Example:

localStorage.setItem('key', new Array(5000000).join('a'));
Solution:

This error arises when you exceed the storage quota limit for `localStorage` or `sessionStorage`. Ensure that the data being stored doesn't surpass the storage limits, typically 5-10 MB.


if (navigator.storage && navigator.storage.estimate) {
    navigator.storage.estimate().then(({ usage, quota }) => {
        console.log(`Using ${usage} out of ${quota} bytes.`);
    });
}

Beginner's Guide to JavaScript