Skip to content

Instantly share code, notes, and snippets.

@chochinlu
Created May 22, 2014 03:23
Show Gist options
  • Save chochinlu/3101ecbb9ff46f7a445e to your computer and use it in GitHub Desktop.
Save chochinlu/3101ecbb9ff46f7a445e to your computer and use it in GitHub Desktop.
js definitive guide 6th -- ch8.3
function getIndexNames(o, a){
var a = a || []; //if (a === undefined) a = [];
for(var index in o){
console.log("---"+ o[index]);
a.push(index);
};
return a;
}
var a = getIndexNames(["111"]);
console.log(a); //['0']
getIndexNames(["aaa", "bbb", "ccc"], a);
console.log(a);//['0', '0', '1', '2']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment