Created
September 20, 2011 15:26
-
-
Save arunoda/1229406 to your computer and use it in GitHub Desktop.
Java Script Data Structures
This file contains hidden or 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
// Arrays | |
var aaa = []; | |
// Stack | |
var aa = [10]; | |
aa.push(20); | |
aa.pop(); //gets 20 | |
// Queue | |
var aa = [10]; | |
aa.push(20); | |
aa.shift(); //gets 10 | |
// Map | |
var aa = {}; | |
aa['arunoda'] = 10; | |
aa['soori'] = 40; | |
// Objects with JSON | |
var tweer = { | |
user: "arunoda", | |
status: "Hey dude", | |
date: new Date().getTime() | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For objects
for(var key in obj) {
var value = obj[key];
}