遍历内联定义的数组

时间:2018-12-12 12:54:22

标签: javascript arrays for-loop

如何使用此for循环结构和数组访问值遍历内联定义的数组?

for(let prop in ["Alan", "Jeff", "Sarah", "Ryan"]){
   //"Alan"
   //"Jeff"
   //"Sarah"
   //"Ryan"
}

1 个答案:

答案 0 :(得分:3)

您应该使用print (m1 | m2) 0 True 1 True 2 False 3 True 4 True 5 True Name: col1, dtype: bool 而不是of

in

将输出:

for(let prop of ["Alan", "Jeff", "Sarah", "Ryan"]){
    console.log(prop);
}