Search Results

Search found 1 results on 1 pages for 'captainclam'.

Page 1/1 | 1 

  • Get next key-value pair in an object

    - by captainclam
    So, given a key, I want to find the next property in an object. Then, I want to return the value of the NEXT property. I can not rely on the keys to be ordered or sequential (they're uuids). Please see below for trivial example of what I want: var db ={ a: 1, b: 2, c: 3 } var next = function(db, key) { // ??? } next(db, 'a'); // I want 2 next(db, 'b'); // I want 3 I also want a prev() function, but I'm sure it will be the same solution. This seems like such a trivial problem but I can't for the life of me figure out how to do it. Happy for the solution to use underscore.js or be written in coffeescript :)

    Read the article

1