.(ﺎﻫ ﻪﯾﺍﺭﺁ ﺪﻨﻧﺎﻣ) ﺪﻨﺘﺴﻫ ﺮﯾﺬﭘﺭﺍﺮﮑﺗ ﯼﺎﯿﺷﺍ ﺎﻫ ﻩﺪﻧﻮﺷ ﺭﺍﺮﮑﺗ
.ﺖﺷﺍﺩ ﯽﺳﺮﺘﺳﺩ ﺎﻫﺭﺍﺮﮑﺗ ﻪﺑ ﻥﺍﻮﺗ ﯽﻣ ﺪﻣﺁﺭﺎﮐ ﻭ ﻩﺩﺎﺳ ﯼﺎﻫﺪﮐ ﺎﺑ
.ﺩﺮﮐ ﺭﺍﺮﮑﺗ for..of
ﯼﺎﻫ ﻪﻘﻠﺣ ﺎﺑ ﻥﺍﻮﺗ ﯽﻣ ﺍﺭ ﺎﻫﺮﯾﺬﭘﺭﺍﺮﮑ
.ﺖﺳﺍ ﮎﺭﺩ ﻞﺑﺎﻗ ﯽﺘﺣﺍﺭ ﻪﺑ ﺭﺍﺮﮑﺗ .ﺖﺳﺍ ﺮﺻﺎﻨﻋ ﺯﺍ ﻪﻟﺎﺒﻧﺩ ﮏﯾ ﯼﻭﺭ ﺮﺑ ﻥﺩﺯ ﻪﻘﻠﺣ ﯼﺎﻨﻌﻣ ﻪﺑ ﯽﮔﺩﺎﺳ ﻪﺑ ﻦﯾﺍ :ﺖﺳﺍ ﻩﺪﺷ ﻩﺩﺭﻭﺁ ﻥﺎﺳﺁ ﻪﻧﻮﻤﻧ ﺪﻨﭼ ﺎﺠﻨﯾﺍ ﺭﺩ ﻪﺘﺷﺭ ﮏﯾ ﯼﻭﺭ ﺭﺍﺮﮑﺗ ﻪﯾﺍﺭﺁ ﮏﯾ ﯼﻭﺭ ﺭﺍﺮﮑﺗ :ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﻪﺘﺷﺭ ﮏﯾ ﺮﺻﺎﻨﻋ ﯼﻭﺭ ﺭﺍﺮﮑﺗ ﯼﺍﺮﺑ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﻪﯾﺍﺭﺁ ﮏﯾ ﺮﺻﺎﻨﻋ ﯼﻭﺭ ﺭﺍﺮﮑﺗ ﯼﺍﺮﺑ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ .ﺪﯾﺯﻮﻣﺎﯿﺑ JS Object Iterables ﻞﺼﻓ ﺭﺩ Iterables ﺩﺭﻮﻣ ﺭﺩ ﯼﺮﺘﺸﯿﺑ ﺕﺎﯿﺋﺰﺟ ﺪﯿﻧﺍﻮﺗ ﯽﻣ ﺎﻤﺷ :ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﻪﻋﻮﻤﺠﻣ ﮏﯾ ﺮﺻﺎﻨﻋ ﯼﻭﺭ ﺭﺍﺮﮑﺗ ﯼﺍﺮﺑ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ .ﺖﺳﺍ ﻩﺪﺷ ﻩﺩﺍﺩ ﺶﺷﻮﭘ ﯼﺪﻌﺑ ﯼﺎﻫ ﻞﺼﻓ ﺭﺩ ﺎﻫ ﻪﺸﻘﻧ ﻭ ﺎﻫ ﻪﻋﻮﻤﺠﻣ :ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﻪﺸﻘﻧ ﺮﺻﺎﻨﻋ ﯼﻭﺭ ﺭﺍﺮﮑﺗ ﯼﺍﺮﺑ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ ﻮﺤﻧ
for (variable of iterable) {
// code block to be executed
}
ﺭﺍﺮﮑﺗ ﻝﺎﺣ ﺭﺩ
ﻪﺘﺷﺭ ﮏﯾ ﺯﺍ ﺶﯿﺑ ﺭﺍﺮﮑﺗ
for..of
ﻪ ﻝﺎﺜﻣ
const name = "W3Schools";
for (const x of name) {
// code block to be executed
}
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Iterables</h2>
<p>Iterate over a String:</p>
<p id="demo"></p>
<script>
// Create a String
const name = "W3Schools";
// List all Elements
let text = ""
for (const x of name) {
text += x + "<br>";
}
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>
ﻪﯾﺍﺭﺁ ﮏﯾ ﯼﻭﺭ ﺭﺍﺮﮑﺗ
for..of
ﻝﺎﺜﻣ
const letters = ["a","b","c"];
for (const x of letters) {
// code block to be executed
}
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Iterables</h2>
<p>Iterate over an Array:</p>
<p id="demo"></p>
<script>
// Create aa Array
const letters = ["a","b","c"];
// List all Elements
let text = "";
for (const x of letters) {
text += x + "<br>";
}
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>
ﻪﻋﻮﻤﺠﻣ ﮏﯾ ﺯﺍ ﺶﯿﺑ ﺭﺍﺮﮑﺗ
for..of
ﻝﺎﺜﻣ
const letters = new Set(["a","b","c"]);
for (const x of letters) {
// code block to be executed
}
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Iterables</h2>
<p>Iterate over a Set:</p>
<p id="demo"></p>
<script>
// Create a Set
const letters = new Set(["a","b","c"]);
// List all Elements
let text = "";
for (const x of letters) {
text += x + "<br>";
}
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>
ﻪﺸﻘﻧ ﯼﻭﺭ ﺭﺍﺮﮑﺗ
for..of
ﻪﻘﻠﺣ ﻝﺎﺜﻣ
const fruits = new Map([
["apples", 500],
["bananas", 300],
["oranges", 200]
]);
for (const x of fruits) {
// code block to be executed
}
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Iterables</h2>
<p>Iterate over a Map:</p>
<p id="demo"></p>
<script>
// Create a Map
const fruits = new Map([
["apples", 500],
["bananas", 300],
["oranges", 200]
]);
// List all entries
let text = "";
for (const x of fruits) {
text += x + "<br>";
}
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>