O'Reilly logo

Practical JavaScript Techniques by Smashing Magazine

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Optimizing Long Lists Of Yes/No Values With JavaScript

By Lea Verou

Very frequently in Web development (and programming in general), you need to store a long list of boolean values (yes/no, true/false, checked/unchecked… you get the idea) into something that accepts only strings. Maybe it's because you want to store them in localStorage or in a cookie, or send them through the body of an HTTP request. I've needed to do this countless times.

The last time I stumbled on such a case wasn't with my own code. It was when Christian Heilmann1 showed me his then new slide deck2, with a cool feature where you could toggle the visibility of individual slides in and out of the presentation. On seeing it, I was impressed. Looking more closely, though, I realized ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required