When iterating with a for loop it's more convenient to use this:
for (var key in obj){ key }
than these:
for (var i in array){ var key = array[i]; key }
for (var i = 0; i< array.length;i++){ var key = array[i]; key }
But, obviously, declaring arrays is easier:
var array = ['key1', 'key2', 'key3']
var obj = { key1:'',key2:'',key3:'' }
Assuming I only care about keys and don't care about order, is there a way of declaring objects with just keys and no values (more easily than above)? I just don't like using
:'',
It looks like a weird smiley face.
Edit:
for-of would definitely be the way to go, just not yet.
for...inloops to iterate over arrays fwiw.arr.forEach.