.ﺪﻨﻨﮐ ﯽﻣ ﻞﻤﻋ ﯼﺍ ﻪﯾﺍﺭﺁ ﻢﺘﯾﺁ ﺮﻫ ﯼﻭﺭ ﻪﯾﺍﺭﺁ ﺭﺍﺮﮑﺗ ﯼﺎﻫ ﺵﻭﺭ
forEach() ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﯾﺍﺭﺁ.ﺪﻨﮐ ﯽﻣ ﯽﻧﺍﻮﺧﺍﺮﻓ ﺍﺭ (ﺱﺎﻤﺗ ﻪﺑ ﺦﺳﺎﭘ ﻊﺑﺎﺗ ﮏﯾ) ﻊﺑﺎﺗ ﮏﯾ ﺭﺎﺑ ﮏﯾ ﻪﯾﺍﺭﺁ ﺮﺼﻨﻋ ﺮﻫ ﯼﺍﺮﺑ forEach()
const numbers = [45, 4, 9, 16, 25];
let txt = "";
numbers.forEach(myFunction);
function myFunction(value, index, array) {
txt += value + "<br>";
}→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The forEach() Method</h2>
<p>Call a function once for each array element:</p>
<p id="demo"></p>
<script>
const numbers = [45, 4, 9, 16, 25];
let txt = "";
numbers.forEach(myFunction);
document.getElementById("demo").innerHTML = txt;
function myFunction(value, index, array) {
txt += value + "<br>";
}
</script>
</body>
</html>
:ﺩﺮﯿﮔ ﯽﻣ ﻥﺎﻣﻮﮔﺭﺁ 3 ﻊﺑﺎﺗ ﻪﮐ ﺪﯿﺷﺎﺑ ﻪﺘﺷﺍﺩ ﻪﺟﻮﺗ
ﺩﺭﻮﻣ ﺵﺯﺭﺍ
ﻢﺘﯾﺁ ﺺﺧﺎﺷ
ﻪﯾﺍﺭﺁ ﺩﻮﺧ
ﺩﺮﮐ ﯽﺴﯾﻮﻧﺯﺎﺑ ﻥﺍﻮﺗ ﯽﻣ ﺍﺭ ﻝﺎﺜﻣ .ﺪﻨﮐ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﺭﺍﺪﻘﻣ ﺮﺘﻣﺍﺭﺎﭘ ﺯﺍ ﻂﻘﻓ ﻻﺎﺑ ﻝﺎﺜﻣ
const numbers = [45, 4, 9, 16, 25];
let txt = "";
numbers.forEach(myFunction);
function myFunction(value) {
txt += value + "<br>";
}→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The forEach() Method</h2>
<p>Call a function once for each array element:</p>
<p id="demo"></p>
<script>
const numbers = [45, 4, 9, 16, 25];
let txt = "";
numbers.forEach(myFunction);
document.getElementById("demo").innerHTML = txt;
function myFunction(value) {
txt += value + "<br>";
}
</script>
</body>
</html>
map() ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﯾﺍﺭﺁ .ﺪﻨﮐ ﯽﻣ ﺩﺎﺠﯾﺍ ﻪﯾﺍﺭﺁ ﺮﺼﻨﻋ ﺮﻫ ﯼﻭﺭ ﻊﺑﺎﺗ ﮏﯾ ﻡﺎﺠﻧﺍ ﺎﺑ ﺪﯾﺪﺟ ﻪﯾﺍﺭﺁ ﮏﯾ map() ﺵﻭﺭ
ﺪﻨﮐ ﯽﻤﻧ ﺍﺮﺟﺍ ﺍﺭ ﻪﯾﺍﺭﺁ ﻊﺑﺎﺗ map() ﺵﻭﺭ
.ﺪﻫﺩ ﯽﻤﻧ ﺮﯿﯿﻐﺗ ﺍﺭ ﯽﻠﺻﺍ ﻪﯾﺍﺭﺁ map() ﺵﻭﺭ
:ﺪﻨﮐ ﯽﻣ ﺏﺮﺿ 2 ﺭﺩ ﺍﺭ ﻪﯾﺍﺭﺁ ﺮﻫ ﺭﺍﺪﻘﻣ ﻝﺎﺜﻣ ﻦﯾﺍ
const numbers1 = [45, 4, 9, 16, 25];
const numbers2 = numbers1.map(myFunction);
function myFunction(value, index, array) {
return value * 2;
}→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The map() Method</h2>
<p>Create a new array by performing a function on each array element:</p>
<p id="demo"></p>
<script>
const numbers1 = [45, 4, 9, 16, 25];
const numbers2 = numbers1.map(myFunction);
document.getElementById("demo").innerHTML = numbers2;
function myFunction(value, index, array) {
return value * 2;
}
</script>
</body>
</html>
:ﺩﺮﯿﮔ ﯽﻣ ﻥﺎﻣﻮﮔﺭﺁ 3 ﻊﺑﺎﺗ ﻪﮐ ﺪﯿﺷﺎﺑ ﻪﺘﺷﺍﺩ ﻪﺟﻮﺗ
ﺩﺭﻮﻣ ﺵﺯﺭﺍ
ﻢﺘﯾﺁ ﺺﺧﺎﺷ
ﻪﯾﺍﺭﺁ ﺩﻮﺧ
ﺪﻨﮐ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﻪﯾﺍﺭﺁ ﻭ ﺺﺧﺎﺷ ،ﺭﺍﺪﻘﻣ ﺮﺘﻣﺍﺭﺎﭘ ﺯﺍ ﻂﻘﻓ ﺱﺎﻤﺗ ﻪﺑ ﺦﺳﺎﭘ ﻊﺑﺎﺗ ﮏﯾ ﻪﮐ ﯽﻣﺎﮕﻨﻫ
const numbers1 = [45, 4, 9, 16, 25];
const numbers2 = numbers1.map(myFunction);
function myFunction(value) {
return value * 2;
}→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The map() Method</h2>
<p>Create a new array by performing a function on each array element:</p>
<p id="demo"></p>
<script>
const numbers1 = [45, 4, 9, 16, 25];
const numbers2 = numbers1.map(myFunction);
document.getElementById("demo").innerHTML = numbers2;
function myFunction(value) {
return value * 2;
}
</script>
</body>
</html>
flatMap() ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﯾﺍﺭﺁES2019 ﺪﺘﻣ Array flatMap() ﺩﺮﮐ ﻪﻓﺎﺿﺍ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﺑ ﺍﺭ.
.ﺪﻨﮐ ﯽﻣ ﻢﯿﺳﺮﺗ ﺍﺭ ﻪﯾﺍﺭﺁ ﮏﯾ ﺮﺻﺎﻨﻋ ﻪﻤﻫ ﺍﺪﺘﺑﺍ flatMap() ﺵﻭﺭ
const myArr = [1, 2, 3, 4, 5, 6];
const newArr = myArr.flatMap((x) => x * 2);→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The flatMap() Method</h2>
<p id="demo"></p>
<script>
const myArr = [1, 2, 3, 4, 5,6];
const newArr = myArr.flatMap((x) => x * 2);
document.getElementById("demo").innerHTML = newArr;
</script>
</body>
</html>
:ﺩﻮﺷ ﯽﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ 2020 ﻪﯾﻮﻧﺍﮊ ﺯﺍ ﻥﺭﺪﻣ ﯼﺎﻫﺮﮔﺭﻭﺮﻣ ﻪﻤﻫ ﺭﺩ flatMap() ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﯾﺍﺭﺁ
| Chrome 69 | Edge 79 | Firefox 62 | Safari 12 | Opera 56 |
| Sep 2018 | Jan 2020 | Sep 2018 | Sep 2018 | Sep 2018 |
filter() ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﯾﺍﺭﺁ.ﺩﺭﺍﺬﮔ ﯽﻣ ﺮﺳ ﺖﺸﭘ ﺖﯿﻘﻓﻮﻣ ﺎﺑ ﺍﺭ ﺶﯾﺎﻣﺯﺁ ﮏﯾ ﻪﮐ ﺪﻨﮐ ﯽﻣ ﺩﺎﺠﯾﺍ ﻪﯾﺍﺭﺁ ﺮﺻﺎﻨﻋ ﺎﺑ ﺪﯾﺪﺟ ﻪﯾﺍﺭﺁ ﮏﯾ filter
:ﺪﻨﮐ ﯽﻣ ﺩﺎﺠﯾﺍ 18 ﺯﺍ ﺮﺘﮔﺭﺰﺑ ﺭﺍﺪﻘﻣ ﺎﺑ ﺮﺻﺎﻨﻋ ﺯﺍ ﺪﯾﺪﺟ ﻪﯾﺍﺭﺁ ﮏﯾ ﻝﺎﺜﻣ ﻦﯾﺍ
const numbers = [45, 4, 9, 16, 25];
const over18 = numbers.filter(myFunction);
function myFunction(value, index, array) {
return value > 18;
} → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The filter() Method</h2>
<p>Create a new array from all array elements that passes a test:</p>
<p id="demo"></p>
<script>
const numbers = [45, 4, 9, 16, 25];
const over18 = numbers.filter(myFunction);
document.getElementById("demo").innerHTML = over18;
function myFunction(value, index, array) {
return value > 18;
}
</script>
</body>
</html>
:ﺩﺮﯿﮔ ﯽﻣ ﻥﺎﻣﻮﮔﺭﺁ 3 ﻊﺑﺎﺗ ﻪﮐ ﺪﯿﺷﺎﺑ ﻪﺘﺷﺍﺩ ﻪﺟﻮﺗ
ﺩﺭﻮﻣ ﺵﺯﺭﺍ
ﻢﺘﯾﺁ ﺺﺧﺎﺷ
ﻪﯾﺍﺭﺁ ﺩﻮﺧ
ﺪﻨﮐ ﯽﻤﻧ ﻩﺩﺎﻔﺘﺳﺍ ﻪﯾﺍﺭﺁ ﻭ ﺺﺧﺎﺷ ﺯﺍ callback ﻊﺑﺎﺗ ،ﻻﺎﺑ ﻝﺎﺜﻣ ﺭﺩ
const numbers = [45, 4, 9, 16, 25];
const over18 =
numbers.filter(myFunction);
function myFunction(value) {
return value > 18;
} → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The filter() Method</h2>
<p>Create a new array with all array elements that passes a test.</p>
<p id="demo"></p>
<script>
const numbers = [45, 4, 9, 16, 25];
const over18 = numbers.filter(myFunction);
document.getElementById("demo").innerHTML = over18;
function myFunction(value) {
return value > 18;
}
</script>
</body>
</html>
reduce() ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﯾﺍﺭﺁ.(ﺪﻫﺩ ﺶﻫﺎﮐ ﻥﺁ ﻪﺑ) ﺪﻨﮐ ﺪﯿﻟﻮﺗ ﺪﺣﺍﻭ ﺭﺍﺪﻘﻣ ﮏﯾ ﺎﺗ ﺪﻨﮐ ﯽﻣ ﺍﺮﺟﺍ ﻪﯾﺍﺭﺁ ﺮﺼﻨﻋ ﺮﻫ ﯼﻭﺭ ﺍﺭ ﻊﺑﺎﺗ ﮏﯾ reduc
.ﺪﯿﻨﮐ ﻪﻌﺟﺍﺮﻣ .ﺪﻫﺩ ﯽﻤﻧ ﺶﻫﺎﮐ ﺍﺭ ﯽﻠﺻﺍ ﻪﯾﺍﺭﺁ reduce() ﺵﻭﺭ :ﺪﻨﮐ ﯽﻣ ﺍﺪﯿﭘ ﺍﺭ ﻪﯾﺍﺭﺁ ﮏﯾ ﺩﺍﺪﻋﺍ ﻡﺎﻤﺗ ﻉﻮﻤﺠﻣ ﻝﺎﺜﻣ ﻦﯾﺍ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﻥﺎﺗﺩﻮﺧ :ﺩﺮﯿﮔ ﯽﻣ ﻥﺎﻣﻮﮔﺭﺁ 4 ﻊﺑﺎﺗ ﻪﮐ ﺪﯿﺷﺎﺑ ﻪﺘﺷﺍﺩ ﻪﺟﻮﺗ (ﯽﻠﺒﻗ ﯽﺘﺸﮔﺮﺑ ﺭﺍﺪﻘﻣ/ﻪﯿﻟﻭﺍ ﺭﺍﺪﻘﻣ) ﻞﮐ ﺩﺭﻮﻣ ﺵﺯﺭﺍ ﻢﺘﯾﺁ ﺺﺧﺎﺷ ﻪﯾﺍﺭﺁ ﺩﻮﺧ ﻪﺷﺎﺑ ﻪﻧﻮﺘﯿﻣ .ﺪﻨﮐ ﯽﻤﻧ ﻩﺩﺎﻔﺘﺳﺍ ﻪﯾﺍﺭﺁ ﻭ ﺺﺧﺎﺷ ﯼﺎﻫﺮﺘﻣﺍﺭﺎﭘ ﺯﺍ ﻻﺎﺑ ﻝﺎﺜﻣ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﻥﺎﺗﺩﻮﺧ :ﺩﺮﯾﺬﭙﺑ ﺍﺭ ﻪﯿﻟﻭﺍ ﺭﺍﺪﻘﻣ ﮏﯾ ﺪﻧﺍﻮﺗ ﯽﻣ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﻥﺎﺗﺩﻮﺧ .(ﺪﻫﺩ ﺶﻫﺎﮐ ﻥﺁ ﻪﺑ ﺍﺭ ﻥﺁ) ﺪﻨﮐ ﺪﯿﻟﻮﺗ ﺪﺣﺍﻭ ﺭﺍﺪﻘﻣ ﮏﯾ ﺎﺗ ﺪﻨﮐ ﯽﻣ ﺍﺮﺟﺍ ﻪﯾﺍﺭﺁ ﺮﺼﻨﻋ ﺮﻫ ﯼﻭﺭ ﺍﺭ ﻊﺑﺎﺗ ﮏﯾ .ﺪﻫﺩ ﯽﻤﻧ ﺶﻫﺎﮐ ﺍﺭ ﯽﻠﺻﺍ ﻪﯾﺍﺭﺁ reduceRight() ﺵﻭﺭ :ﺪﻨﮐ ﯽﻣ ﺍﺪﯿﭘ ﺍﺭ ﻪﯾﺍﺭﺁ ﮏﯾ ﺩﺍﺪﻋﺍ ﻡﺎﻤﺗ ﻉﻮﻤﺠﻣ ﻝﺎﺜﻣ ﻦﯾﺍ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﻥﺎﺗﺩﻮﺧ :ﺩﺮﯿﮔ ﯽﻣ ﻥﺎﻣﻮﮔﺭﺁ 4 ﻊﺑﺎﺗ ﻪﮐ ﺪﯿﺷﺎﺑ ﻪﺘﺷﺍﺩ ﻪﺟﻮﺗ (ﯽﻠﺒﻗ ﯽﺘﺸﮔﺮﺑ ﺭﺍﺪﻘﻣ/ﻪﯿﻟﻭﺍ ﺭﺍﺪﻘﻣ) ﻞﮐ ﺩﺭﻮﻣ ﺵﺯﺭﺍ ﻢﺘﯾﺁ ﺺﺧﺎﺷ ﻪﯾﺍﺭﺁ ﺩﻮﺧ ﻪﺷﺎﺑ ﻪﻧﻮﺘﯿﻣ .ﺪﻨﮐ ﯽﻤﻧ ﻩﺩﺎﻔﺘﺳﺍ ﻪﯾﺍﺭﺁ ﻭ ﺺﺧﺎﺷ ﯼﺎﻫﺮﺘﻣﺍﺭﺎﭘ ﺯﺍ ﻻﺎﺑ ﻝﺎﺜﻣ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﻥﺎﺗﺩﻮﺧ .ﺮﯿﺧ ﺎﯾ ﺪﻨﻨﮐﯽﻣ ﺭﻮﺒﻋ ﻥﻮﻣﺯﺁ ﺯﺍ ﻪﯾﺍﺭﺁ ﺮﯾﺩﺎﻘﻣ ﻪﻤﻫ ﺎﯾﺁ ﻪﮐ ﺪﻨﮐﯽﻣ ﯽﺳﺭﺮﺑ :ﺪﻨﺘﺴﻫ 18 ﺯﺍ ﺮﺘﮔﺭﺰﺑ ﻪﯾﺍﺭﺁ ﺮﯾﺩﺎﻘﻣ ﻪﻤﻫ ﺎﯾﺁ ﻪﮐ ﺪﻨﮐ ﯽﻣ ﯽﺳﺭﺮﺑ ﻝﺎﺜﻣ ﻦﯾﺍ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﻥﺎﺗﺩﻮﺧ :ﺩﺮﯿﮔ ﯽﻣ ﻥﺎﻣﻮﮔﺭﺁ 3 ﻊﺑﺎﺗ ﻪﮐ ﺪﯿﺷﺎﺑ ﻪﺘﺷﺍﺩ ﻪﺟﻮﺗ ﺩﺭﻮﻣ ﺵﺯﺭﺍ ﻢﺘﯾﺁ ﺺﺧﺎﺷ ﻪﯾﺍﺭﺁ ﺩﻮﺧ ﺪﻨﮐ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﺮﮕﯾﺩ ﺮﺘﻣﺍﺭﺎﭘ ﺯﺍ ،(ﺭﺍﺪﻘﻣ) ﻝﻭﺍ ﺮﺘﻣﺍﺭﺎﭘ ﺯﺍ ﺎﻬﻨﺗ ﺱﺎﻤﺗ ﻪﺑ ﺦﺳﺎﭘ ﻊﺑﺎﺗ ﮏﯾ ﻪﮐ ﯽﻣﺎﮕﻨﻫ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﻥﺎﺗﺩﻮﺧ .ﺮﯿﺧ ﺎﯾ ﺪﻨﻨﮐﯽﻣ ﺭﻮﺒﻋ ﻥﻮﻣﺯﺁ ﺯﺍ ﻪﯾﺍﺭﺁ ﺮﯾﺩﺎﻘﻣ ﺯﺍ ﯽﺧﺮﺑ ﺎﯾﺁ ﻪﮐ ﺪﻨﮐﯽﻣ ﯽﺳﺭﺮﺑ some() :ﺪﻨﺘﺴﻫ 18 ﺯﺍ ﺮﺘﮔﺭﺰﺑ ﻪﯾﺍﺭﺁ ﺮﯾﺩﺎﻘﻣ ﺯﺍ ﯽﺧﺮﺑ ﺎﯾﺁ ﻪﮐ ﺪﻨﮐ ﯽﻣ ﯽﺳﺭﺮﺑ ﻝﺎﺜﻣ ﻦﯾﺍ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﻥﺎﺗﺩﻮﺧ :ﺩﺮﯿﮔ ﯽﻣ ﻥﺎﻣﻮﮔﺭﺁ 3 ﻊﺑﺎﺗ ﻪﮐ ﺪﯿﺷﺎﺑ ﻪﺘﺷﺍﺩ ﻪﺟﻮﺗ ﺩﺭﻮﻣ ﺵﺯﺭﺍ ﻢﺘﯾﺁ ﺺﺧﺎﺷ ﻪﯾﺍﺭﺁ ﺩﻮﺧ .ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ ﻥﺁ ﺖﯿﻌﻗﻮﻣ ﻭ ﺪﻨﮐ ﯽﻣ ﻮﺠﺘﺴﺟ ﺮﺼﻨﻋ ﺭﺍﺪﻘﻣ ﮏﯾ ﯼﺍﺮﺑ ﺍﺭ ﻪﯾﺍﺭﺁ ﮏﯾ ﻪﺟﻮﺗ: ﺖﺳﺍ ﻩﺮﯿﻏ ﻭ 1 ﺖﯿﻌﻗﻮﻣ ﯼﺍﺭﺍﺩ ﻡﻭﺩ ﺩﺭﻮﻣ ،0 ﺖﯿﻌﻗﻮﻣ ﯼﺍﺭﺍﺩ ﻝﻭﺍ ﺩﺭﻮﻣ. :ﺪﯿﻨﮐ ﻮﺠﺘﺴﺟ "Apple" ﺩﺭﻮﻣ ﯼﺍﺮﺑ ﻪﯾﺍﺭﺁ ﮏﯾ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﻥﺎﺗﺩﻮﺧ ﺩﻮﺷ ﻮﺠﺘﺴﺟ ﺪﯾﺎﺑ ﻪﮐ ﯼﺩﺭﻮﻣ .ﯼﺭﻭﺮﺿ .ﺪﻨﻨﮐ ﯽﻣ ﻮﺠﺘﺴﺟ ﺎﻬﺘﻧﺍ ﺎﺗ ﻭ ﺪﻨﻨﮐ ﯽﻣ ﺵﺭﺎﻤﺷ ﺎﻬﺘﻧﺍ ﺯﺍ ﻭ ﺪﻧﻮﺷ ﯽﻣ ﻉﻭﺮﺷ ﻩﺪﺷ ﻩﺩﺍﺩ ﺖﯿﻌﻗﻮﻣ ﺭﺩ ﯽﻔﻨﻣ ﺮﯾﺩﺎﻘﻣ ﻢﯿﻨﮐ ﻉﻭﺮﺷ ﺎﺠﮐ ﺯﺍ ﺍﺭ ﻮﺠ ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ ﻝﻭﺍ ﺩﺭﻮﻣ ﺖﯿﻌﻗﻮﻣ ،ﺪﺷﺎﺑ ﻪﺘﺷﺍﺩ ﺩﻮﺟﻭ ﺭﺎﺑ ﮏﯾ ﺯﺍ ﺶﯿﺑ ﺩﺭﻮﻣ ﺮﮔﺍ :ﺪﯿﻨﮐ ﻮﺠﺘﺴﺟ "Apple" ﺩﺭﻮﻣ ﯼﺍﺮﺑ ﻪﯾﺍﺭﺁ ﮏﯾ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ ﺩﻮﺷ ﻮﺠﺘﺴﺟ ﺪﯾﺎﺑ ﻪﮐ ﯼﺩﺭﻮﻣ .ﯼﺭﻭﺮﺿ ﺪﻨﻨﮐ ﯽﻣ ﻮﺠﺘﺴﺟ ﺍﺪﺘﺑﺍ ﺎﺗ ﻭ ﺪﻨﻨﮐ ﯽﻣ ﺵﺭﺎﻤﺷ ﺎﻬﺘﻧﺍ ﺯﺍ ﻭ ﺪﻧﻮﺷ ﯽﻣ ﻉﻭﺮﺷ ﻩﺪﺷ ﻩﺩﺍﺩ ﺖﯿﻌﻗﻮﻣ ﺭﺩ ﯽﻔﻨﻣ ﺮﯾﺩﺎﻘﻣ ﻢﯿﻨﮐ ﻉﻭﺮﺷ ﺎﺠﮐ ﺯﺍ ﺍﺭ ﻮﺠﺘ .ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ ﯼﺍ ﻪﯾﺍﺭﺁ ﺮﺼﻨﻋ ﻦﯿﻟﻭﺍ ﺭﺍﺪﻘﻣ .(ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ ﻥﺁ ﺭﺍﺪﻘﻣ) ﺪﻨﮐ ﯽﻣ ﺍﺪﯿﭘ ﺍﺭ ﺮﺘﮔﺭﺰﺑ ﺮﺼﻨﻋ ﻦﯿﻟﻭﺍ ﻝﺎﺜﻣ ﻦﯾﺍ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺩﺮﯿﮔ ﯽﻣ ﻥﺎﻣﻮﮔﺭﺁ 3 ﻊﺑﺎﺗ ﻪﮐ ﺪﯿﺷﺎﺑ ﻪﺘﺷﺍﺩ ﻪﺟﻮﺗ ﺩﺭﻮﻣ ﺵﺯﺭﺍ ﻢﺘﯾﺁ ﺺﺧﺎﺷ ﻪﯾﺍﺭﺁ ﺩﻮﺧ :ﺩﻮﺷ ﯽﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ ﻥﺭﺪﻣ ﯼﺎﻫﺮﮔﺭﻭﺮﻣ ﻡﺎﻤﺗ ﺭﺩ .ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ ﻪﯾﺍﺭﺁ ﺮﺼﻨﻋ ﻦﯿﻟﻭﺍ ﺲﮐﺪﻨﯾﺍ :ﺪﻨﮐ ﯽﻣ ﺍﺪﯿﭘ ﺖﺳﺍ 18 ﺯﺍ ﺮﺘﮔﺭﺰﺑ ﻪﮐ ﺍﺭ ﺮﺼﻨﻋ ﻦﯿﻟﻭﺍ ﺺﺧﺎﺷ ﻝﺎﺜﻣ ﻦﯾﺍ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺩﺮﯿﮔ ﯽﻣ ﻥﺎﻣﻮﮔﺭﺁ 3 ﻊﺑﺎﺗ ﻪﮐ ﺪﯿﺷﺎﺑ ﻪﺘﺷﺍﺩ ﻪﺟﻮﺗ ﺩﺭﻮﻣ ﺵﺯﺭﺍ ﻢﺘﯾﺁ ﺺﺧﺎﺷ ﻪﯾﺍﺭﺁ ﺩﻮﺧ :ﺩﻮﺷ ﯽﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ ﻥﺭﺪﻣ ﯼﺎﻫﺮﮔﺭﻭﺮﻣ ﻡﺎﻤﺗ ﺭﺩ .ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﻝﻮﻃ ﺎﺑ ﯽﺷ ﺮﻫ ﺯﺍ ﺍﺭ ﻪﯾﺍﺭﺁ ﯽﺷ ﮏﯾ :ﻪﺘﺷﺭ ﮏﯾ ﺯﺍ ﻪﯾﺍﺭﺁ ﮏﯾ ﺩﺎﺠﯾﺍ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺩﻮﺷ ﯽﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ ﻥﺭﺪﻣ ﯼﺎﻫﺮﮔﺭﻭﺮﻣ ﻡﺎﻤﺗ ﺭﺩ .ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﻪﯾﺍﺭﺁ ﮏﯾ ﯼﺎﻫﺪﯿﻠﮐ ﺎﺑ ﺍﺭ Array Iterator ﯽﺷ ﮏﯾ :ﺖﺳﺍ ﻪﯾﺍﺭﺁ ﯼﺎﻫﺪﯿﻠﮐ ﯼﻭﺎﺣ ﻪﮐ ﺪﯿﻨﮐ ﺩﺎﺠﯾﺍ Array Iterator ﯽﺷ ﮏﯾ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺩﻮﺷ ﯽﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ ﻥﺭﺪﻣ ﯼﺎﻫﺮﮔﺭﻭﺮﻣ ﻡﺎﻤﺗ ﺭﺩ :ﺪﯿﻨﮐ ﺭﺍﺮﮑﺗ ﺭﺍﺪﻘﻣ/ﺪﯿﻠﮐ ﯼﺎﻫ ﺖﻔﺟ ﯼﻭﺭ ﺲﭙﺳ ﻭ ﺪﯿﻨﮐ ﺩﺎﺠﯾﺍ Array Iterator ﮏﯾ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺭﺍﺪﻘﻣ/ﺪﯿﻠﮐ ﯼﺎﻫﺖﻔﺟ ﺎﺑ ﺍﺭ Array Iterator ءﯽﺷ ﮏﯾ ["ﻪﺒﻧﺍ" ،3] .ﺪﻫﺩ ﯽﻤﻧ ﺮﯿﯿﻐﺗ ﺍﺭ ﯽﻠﺻﺍ ﻪﯾﺍﺭﺁ :ﺩﻮﺷ ﯽﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ ﻥﺭﺪﻣ ﯼﺎﻫﺮﮔﺭﻭﺮﻣ ﻡﺎﻤﺗ ﺭﺩ ECMAScript 2016 → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ Array.includes() ﺮﯾﺩﺎﻘﻣ ﺎﺗ ﺪﻫﺩ ﯽﻣ ﻩﺯﺎﺟﺍ NaN ﻑﻼﺧﺮﺑ .ﺪﯿﻨﮐ ﯽﺳﺭﺮﺑ ﺍﺭ Array.indexOf(). :ﺩﻮﺷ ﯽﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ ﻥﺭﺪﻣ ﯼﺎﻫﺮﮔﺭﻭﺮﻣ ﻡﺎﻤﺗ ﺭﺩ :ﺪﻫﺩ ﯽﻣ ﺵﺮﺘﺴﮔ ﯼﺮﺘﺸﯿﺑ ﺮﺻﺎﻨﻋ ﻪﺑ ﺍﺭ (ﻪﯾﺍﺭﺁ ﮏﯾ ﺪﻨﻧﺎﻣ) ﺮﯾﺬﭘ ﺭﺍﺮﮑﺗ ﮏﯾ ... ﺮﮕﻠﻤﻋ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺩﻮﺷ ﯽﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ ﻥﺭﺪﻣ ﯼﺎﻫﺮﮔﺭﻭﺮﻣ ﻡﺎﻤﺗ ﺭﺩ :ﺪﯾﻭﺮﺑ ﺎﻣ ﺱﺭﺩﺁ ﻪﺑ ،ﻪﯾﺍﺭﺁ ﻞﻣﺎﮐ ﻊﺟﺮﻣ ﮏﯾ ﯼﺍﺮﺑ .ﻞﻣﺎﮐ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﯾﺍﺭﺁ ﻊﺟﺮﻣ ﺖﺳﺍ ﺎﻫ ﻪﯾﺍﺭﺁ ﻪﻤﻫ ﺯﺍ ﯽﯾﺎﻫ ﻪﻧﻮﻤﻧ ﻭ ﺕﺎﺤﯿﺿﻮﺗ ﯼﻭﺎﺣ ﻊﺟﺮﻣreduceRight() ﻪﺑ ﻦﯿﻨﭽﻤﻫ .ﺪﻨﮐ ﯽﻣ ﺭﺎﮐ ﻪﯾﺍﺭﺁ ﺭﺩ ﺖﺳﺍﺭ ﻪﺑ ﭗﭼ ﺯﺍ ﻝﺎﺜﻣ
const numbers = [45, 4, 9, 16, 25];
let sum = numbers.reduce(myFunction);
function myFunction(total, value, index, array) {
return total + value;
} <!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The reduce() Method</h2>
<p>Find the sum of all numbers in an array:</p>
<p id="demo"></p>
<script>
const numbers = [45, 4, 9, 16, 25];
let sum = numbers.reduce(myFunction);
document.getElementById("demo").innerHTML = "The sum is " + sum;
function myFunction(total, value, index, array) {
return total + value;
}
</script>
</body>
</html>
ﻝﺎﺜﻣ
const numbers = [45, 4, 9, 16, 25];
let sum = numbers.reduce(myFunction);
function myFunction(total, value) {
return total + value;
} <!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The reduce() Method</h2>
<p>Find the sum of all numbers in an array:</p>
<p id="demo"></p>
<script>
const numbers = [45, 4, 9, 16, 25];
let sum = numbers.reduce(myFunction);
document.getElementById("demo").innerHTML = "The sum is " + sum;
function myFunction(total, value) {
return total + value;
}
</script>
</body>
</html>
reduce() ﺵﻭﺭ ﻝﺎﺜﻣ
const numbers = [45, 4, 9, 16, 25];
let sum = numbers.reduce(myFunction,
100);
function myFunction(total, value) {
return total + value;
} <!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The reduce() Method</h2>
<p>Find the sum of all numbers in an array:</p>
<p id="demo"></p>
<script>
const numbers = [45, 4, 9, 16, 25];
let sum = numbers.reduce(myFunction, 100);
document.getElementById("demo").innerHTML = "The sum is " + sum;
function myFunction(total, value) {
return total + value;
}
</script>
</body>
</html>
reduceRight() ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﯾﺍﺭﺁreduceRight() ﻪﺑ ﻦﯿﻨﭽﻤﻫ .ﺪﻨﮐ ﯽﻣ ﺭﺎﮐ ﻪﯾﺍﺭﺁ ﺭﺩ ﭗﭼ ﻪﺑ ﺖﺳﺍﺭ ﺯﺍ ﻝﺎﺜﻣ
const numbers = [45, 4, 9, 16, 25];
let sum = numbers.reduceRight(myFunction);
function myFunction(total, value, index, array) {
return total + value;
} <!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The reduceRight() Method</h2>
<p>Find the sum of all numbers in an array:</p>
<p id="demo"></p>
<script>
const numbers = [45, 4, 9, 16, 25];
let sum = numbers.reduceRight(myFunction);
document.getElementById("demo").innerHTML = "The sum is " + sum;
function myFunction(total, value, index, array) {
return total + value;
}
</script>
</body>
</html>
ﻝﺎﺜﻣ
const numbers = [45, 4, 9, 16, 25];
let sum = numbers.reduceRight(myFunction);
function myFunction(total, value) {
return total + value;
} <!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The reduceRight() Method</h2>
<p>Find the sum of all numbers in an array:</p>
<p id="demo"></p>
<script>
const numbers = [45, 4, 9, 16, 25];
let sum = numbers.reduceRight(myFunction);
document.getElementById("demo").innerHTML = "The sum is " + sum;
function myFunction(total, value) {
return total + value;
}
</script>
</body>
</html>
every() ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﯾﺍﺭﺁevery() ﺵ ﻝﺎﺜﻣ
const numbers = [45, 4, 9, 16, 25];
let allOver18 =
numbers.every(myFunction);
function myFunction(value, index, array) {
return
value > 18;
} <!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The every() Method</h2>
<p>The every() method checks if all array values pass a test.</p>
<p id="demo"></p>
<script>
const numbers = [45, 4, 9, 16, 25];
let allOver18 = numbers.every(myFunction);
document.getElementById("demo").innerHTML = "All over 18 is " + allOver18;
function myFunction(value, index, array) {
return value > 18;
}
</script>
</body>
</html>
ﻝﺎﺜﻣ
const numbers = [45, 4, 9, 16, 25];
let allOver18 =
numbers.every(myFunction);
function myFunction(value) {
return
value > 18;
} <!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The every() Method</h2>
<p>The every() method checks if all array values pass a test.</p>
<p id="demo"></p>
<script>
const numbers = [45, 4, 9, 16, 25];
let allOver18 = numbers.every(myFunction);
document.getElementById("demo").innerHTML = "All over 18 is " + allOver18;
function myFunction(value) {
return value > 18;
}
</script>
</body>
</html>
some() ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﯾﺍﺭﺁ ﻝﺎﺜﻣ
const numbers = [45, 4, 9, 16, 25];
let someOver18 = numbers.some(myFunction);
function myFunction(value, index, array) {
return
value > 18;
} <!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The some() Method</h2>
<p>The some() method checks if some array values pass a test:</p>
<p id="demo"></p>
<script>
const numbers = [45, 4, 9, 16, 25];
let someOver18 = numbers.some(myFunction);
document.getElementById("demo").innerHTML = "Some over 18 is " + someOver18;
function myFunction(value, index, array) {
return value > 18;
}
</script>
</body>
</html>
indexOf() ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﯾﺍﺭﺁindexOf() ﺵﻭ ﻝﺎﺜﻣ
const fruits = ["Apple", "Orange", "Apple", "Mango"];
let position = fruits.indexOf("Apple") + 1;<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The indexOf() Method</h2>
<p id="demo"></p>
<script>
const fruits = ["Apple", "Orange", "Apple", "Mango"];
let position = fruits.indexOf("Apple") + 1;
document.getElementById("demo").innerHTML = "Apple is found in position " + position;
</script>
</body>
</html>
ﻮﺤﻧ
array.indexOf(item, start)Array.indexOf() ﯽﻣﺮﺑ ﺍﺭ 1- ﺪﺸﻧ ﺍﺪﯿﭘ ﺩﺭﻮﻣ ﺮﮔﺍﺪﻧﺍﺩﺮﮔ.
lastIndexOf() ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﯾﺍﺭﺁArray.lastIndexOf() ﻥﺎﻤﻫ Array.indexOf() ﺎﻣﺍ ،ﺖﺳﺍ ﻝﺎﺜﻣ
const fruits = ["Apple", "Orange", "Apple", "Mango"];
let position = fruits.lastIndexOf("Apple") + 1;<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The lastIndexOf() Method</h2>
<p id="demo"></p>
<script>
const fruits = ["Apple", "Orange", "Apple", "Mango"];
let position = fruits.lastIndexOf("Apple") + 1;
document.getElementById("demo").innerHTML = "Apple is found in position " + position;
</script>
</body>
</html>
ﻮﺤﻧ
array.lastIndexOf(item, start)
find() ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﯾﺍﺭﺁfind() ﺪﺘﻣ ﻝﺎﺜﻣ
const numbers = [4, 9, 16, 25, 29];
let first =
numbers.find(myFunction);
function myFunction(value, index, array) {
return
value > 18;
} <!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The find() Method</h2>
<p id="demo"></p>
<script>
const numbers = [4, 9, 16, 25, 29];
let first = numbers.find(myFunction);
document.getElementById("demo").innerHTML = "First number over 18 is " + first;
function myFunction(value, index, array) {
return value > 18;
}
</script>
</body>
</html>
ﺮﮔﺭﻭﺮﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ
find() ﯽﮔﮋﯾﻭ ﮏﯾ ES6 (2015 ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ) ﺖﺳﺍ.
Chrome
Edge
Firefox
Safari
Opera
Yes
Yes
Yes
Yes
Yes
find() ﺩﻮﺷ ﯽﻤﻧ ﯽﻧﺎﺒﯿﺘﺸﭘ ﺭﺭﻮﻠﭙﺴﮐﺍ ﺖﻧﺮﺘﻨﯾﺍ ﺭﺩ.
findIndex() ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﯾﺍﺭﺁfindIndex() ﺵﻭﺭ ﻝﺎﺜﻣ
const numbers = [4, 9, 16, 25, 29];
let first =
numbers.findIndex(myFunction);
function myFunction(value, index, array) {
return
value > 18;
} <!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The findIndex() Method</h2>
<p id="demo"></p>
<script>
const numbers = [4, 9, 16, 25, 29];
document.getElementById("demo").innerHTML = "First number over 18 has index " + numbers.findIndex(myFunction);
function myFunction(value, index, array) {
return value > 18;
}
</script>
</body>
</html>
ﺮﮔﺭﻭﺮﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ
findIndex() ﯽﮔﮋﯾﻭ ﮏﯾ ES6 (2015 ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ) ﺖﺳﺍ.
Chrome
Edge
Firefox
Safari
Opera
Yes
Yes
Yes
Yes
Yes
findIndex() ﯽﻤﻧ ﯽﻧﺎﺒﯿﺘﺸﭘ ﺭﺭﻮﻠﭙﺴﮐﺍ ﺖﻧﺮﺘﻨﯾﺍ ﺭﺩﺩﻮﺷ.
Array.from() ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟArray.from() ﺪﺘﻣ ﻝﺎﺜﻣ
Array.from("ABCDEFG");<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The from() Method</h2>
<p>Return an array object from any object with a length property or any iterable object.</p>
<p id="demo"></p>
<script>
const myArr = Array.from("ABCDEFG");
document.getElementById("demo").innerHTML = myArr;
</script>
<p>The Array.from() method is not supported in Internet Explorer.</p>
</body>
</html>
ﺮﮔﺭﻭﺮﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ
from() ﯽﮔﮋﯾﻭ ﮏﯾ ES6 (2015 ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ) ﺖﺳﺍ.
Chrome
Edge
Firefox
Safari
Opera
Yes
Yes
Yes
Yes
Yes
from() ﺩﻮﺷ ﯽﻤﻧ ﯽﻧﺎﺒﯿﺘﺸﭘ ﺭﺭﻮﻠﭙﺴﮐﺍ ﺖﻧﺮﺘﻨﯾﺍ ﺭﺩ.
Keys() ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﯾﺍﺭﺁArray.keys() ﺵﻭﺭ ﻝﺎﺜﻣ
const fruits = ["Banana", "Orange", "Apple", "Mango"];
const keys = fruits.keys();
for (let x of keys) {
text += x + "<br>";
}<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The keys() Method</h2>
<p>Return an Array Iterator object with the keys of the array:</p>
<p id="demo"></p>
<script>
const fruits = ["Banana", "Orange", "Apple", "Mango"];
const keys = fruits.keys();
let text = "";
for (let x of keys) {
text += x + "<br>";
}
document.getElementById("demo").innerHTML = text;
</script>
<p>Array.keys() is not supported in Internet Explorer.</p>
</body>
</html>
ﺮﮔﺭﻭﺮﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ
keys() ﯽﮔﮋﯾﻭ ﮏﯾ ES6 (2015 ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ) ﺖﺳﺍ.
Chrome
Edge
Firefox
Safari
Opera
Yes
Yes
Yes
Yes
Yes
keys() ﯽﻤﻧ ﯽﻧﺎﺒﯿﺘﺸﭘ ﺭﺭﻮﻠﭙﺴﮐﺍ ﺖﻧﺮﺘﻨﯾﺍ ﺭﺩﺩﻮﺷ.
entries() ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﯾﺍﺭﺁ ﻝﺎﺜﻣ
const fruits = ["Banana", "Orange", "Apple", "Mango"];
const f = fruits.entries();
for (let x of f) {
document.getElementById("demo").innerHTML += x;
}<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The entries() method</h2>
<p>entries() returns an Array Iterator object with key/value pairs:</p>
<p id="demo"></p>
<script>
const fruits = ["Banana", "Orange", "Apple", "Mango"];
const f = fruits.entries();
for (let x of f) {
document.getElementById("demo").innerHTML += x + "<br>";
}
</script>
<p>The entries() method is not supported in Internet Explorer 11 (or earlier).</p>
</body>
</html>
entries() ﺪﺘﻣ
["ﺐﯿﺳ" ،2]
["ﯽﺠﻧﺭﺎﻧ" ،1]
["ﺯﻮﻣ" ،0]entries() ﺵﻭﺭ ﺮﮔﺭﻭﺮﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ
entries() ﯽﮔﮋﯾﻭ ﮏﯾ ES6 (2015 ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ) ﺖﺳﺍ.
Chrome
Edge
Firefox
Safari
Opera
Yes
Yes
Yes
Yes
Yes
entries() ﺩﻮﺷ ﯽﻤﻧ ﯽﻧﺎﺒﯿﺘﺸﭘ ﺭﺭﻮﻠﭙﺴﮐﺍ ﺖﻧﺮﺘﻨﯾﺍ ﺭﺩ. ﺖﺳﺍ
()ﻞﻣﺎﺷ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﯾﺍﺭﺁArray.includes() ﺩﺮﮐ ﯽﻓﺮﻌﻣ ﺎﻫ ﻪﯾﺍﺭﺁ ﻪﺑ ﺍﺭ. ﻝﺎﺜﻣ
const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.includes("Mango"); // is true<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The includes() Method</h2>
<p>Check if the fruit array contains "Mango":</p>
<p id="demo"></p>
<p><strong>Note:</strong> The includes method is not supported in Edge 13 (and earlier versions).</p>
<script>
const fruits = ["Banana", "Orange", "Apple", "Mango"];
document.getElementById("demo").innerHTML = fruits.includes("Mango");
</script>
</body>
</html>
ﻮﺤﻧ
array.includes(search-item) ﺮﮔﺭﻭﺮﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ
includes() ﯽﮔﮋﯾﻭ ﮏﯾ ECMAScript 2016 ﺖﺳﺍ.
Chrome
Edge
Firefox
Safari
Opera
Yes
Yes
Yes
Yes
Yes
includes() ﯽﻤﻧ ﯽﻧﺎﺒﯿﺘﺸﭘ ﺭﺭﻮﻠﭙﺴﮐﺍ ﺖﻧﺮﺘﻨﯾﺍ ﺭﺩﺩﻮﺷ. (...) ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﯾﺍﺭﺁ ﺵﺮﺘﺴﮔ
ﻝﺎﺜﻣ
const q1 = ["Jan", "Feb", "Mar"];
const q2 = ["Apr", "May", "Jun"];
const q3 = ["Jul", "Aug", "Sep"];
const q4 = ["Oct", "Nov", "May"];
const year = [...q1, ...q2, ...q3, ...q4];<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Operators</h1>
<h2>The ... Operator</h2>
<p>The "spread" operator spreads elements of iterable objects:</p>
<p id="demo"></p>
<script>
const q1 = ["Jan", "Feb", "Mar"];
const q2 = ["Apr", "May", "Jun"];
const q3 = ["Jul", "Aug", "Sep"];
const q4 = ["Oct", "Nov", "May"];
const year = [...q1, ...q2, ...q3, ...q4];
document.getElementById("demo").innerHTML = year;
</script>
</body>
</html>
ﺮﮔﺭﻭﺮﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ
... ﯽﮔﮋﯾﻭ ﮏﯾ ES6 (2015 ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ) ﺖﺳﺍ.
Chrome
Edge
Firefox
Safari
Opera
Yes
Yes
Yes
Yes
Yes
... ﺩﻮﺷ ﯽﻤﻧ ﯽﻧﺎﺒﯿﺘﺸﭘ ﺭﺭﻮﻠﭙﺴﮐﺍ ﺖﻧﺮﺘﻨﯾﺍ ﺭﺩ. ﻪﯾﺍﺭﺁ ﻞﻣﺎﮐ ﻊﺟﺮﻣ