localStorage and sessionStorage both extend Storage. There is no difference between them except for the intended "non-persistence" of sessionStorage
.
That is, the data stored in localStorage
persists until explicitly deleted. Changes made are saved and available for all current and future visits to the site.
For sessionStorage
, changes are only available per tab. Changes made are saved and available for the current page in that tab until it is closed. Once it is closed, the stored data is deleted.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…