title: Specify default value for HTML5 Local Storage item?
body: <p>In the case that you are trying to get a local storage item that doesn't exist, is it possible to set a default value for that item?</p>
  
  <p>For example, let's say that in your web app, various UI preferences are saved in local storage. When a user leaves your website and then comes back, the UI is setup according to the values pulled from their local storage. This works great.</p>
  
  <p>However, when a user visits your web app for the first time, those local storage values do not exist yet. So when your JavaScript attempts to get those local storage items, they will all be undefined. Is there not a way to specify default values for each local storage item in the case that it doesn't exist?</p>
  
  <p>Most programming languages that deal with saving key/value pairs offer some sort way to specify default values (think .ini config file interfaces). I was expecting something like this:</p>
  
  <pre><code>var preference = localStorage.getItem('some-key', 'Default Value');
  </code></pre>
  
  <p>Also, I know that I can easily programmatically set default values by testing if they are null/undefined or not and set the value accordingly, but I wanted to see if this was built into the local storage key/value pair fetching and that maybe I just wasn't seeing it. If this feature doesn't exist, I will end up just writing some basic local storage wrapper functions that add in this feature.</p>