Skip to content

Instantly share code, notes, and snippets.

@colevandersWands
Last active June 26, 2018 22:17
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 colevandersWands/88719f07825dcfd226bc7a205049c08b to your computer and use it in GitHub Desktop.
Save colevandersWands/88719f07825dcfd226bc7a205049c08b to your computer and use it in GitHub Desktop.
objects vs arrays
// ----- objects vs arrays -----
// run in python tutor
function toObject(arr) {
var rv = {};
for (var i = 0; i < arr.length; ++i)
if (arr[i] !== undefined) rv[i] = arr[i];
delete rv[1]
arr.splice(1, 1)
return rv;
}
toObject(["a", "b", "c"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment