search

Home  >  Q&A  >  body text

javascript - js array traversal issues

Does anyone know how to get the variable names in the array? For example, [a, b, c] wants to get the values ​​​​of a, b, c and a, b, c respectively by traversing.

欧阳克欧阳克2744 days ago750

reply all(3)I'll reply

  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-07-05 10:37:51

    > arr=[]
    
    > arr['a']=1
    
    > arr['b']=2
    
    > arr['c']=3
    
    > for(k in arr)console.log(k,arr[k])
    a 1
    b 2
    c 3
    
    > arr
    [ a: 1, b: 2, c: 3 ]

    reply
    0
  • typecho

    typecho2017-07-05 10:37:51

    No.

    reply
    0
  • 欧阳克

    欧阳克2017-07-05 10:37:51

    for in ?

    reply
    0
  • Cancelreply