Skip to content

Instantly share code, notes, and snippets.

@altamic
Created November 2, 2012 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save altamic/4001472 to your computer and use it in GitHub Desktop.
Save altamic/4001472 to your computer and use it in GitHub Desktop.
javascript simple Array to Object conversion
> Array.prototype.toObject = function() {b={}; for(i=0;i<this.length;i+=2) {b[this[i]]=this[i+1]}; return b;}
[Function]
> ["chiave1","valore1","chiave2","valore2"].toObject()
{ chiave1: 'valore1', chiave2: 'valore2' }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment