Created
May 12, 2014 09:40
-
-
Save nolanlawson/886cb5fbc83d488ae40d to your computer and use it in GitHub Desktop.
Test localStorage key ordering
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<pre id="output"></pre> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> | |
<script src="index.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
console.log(key); | |
$('#output').text($('#output').text() + '\n' + key); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment