Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Test localStorage key ordering
<pre id="output"></pre>
<script src="//"></script>
<script src="index.js"></script>
localStorage.setItem('3', '3');
localStorage.setItem('2', '2');
localStorage.setItem('1', '1');
localStorage.setItem('10', '10');
localStorage.setItem('0', '0');
localStorage.setItem('2', '2');
localStorage.setItem('100', '100');
var i = -1;
var len = window.localStorage.length;
while (++i < len) {
var key = window.localStorage.key(i);
$('#output').text($('#output').text() + '\n' + key);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment