Last active
June 26, 2018 22:17
-
-
Save colevandersWands/88719f07825dcfd226bc7a205049c08b to your computer and use it in GitHub Desktop.
objects vs arrays
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
// ----- 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