.ﺪﻨﺷﺎﺑ ﯼﺍ ﻩﺩﺍﺩ ﻉﻮﻧ ﺮﻫ ﺪﻨﻧﺍﻮﺗ ﯽﻣ ﺎﻫﺪﯿﻠﮐ ﻥﺁ ﺭﺩ ﻪﮐ ﺩﺭﺍﺩ ﯽﻣ ﻪﮕﻧ ﺩﻮﺧ ﺭﺩ ﺍﺭ ﺭﺍﺪﻘﻣ-ﺪﯿﻠﮐ ﯼﺎﻫ
.ﺩﺭﻭﺁ ﯽﻣ ﺮﻃﺎﺧ ﻪﺑ ﺍﺭ ﺎﻫﺪﯿﻠﮐ ﯽﻠﺻﺍ ﺝﺭﺩ ﺐﯿﺗﺮﺗ ﻪﺸﻘﻧ
ﺪﻨﮐ ﯽﻣ ﺩﺎﺠﯾﺍ ﺪﯾﺪﺟ ﻪﺸﻘﻧ ﮏﯾ
ﺪﻨﮐ ﯽﻣ ﻦﯿﯿﻌﺗ ﻪﺸﻘﻧ ﺭﺩ ﺍﺭ ﺪﯿﻠﮐ ﮏﯾ ﺭﺍﺪﻘﻣ
ﺪﻨﮐ ﯽﻣ ﺖﻓﺎﯾﺭﺩ ﻪﺸﻘﻧ ﺭﺩ ﺍﺭ ﺪﯿﻠﮐ ﮏﯾ ﺭﺍﺪﻘﻣ
ﺪﻨﮐ ﯽﻣ ﻑﺬﺣ ﺍﺭ ﺪﯿﻠﮐ ﻂﺳﻮﺗ ﻩﺪﺷ ﺺﺨﺸﻣ ﻪﺸﻘﻧ ﺮﺼﻨﻋ ﮏﯾ
ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ true ﺭﺍﺪﻘﻣ ،ﺪﺷﺎﺑ ﻪﺘﺷﺍﺩ ﺩﻮﺟﻭ ﻪﺸﻘﻧ ﺭﺩ ﯼﺪﯿﻠﮐ ﺮﮔﺍ
ﺪﻨﮐ ﯽﻣ ﯽﻧﺍﻮﺧﺍﺮﻓ ﻪﺸﻘﻧ ﺭﺩ ﺭﺍﺪﻘﻣ/ﺪﯿﻠﮐ ﺖﻔﺟ ﺮﻫ ﯼﺍﺮﺑ ﺍﺭ ﻊﺑﺎﺗ ﮏﯾ
ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﻪﺸﻘﻧ ﺭﺩ [key, value] ﯼﺎﻫ ﺖﻔﺟ ﺎﺑ ﺍﺭ ﻩﺪﻨﻨﮐ ﺭﺍﺮﮑﺗ ﮏﯾ
ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ ﻪﺸﻘﻧ ﺭﺩ ﺩﻮﺟﻮﻣ ﺮﺻﺎﻨﻋ ﺩﺍﺪﻌﺗ
:ﻂﺳﻮﺗ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﺸﻘﻧ ﮏﯾ ﺪﯿﻧﺍﻮﺗ ﯽﻣ ﺎﻤﺷ
new Map()
ﻪﺑ ﻪﯾﺍﺭﺁ ﮏﯾ ﻝﺎﺳﺭﺍ
ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ Map.set()
ﺯﺍ ﻭ ﺪﯿﻨﮐ ﺩﺎﺠﯾﺍ ﻪﺸﻘﻧ ﮏﯾ
new Map()
ﺵﻭﺭ:ﺪﯿﻨﮐ ﺩﺎﺠﯾﺍ ﻪﺸﻘﻧ ﮏﯾ new Map()
ﻩﺪﻧﺯﺎﺳ ﻪﺑ ﻪﯾﺍﺭﺁ ﮏﯾ ﻝﺎﺳ
// Create a Map
const fruits = new Map([
["apples", 500],
["bananas", 300],
["oranges", 200]
]);
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Map Objects</h2>
<p>Creating a Map from an Array:</p>
<p id="demo"></p>
<script>
// Create a Map
const fruits = new Map([
["apples", 500],
["bananas", 300],
["oranges", 200]
]);
document.getElementById("demo").innerHTML = fruits.get("apples");
</script>
</body>
</html>
set()
ﺵﻭﺭ :ﺪﯿﻨﮐ ﻪﻓﺎﺿﺍ ﻪﺸﻘﻧ ﻪﺑ ﺍﺭ ﺮﺻﺎﻨﻋ set()
ﺵﻭﺭ ﺎﺑ ﺪﯿﻧﺍﻮﺗ ﯽﻣ
// Create a Map
const fruits = new Map();
// Set Map Values
fruits.set("apples", 500);
fruits.set("bananas", 300);
fruits.set("oranges", 200);
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Map Objects</h2>
<p>Using Map.set():</p>
<p id="demo"></p>
<script>
// Create a Map
const fruits = new Map();
// Set Map Values
fruits.set("apples", 500);
fruits.set("bananas", 300);
fruits.set("oranges", 200);
document.getElementById("demo").innerHTML = fruits.get("apples");
</script>
</body>
</html>
:ﺩﻮﺷ ﻩﺩﺎﻔﺘﺳﺍ Map ﺩﻮﺟﻮﻣ ﺮﯾﺩﺎﻘﻣ ﺮﯿﯿﻐﺗ ﯼﺍﺮﺑ ﺪﻧﺍﻮﺗ ﯽﻣ ﻦﯿﻨﭽﻤﻫ se
fruits.set("apples", 200);
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Map Objects</h2>
<p>Using Map.set():</p>
<p id="demo"></p>
<script>
// Create a Map
const fruits = new Map([
["apples", 500],
["bananas", 300],
["oranges", 200]
]);
fruits.set("apples", 200);
document.getElementById("demo").innerHTML = fruits.get("apples");
</script>
</body>
</html>
get()
ﺵﻭﺭ :ﺪﻨﮐ ﯽﻣ ﺖﻓﺎﯾﺭﺩ ﻪﺸﻘﻧ ﺭﺩ ﺍﺭ ﺪﯿﻠﮐ ﮏﯾ ﺭﺍﺪﻘﻣ get()
ﺪﺘﻣ
fruits.get("apples"); // Returns 500
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Map Objects</h2>
<p>Using Map.get():</p>
<p id="demo"></p>
<script>
// Create a Map
const fruits = new Map([
["apples", 500],
["bananas", 300],
["oranges", 200]
]);
document.getElementById("demo").innerHTML = fruits.get("apples");
</script>
</body>
</html>
size
ﯽﮔﮋﯾﻭ:ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ ﻪﺸﻘﻧ ﺭﺩ ﺩﻮﺟﻮﻣ ﺮﺻﺎﻨﻋ ﺩﺍﺪﻌﺗ size
ﯽ
fruits.size;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Maps</h2>
<p>Using Map.size:</p>
<p id="demo"></p>
<script>
// Create a Map
const fruits = new Map([
["apples", 500],
["bananas", 300],
["oranges", 200]
]);
document.getElementById("demo").innerHTML = fruits.size;
</script>
</body>
</html>
delete()
ﺵﻭﺭ :ﺪﻨﮐ ﯽﻣ ﻑﺬﺣ ﺍﺭ Map ﺮﺼﻨﻋ ﮏﯾ delete()
ﺵﻭﺭ
fruits.delete("apples");
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Maps</h2>
<p>Deleting Map elements:</p>
<p id="demo"></p>
<script>
// Create a Map
const fruits = new Map([
["apples", 500],
["bananas", 300],
["oranges", 200]
]);
// Delete an Element
fruits.delete("apples");
document.getElementById("demo").innerHTML = fruits.size;
</script>
</body>
</html>
has()
ﺵﻭﺭ:ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ code class="w3-codespan">has() true> ﺵﻭﺭ ،ﺪﺷﺎﺑ ﻪﺘﺷﺍﺩ ﺩﻮﺟﻭ
fruits.has("apples");
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Maps</h2>
<p>Using Map.has():</p>
<p id="demo"></p>
<script>
// Create a Map
const fruits = new Map([
["apples", 500],
["bananas", 300],
["oranges", 200]
]);
document.getElementById("demo").innerHTML = fruits.has("apples");
</script>
</body>
</html>
fruits.delete("apples");
fruits.has("apples");
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Maps</h2>
<p>Using Map.has():</p>
<p id="demo"></p>
<script>
// Create a Map
const fruits = new Map([
["apples", 500],
["bananas", 300],
["oranges", 200]
]);
// Delete an Element
fruits.delete("apples");
document.getElementById("demo").innerHTML = fruits.has("apples");
</script>
</body>
</html>
ﺮﯾﺬﭘﺭﺍﺮﮑﺗ: ﺖﺴﯿﻧ ﺭﺍﺮﮑﺗ ﻞﺑﺎﻗ ﺎًﻤﯿﻘﺘﺴﻣ
Size: ﺪﯾﺭﺍﺪﻧ ﻩﺯﺍﺪﻧﺍ ﯽﮔﮋﯾﻭ
ﺪﯿﻠﮐ ﻉﺍﻮﻧﺍ: ﺪﻨﺷﺎﺑ (ﺩﺎﻤﻧ ﺎﯾ) ﻪﺘﺷﺭ ﺪﯾﺎﺑ ﺎﻫﺪﯿﻠﮐ
ﺪﯿﻠﮐ ﺐﯿﺗﺮﺗ: ﺪﻧﺍ ﻩﺪﺸﻧ ﺐﺗﺮﻣ ﯽﺑﻮﺧ ﻪﺑ ﺎﻫﺪﯿﻠﮐ
ﺶﯿﭘﺽﺮﻓﺎﻫ: ﺶﯿﭘ ﯼﺎﻫﺪﯿﻠﮐﺪﯿﺷﺎﺑ ﻪﺘﺷﺍﺩ ﺽﺮﻓ
ﺮﯾﺬﭘﺭﺍﺮﮑﺗ: ﺭﺍﺮﮑﺗ ﻞﺑﺎﻗ ﻢﯿﻘﺘﺴﻣ
ﻩﺯﺍﺪﻧﺍ: ﺪﯿﺷﺎﺑ ﻪﺘﺷﺍﺩ ﻩﺯﺍﺪﻧﺍ ﯽﮔﮋﯾﻭ ﮏﯾ
ﺪﯿﻠﮐ ﻉﺍﻮﻧﺍ: ﺪﻨﺷﺎﺑ ﯼﺍ ﻩﺩﺍﺩ ﻉﻮﻧ ﺮﻫ ﺪﻨﻧﺍﻮﺗ ﯽﻣ ﺎﻫﺪﯿﻠﮐ
ﺪﯿﻠﮐ ﺐﯿﺗﺮﺗ: ﯽﻣ ﺐﺗﺮﻣ ﺝﺭﺩ ﺎﺑ ﺎﻫﺪﯿﻠﮐﺪﻧﻮﺷ
ﺶﯿﭘﺽﺮﻓﺎﻫ: ﺶﯿﭘ ﯼﺎﻫﺪﯿﻠﮐﺪﻧﺭﺍﺪﻧ ﺽﺮﻓ
forEach()
ﺵﻭﺭ:ﺪﻨﮐ ﯽﻣ ﯽﻧﺍﻮﺧﺍﺮﻓ ﻪﺸﻘﻧ ﺭﺩ ﺭﺍﺪﻘﻣ/ﺪﯿﻠﮐ ﺖﻔﺟ ﺮﻫ ﯼﺍﺮﺑ ﺍﺭ ﻊﺑﺎﺗ ﮏﯾ
// List all entries
let text = "";
fruits.forEach (function(value, key) {
text += key + ' = ' + value;
})
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Map Objects</h2>
<p>Using Map.forEach():</p>
<p id="demo"></p>
<script>
// Create a Map
const fruits = new Map([
["apples", 500],
["bananas", 300],
["oranges", 200]
]);
let text = "";
fruits.forEach (function(value, key) {
text += key + ' = ' + value + "<br>"
})
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>
entries()
ﺵﻭﺭ:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﻪﺸﻘﻧ ﺭﺩ [key, values] ﺎﺑ ﺍﺭ ﻩﺪﻨﻨﮐ ﺭﺍﺮﮑﺗ ﯽﺷ ﮏﯾ
// List all entries
let text = "";
for (const x of fruits.entries()) {
text += x;
}
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Map Objects</h2>
<p>Using Map.entries():</p>
<p id="demo"></p>
<script>
// Create a Map
const fruits = new Map([
["apples", 500],
["bananas", 300],
["oranges", 200]
]);
let text = "";
for (const x of fruits.entries()) {
text += x + "<br>";
}
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>
:ﺩﻮﺷ ﯽﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ ﺭﺭﻮﻠﭙﺴﮐﺍ ﺖﻧﺮﺘﻨﯾﺍ ﺰﺟ ﻪﺑ ﺎﻫﺮﮔﺭﻭﺮﻣ ﻪﻤﻫ ﺭﺩ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫ ﻪﺸﻘﻧ
Chrome | Edge | Firefox | Safari | Opera |