本文主要是介绍Loops in JavaScript,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1. Loop Syntax
for (var index=1; index<10; index=index+1) {
code code code;
}
2. Array Syntax
var arrayname = [data1, data2, data3, ...]
列表元素从0开始计数,元素类型任意
3. Loop & Array
var arr = ["a", "b", 1, 2, "c"];
for (var i=1; i<arr.length; i++) {
console.log(arr[i]);
}
4. While
while (condition) {
// do something!
}
do ... while ...
do (condition) {
// do something!
// remember to change the condition.
} while (condition);
(完)
While Syntax
while (condition) {
// do something!
}
这篇关于Loops in JavaScript的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!