HTML5 Local Storage toggle and save multiple classes
The following are all acceptable ways to set/get values to/from localStorage (or sessionStorage for that matter):

// set
localStorage.key = 'value';
localStorage['key'] = 'value';
localStorage.setItem('key', 'value');

// get
value = localStorage.key;
value = localStorage['key'];
value = localStorage.getItem('key');


I think from a practical standpoint though, you might see explicit setItem() or getItem() method calls used most frequently, as oftentimes one might find themselves working with dynamic key names, which would eliminate the first usage example from each of the the sets above.  Oftentimes developers choose to simply be consistent and use the getter/setter methods rather than mix direct property access when key names are known vs. getter/setter or "array-like" access when the key names are dynamic.

More complex applications may also abstract out direct access to localStorage and sessionStorage altogether, especially when dealing with browsers that do not support web storage (and therefore may need cookie-based fallback).  In such cases, you would absolutely not be able to have hard-coded key names when interacting with the underlying web storage, because you might have a usage pattern like:

myStorage.set(key, value, inSession) {
    if (typeof Storage !== undefined) {
        // we have local and session storage available
        if(inSession === true) {
            sessionStorage.setItem(key, value);
        } else {
            localStorage.setItem(key, value);
        }
    } else {
        // fallback
    }    
}