3 ms·
Weird to throw an exception when localStorage is not available. It is much more logical to have it undefined or null. Code working with localStorage is more lik
by sebazzz 4y ago
Weird to throw an exception when localStorage is not available. It is much more logical to have it undefined or null. Code working with localStorage is more likely to check whether it is available (“not falsey”) rather than trying to use it and fall back if it throws.
- the_gipsy 4y agoNo, it's correct. Null checks are for checking that a browser API is supported, but they might be unavailable, like being blocked or full or whatever.