How to iterate javascript object properties in the order they were written

前端 未结 4 1638
抹茶落季
抹茶落季 2020-11-29 12:00

I identified a bug in my code which I hope to solve with minimal refactoring effort. This bug occurs in Chrome and Opera browsers. Problem:

var obj = {23:\"A         


        
4条回答
  •  -上瘾入骨i
    2020-11-29 12:34

    I think you'll find the only reliable way to do this would be to use an array rather than an associative array, eg:

    var arr = [{key:23,val:"AA"},{key:12,val:"BB"}];
    for(var i=0; i

提交回复
热议问题