📜  javascript代码示例中的for vs for

📅  最后修改于: 2022-03-11 15:02:53.288000             🧑  作者: Mango

代码示例4
//for in, iterates keys in an object
var obj={a:1, b:2}

for( var key in obj)
  console.log(obj[key]); //would print 1 and 2

//for of, iterates values in array or any iterable
var ar = [10, 11, 12, 13]
for (var item in ar )
  console.log(item);  //would print 10  11  12  13