sorting - Javascript object automatically sorts -


// mechanics mechanics_isolation : 1, mechanics_na : 2, mechanics_compound : 3,  // mechanics exercise.mechanics = {}; exercise.mechanics[exercise.mechanics_compound] = 'compound'; exercise.mechanics[exercise.mechanics_isolation] = 'isolation'; exercise.mechanics[exercise.mechanics_na] = 'n/a'; 

when loop through exercise.mechanics, keys come out sorted. how can unsorted keys loop through?

thanks!

keys in hashmap not reliable. give keys order. example, put keys array , iterate keys.

var keys = [mechanics_isolation, mechanics_na, mechanics_compound]; (var = 0; < keys.length; i++) {     console.log(exercise.mechanics[keys[i]]); } 

Comments

Popular posts from this blog

How do you change vbulletin's home page to the forums instead of the default (CMS or Activity Stream)? -

c++ - Troubles when compiling phash program -