ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫﺭﺍﺮﮑﺗ


فهرست مطالب

    نمایش فهرست مطالب

.(ﺎﻫ ﻪﯾﺍﺭﺁ ﺪﻨﻧﺎﻣ) ﺪﻨﺘﺴﻫ ﺮﯾﺬﭘﺭﺍﺮﮑﺗ ﯼﺎﯿﺷﺍ ﺎﻫ ﻩﺪﻧﻮﺷ ﺭﺍﺮﮑﺗ

.ﺖﺷﺍﺩ ﯽﺳﺮﺘﺳﺩ ﺎﻫﺭﺍﺮﮑﺗ ﻪﺑ ﻥﺍﻮﺗ ﯽﻣ ﺪﻣﺁﺭﺎﮐ ﻭ ﻩﺩﺎﺳ ﯼﺎﻫﺪﮐ ﺎﺑ

.ﺩﺮﮐ ﺭﺍﺮﮑﺗ for..of ﯼﺎﻫ ﻪﻘﻠﺣ ﺎﺑ ﻥﺍﻮﺗ ﯽﻣ ﺍﺭ ﺎﻫﺮﯾﺬﭘﺭﺍﺮﮑ

ﻪﻘﻠﺣ ﯼﺍﺮﺑ

for..of

ﻮﺤﻧ

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>

.ﺪﯾﺯﻮﻣﺎﯿﺑ JS Object Iterables ﻞﺼﻓ ﺭﺩ Iterables ﺩﺭﻮﻣ ﺭﺩ ﯼﺮﺘﺸﯿﺑ ﺕﺎﯿﺋﺰﺟ ﺪﯿﻧﺍﻮﺗ ﯽﻣ ﺎﻤﺷ



ﻪﻋﻮﻤﺠﻣ ﮏﯾ ﺯﺍ ﺶﯿﺑ ﺭﺍﺮﮑﺗ

:ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﻪﻋﻮﻤﺠﻣ ﮏﯾ ﺮﺻﺎﻨﻋ ﯼﻭﺭ ﺭﺍﺮﮑﺗ ﯼﺍﺮﺑ 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>