ﺪﻨﻨﮐ ﺍﺮﺟﺍ ﺍﺭ ﺪﮐ ﮎﻮﻠﺑ ﮏﯾ ﺪﻨﻧﺍﻮﺗ ﯽﻣ ﺎﻫ ﻪﻘﻠﺣ
while
ﻪﻘﻠﺣ.ﺪﻧﺯ ﯽﻣ ﻪﻘﻠﺣ ﺪﮐ ﮎﻮﻠﺑ ﮏﯾ ﻖﯾﺮﻃ ﺯﺍ ،ﺪﺷﺎﺑ ﺖﺳﺭﺩ ﺺﺨﺸﻣ ﻁﺮﺷ ﮏﯾ ﻪﮐ ﯽﻧﺎﻣﺯ ﺎﺗ ﺩﻮﺷﯽﻣ ﺍﺮﺟﺍ ﻪﮐ ﯽﻧﺎﻣﺯ ﺎﺗ ،ﺎﻫﺭﺎﺑ ﻭ ﺎﻫﺭﺎﺑ ،ﻪﻘﻠﺣ ﺭﺩ ﺩﻮﺟﻮﻣ ﺪﮐ ،ﺮﯾﺯ ﻝﺎﺜﻣ ﺭﺩ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ .ﺖﻓﺎﯾ ﺪﻫﺍﻮﺨﻧ ﻥﺎﯾﺎﭘ ﺰﮔﺮﻫ ﻪﻘﻠﺣ ،ﺪﯿﻫﺩ ﺶﯾﺍﺰﻓﺍ ﺍﺭ ﻁﺮﺷ ﺭﺩ ﻩﺩﺎﻔﺘﺳﺍ ﺩﺭﻮﻣ ﺮﯿﻐﺘﻣ ﻪﮐ ﺪﯿﻨﮐ ﺵﻮﻣﺍﺮﻓ ﺪﺷ ﺪﻫﺍﻮﺧ ﻪﻘﻠﺣ ﻦﯾﺍ .ﺖﺳﺍ while ﻪﻘﻠﺣ ﺯﺍ ﯽﻋﻮﻧ ﺩﻮﺑ ﺪﻫﺍﻮﺧ ﻪﺸﯿﻤﻫ ﻪﻘﻠﺣ .ﺪﻨﮐ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ ﺕﺭﻮﺻ ﻦﯾﺍ ﺮﯿﻏ ﺭﺩ ،ﺪﯿﻫﺩ ﺶﯾﺍﺰﻓﺍ ﺍﺭ ﻁﺮﺷ ﺭﺩ ﻩﺩﺎﻔﺘﺳﺍ ﺩﺭﻮﻣ ﺮﯿﻐﺘﻣ ﻪﮐ ﺪﯿﻨﮑﻧ ﺵﻮﻣﺍﺮﻓ ﺖﺳﺍ while ﻪﻘﻠﺣ ﻪﮐ ﺪﺷ ﺪﯿﻫﺍﻮﺧ ﻪﺟﻮﺘﻣ ،ﺪﯿﺷﺎﺑ ﻩﺪﻧﺍﻮﺧ for ﻪﻘﻠﺣ ﺩﺭﻮﻣ ﺭﺩ ﺍﺭ ﻞﺒﻗ ﻞﺼﻓ ﺮﮔﺍ .ﺪﻨﮐ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﻦﯿﺷﺎﻣ ﯼﺭﻭﺁ ﻊﻤﺟ ﯼﺍﺮﺑ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ ﯼﺭﻭﺁ ﻊﻤﺟ ﯼﺍﺮﺑ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ ﻮﺤﻧ
while (condition) {
// code block to be executed
}
ﻝﺎﺜﻣ
ﻝﺎﺜﻣ
while (i < 10) {
text += "The number is " + i;
i++;
}
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript While Loop</h2>
<p id="demo"></p>
<script>
let text = "";
let i = 0;
while (i < 10) {
text += "<br>The number is " + i;
i++;
}
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>
do while
ﻪﻘﻠﺣdo while
ﻪ ﻮﺤﻧ
do {
// code block to be executed
}
while (condition);
ﻝﺎﺜﻣ
do while
ﻪﻘﻠﺣ ﮏ ﻝﺎﺜﻣ
do {
text += "The number is " + i;
i++;
}
while (i < 10);
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Do While Loop</h2>
<p id="demo"></p>
<script>
let text = ""
let i = 0;
do {
text += "<br>The number is " + i;
i++;
}
while (i < 10);
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>
while
ﻭ ﯼﺍﺮﺑ
ﻪﺴﯾﺎﻘﻣ
for
ﻪﻘﻠﺣ ﮏﯾ ﺯﺍ ﻝ ﻝﺎﺜﻣ
const cars = ["BMW", "Volvo", "Saab", "Ford"];
let i = 0;
let text = "";
for (;cars[i];) {
text += cars[i];
i++;
}
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
const cars = ["BMW", "Volvo", "Saab", "Ford"];
let i = 0;
let text = "";
for (;cars[i];) {
text += cars[i] + "<br>";
i++;
}
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>
ﻪﮐ ﯽﻟﺎﺣ ﺭﺩ<"code class="w3-codespan> ﻪﻘﻠﺣ ﮏﯾ ﺯﺍ ﻝﺎﺜﻣ ﻦﯾﺍ ﺭﺩ ﻪﻘﻠﺣ
ﻝﺎﺜﻣ
const cars = ["BMW", "Volvo", "Saab", "Ford"];
let i = 0;
let text = "";
while (cars[i]) {
text += cars[i];
i++;
}
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
const cars = ["BMW", "Volvo", "Saab", "Ford"];
let i = 0;
let text = "";
while (cars[i]) {
text += cars[i] + "<br>";
i++;
}
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>