javascript - Getting the next key -


i have array this:

var bookch = {'tomsawyer':[twain,50], 'parelandra':[lewis,150], 'roguecode':[russinovich,23], 'wrinkle':[lengle,12]}; 

if match on roguecode, want print next key console (e.g., if match roguecode, print wrinkle). here's have match, have no idea how print next key in array instead of current one. if numbered keys easy, aren't...

var currentbook = "roguecode";  (var bookkey in bookch) {  if (bookkey == currentbook) {   console.log("next book: " +  ???);  } } 

declare array this

var bookch = [   {     'id': 'tomsawyer',     'meta': [twain, 50]   },   {     'id': 'parelandra',     'meta': [lewis, 150]   },   {     'id': 'roguecode',     'meta': [russinovich, 23]   },   {     'id': 'wrinkle',     'meta': [lengle, 12]   } ] 

now when iterate on it

for(var i=0; i<bookch.length-1; i++) {  // bookch[i+1] (this next array item) } 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -