JS 用变量作为关联数组的索引

JavaScript014

JS 用变量作为关联数组的索引,第1张

关联数组类似对象,遍历关联数组,可以用for...in语法:

for(var key in data){

    console.log(key +  ':' + data[key])

}

$(fucntion(){

    $("td").each(function(i){

       $(this).click(function(){

       //这个i就是你要的索引值

       //TODO

    })

   })

})

#include <stdio.h>

int main()

{

int a[2][3]

int * p=a

int js =3

*p=js

printf("%d",*p)

return 0

}