摘要: 一、循环的适用场景(建议) for : 比较适合遍历数组,字符串等等。 for in : 比较适合遍历对象,遍历对象时使用这个再合适不过。 while : while 与 for 的使用场景差不多。 do while : 至少执行一边的循环,遍历数组和字符串也很方便。 二、while遍历数组需要注意 阅读全文
posted @ 2021-07-03 09:08 那些年的事儿 阅读(401) 评论(0) 推荐(0) 编辑
摘要: 一、JavaScript for/in 语句循环遍历对象的属性 var person={fname:"Bill",lname:"Gates",age:56}; var txt = ""; // x 为属性名 for (x in person) { txt = txt + person[x]; } c 阅读全文
posted @ 2021-07-03 08:54 那些年的事儿 阅读(231) 评论(0) 推荐(0) 编辑