No, there's no direct way. One workaround would be to use a for
loop over keys
instead of for..in
and pick elements by their numeric index:
keys = Object.keys(myObj);
for(var i = 0; i < keys.length; i++) {
current = keys[i];
previous = keys[i - 1];
next = keys[i + 1];
...
}