摘要:
一、循环的适用场景(建议) for : 比较适合遍历数组,字符串等等。 for in : 比较适合遍历对象,遍历对象时使用这个再合适不过。 while : while 与 for 的使用场景差不多。 do while : 至少执行一边的循环,遍历数组和字符串也很方便。 二、while遍历数组需要注意 阅读全文
摘要:
一、JavaScript for/in 语句循环遍历对象的属性 var person={fname:"Bill",lname:"Gates",age:56}; var txt = ""; // x 为属性名 for (x in person) { txt = txt + person[x]; } c 阅读全文