I have been struggling with this for a while:
for( var key in obj ){
blah.blah()
if(choice){
doThis();
}
}
How can I call doThis() only at the last item? Since I don’t have a counter, i, I can’t determine which is the last item.
First off, keys don’t come in any guaranteed order. By specification, the keys are unordered. If you really wanted to do something with the last key you got, you could do so like this;