I want to store an array of items in html5 session storage. But before storing new items in array I want to see if there is enough space and if it doesn't has enough I want remove first element and add new item. How I can know about available space in session storage?
Try to put the data there and catch possible error:
try {
sessionStorage.setItem('key', data);
} catch (e) {
if (e.name === 'QuotaExceededError') {
/* do something else */
}
}