ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫ ﻪﺸﻘﻧ


فهرست مطالب

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

.ﺪﻨﺷﺎﺑ ﯼﺍ ﻩﺩﺍﺩ ﻉﻮﻧ ﺮﻫ ﺪﻨﻧﺍﻮﺗ ﯽﻣ ﺎﻫﺪﯿﻠﮐ ﻥﺁ ﺭﺩ ﻪﮐ ﺩﺭﺍﺩ ﯽﻣ ﻪﮕﻧ ﺩﻮﺧ ﺭﺩ ﺍﺭ ﺭﺍﺪﻘﻣ-ﺪﯿﻠﮐ ﯼﺎﻫ

.ﺩﺭﻭﺁ ﯽﻣ ﺮﻃﺎﺧ ﻪﺑ ﺍﺭ ﺎﻫﺪﯿﻠﮐ ﯽﻠﺻﺍ ﺝﺭﺩ ﺐﯿﺗﺮﺗ ﻪﺸﻘﻧ

ﻪﺸﻘﻧ ﯼﺭﻭﺮﺿ ﯼﺎﻫ ﺵﻭﺭ

new Map()

ﺪﻨﮐ ﯽﻣ ﺩﺎﺠﯾﺍ ﺪﯾﺪﺟ ﻪﺸﻘﻧ ﮏﯾ

set()

ﺪﻨﮐ ﯽﻣ ﻦﯿﯿﻌﺗ ﻪﺸﻘﻧ ﺭﺩ ﺍﺭ ﺪﯿﻠﮐ ﮏﯾ ﺭﺍﺪﻘﻣ

get()

ﺪﻨﮐ ﯽﻣ ﺖﻓﺎﯾﺭﺩ ﻪﺸﻘﻧ ﺭﺩ ﺍﺭ ﺪﯿﻠﮐ ﮏﯾ ﺭﺍﺪﻘﻣ

delete()

ﺪﻨﮐ ﯽﻣ ﻑﺬﺣ ﺍﺭ ﺪﯿﻠﮐ ﻂﺳﻮﺗ ﻩﺪﺷ ﺺﺨﺸﻣ ﻪﺸﻘﻧ ﺮﺼﻨﻋ ﮏﯾ

has()

ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ true ﺭﺍﺪﻘﻣ ،ﺪﺷﺎﺑ ﻪﺘﺷﺍﺩ ﺩﻮﺟﻭ ﻪﺸﻘﻧ ﺭﺩ ﯼﺪﯿﻠﮐ ﺮﮔﺍ

forEach()

ﺪﻨﮐ ﯽﻣ ﯽﻧﺍﻮﺧﺍﺮﻓ ﻪﺸﻘﻧ ﺭﺩ ﺭﺍﺪﻘﻣ/ﺪﯿﻠﮐ ﺖﻔﺟ ﺮﻫ ﯼﺍﺮﺑ ﺍﺭ ﻊﺑﺎﺗ ﮏﯾ

entries()

ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﻪﺸﻘﻧ ﺭﺩ [key, value] ﯼﺎﻫ ﺖﻔﺟ ﺎﺑ ﺍﺭ ﻩﺪﻨﻨﮐ ﺭﺍﺮﮑﺗ ﮏﯾ

size

ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ ﻪﺸﻘﻧ ﺭﺩ ﺩﻮﺟﻮﻣ ﺮﺻﺎﻨﻋ ﺩﺍﺪﻌﺗ


ﻪﺸﻘﻧ ﺩﺎﺠﯾﺍ ﻩﻮﺤﻧ

:ﻂﺳﻮﺗ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﺸﻘﻧ ﮏﯾ ﺪﯿﻧﺍﻮﺗ ﯽﻣ ﺎﻤﺷ

  • 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

تمامی حقوق محفوظ است. © BasicIT.org • 2023-2024