function supportsStorage(){
var ls = window.localStorage;
return ls instanceof Object && !isNaN(ls.length);
}
On Sep 22, 5:19 am, Anders Jönsson <[email protected]> wrote:
> Hi
>
> On "http://diveintohtml5.org/storage.html" they use the following code to
> check for local storage support:
>
> function supports_html5_storage() {
> try {
> return 'localStorage' in window && window['localStorage'] !== null;
> } catch (e) {
> return false;
> }
>
> }
>
> What's the difference between that way and this way?:
>
> function supports_html5_storage() {
> try {
> return typeof window.localStorage !== 'undefined';
> } catch (e) {
> return false;
> }
>
> }
>
> And can we also remove the try...catch?:
>
> function supports_html5_storage1() {
> return typeof window.localStorage !== 'undefined';
>
> }
>
> Is it more safe to use "'localStorage' in window && window['localStorage']
> !== null; " over "typeof"?
>
> Regards
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]