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


فهرست مطالب

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

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

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

.ﺪﻫﺩ ﯽﻣ ﻥﺎﺸﻧ ﺍﺭ ﻪﺸﻘﻧ ﻩﺯﺍﺪﻧﺍ ﻪﮐ ﺖﺳﺍ ﯽﮔﮋﯾﻭ ﯼﺍﺭﺍﺩ ﻪﺸﻘﻧ

ﯼﺭﺍﺩﺮﺑ ﻪﺸﻘﻧ ﯼﺎﻫ ﺵﻭﺭ

new Map()

ﺪﻨﮐ ﯽﻣ ﺩﺎﺠﯾﺍ ﺪﯾﺪﺟ Map ﯽﺷ ﮏﯾ

set()

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

get()

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

clear()

ﺪﻨﮐ ﯽﻣ ﻑﺬﺣ ﻪﺸﻘﻧ ﺯﺍ ﺍﺭ ﺮﺻﺎﻨﻋ ﻡﺎﻤﺗ

delete()

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

has()

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

forEach()

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

entries()

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

keys()

ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﻪﺸﻘﻧ ﺭﺩ ﺩﻮﺟﻮﻣ ﯼﺎﻫﺪﯿﻠﮐ ﺎﺑ ﺍﺭ ﻩﺪﻨﻨﮐ ﺭﺍﺮﮑﺗ ﯽﺷ ﮏﯾ

values()

ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ ﻪﺸﻘﻧ ﺭﺩ ﺩﻮﺟﻮﻣ ﺮﯾﺩﺎﻘﻣ ﻩﺪﻨﻨﮐ ﺭﺍﺮﮑﺗ ﯽﺷ ﮏﯾ

size

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


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

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

  • new Map() ﻪﺑ ﻪﯾﺍﺭﺁ ﮏﯾ ﻝﺎﺳﺭﺍ

  • ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ Map.set() ﺯﺍ ﻭ ﺪﯿﻨﮐ ﺩﺎﺠﯾﺍ ﻪﺸﻘﻧ ﮏﯾ


ﻪﺸﻘﻧ()

:ﺪﯿﻨﮐ ﺩﺎﺠﯾﺍ ﻪﺸﻘﻧ ﮏﯾ 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>


Map.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", 500);

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!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>


Map.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>



Map.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>


Map.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>


Map.clear()

:ﺪﻨﮐ ﯽﻣ ﻑﺬﺣ ﻪﺸﻘﻧ ﺯﺍ ﺍﺭ ﺮﺻﺎﻨﻋ ﻪﻤﻫ clear() ﺵﻭﺭ

ﻝﺎﺜﻣ

fruits.clear();

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Maps</h2>
<p>Clearing a Map:</p>

<p id="demo"></p>

<script>
// Create a Map
const fruits = new Map([
  ["apples", 500],
  ["bananas", 300],
  ["oranges", 200]
]);

// Clear the Map
fruits.clear();

document.getElementById("demo").innerHTML = fruits.size;
</script>

</body>
</html>


Map.has()

:ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ true ﺭﺍﺪﻘﻣ has() ﺵﻭﺭ ،ﺪﺷﺎﺑ ﻪﺘﺷﺍﺩ

ﻝﺎﺜﻣ

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>


ﺪﻨﺘﺴﻫ ﺎﯿﺷﺍ ﺎﻫ ﻪﺸﻘﻧ

ﻉﻮﻧ ﯽﻣﺮﺑ ﺍﺭ ﯽﺷﺪﻧﺍﺩﺮﮔ:

ﻝﺎﺜﻣ

// Returns object:
typeof fruits;

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Map Objects</h2>
<p>Map typeof:</p>

<p id="demo"></p>

<script>
// Create a Map
const fruits = new Map([
  ["apples", 500],
  ["bananas", 300],
  ["oranges", 200]
]);

document.getElementById("demo").innerHTML = typeof fruits;
</script>

</body>
</html>

ﻪﻧﻮﻤﻧ Map true ﯽﻣﺮﺑ ﺍﺭﺪﻧﺍﺩﺮﮔ:

ﻝﺎﺜﻣ

// Returns true:
fruits instanceof Map;

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Map Objects</h2>
<p>Map instanceof:</p>

<p id="demo"></p>

<script>
// Create a Map
const fruits = new Map([
  ["apples", 500],
  ["bananas", 300],
  ["oranges", 200]
]);

document.getElementById("demo").innerHTML = fruits instanceof Map;
</script>

</body>
</html>

ﺎﻫ ﻪﺸﻘﻧ ﻞﺑﺎﻘﻣ ﺭﺩ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ءﺎﯿﺷﺍ

:ﺎﻫ ﻪﺸﻘﻧ ﻭ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫ ﺖﮑﺠﺑﺁ ﻦﯿﺑ ﺕﻭﺎﻔﺗ

Not directly iterable

ﺭﺍﺮﮑﺗ ﻞﺑﺎﻗ ﺎﻤﯿﻘﺘﺴﻣ

Do not have a size property

ﺪﺷﺎﺑ ﻩﺯﺍﺪﻧﺍ ﺖﯿﺻﺎﺧ ﯼﺍﺭﺍﺩ

Keys must be Strings (or Symbols)

ﺪﻨﺷﺎﺑ ﯼﺍ ﻩﺩﺍﺩ ﻉﻮﻧ ﺮﻫ ﺪﻨﻧﺍﻮﺗ ﯽﻣ ﺎﻫﺪﯿﻠﮐ

Keys are not well ordered

ﺪﻧﻮﺷ ﯽﻣ ﺐﺗﺮﻣ ﺝﺭﺩ ﺎﺑ ﺎﻫﺪﯿﻠﮐ

Have default keys

ﺪﯾﺭﺍﺪﻧ ﺽﺮﻓ ﺶﯿﭘ ﯼﺎﻫﺪﯿﻠﮐ


Map.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>

Map.entries()

:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﻪﺸﻘﻧ ﺭﺩ ﺍﺭ [key,values] ﺎﺑ ﻩﺪﻨﻨﮐ ﺭﺍﺮﮑﺗ ﯽﺷ ﮏﯾ e

ﻝﺎﺜﻣ

// 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>

Map.keys()

:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﻪﺸﻘﻧ ﺭﺩ ﺩﻮﺟﻮﻣ ﯼﺎﻫﺪﯿﻠﮐ ﺎﺑ ﺍﺭ ﻩﺪﻨﻨﮐ ﺭﺍﺮﮑﺗ ﯽﺷ ﮏﯾ

ﻝﺎﺜﻣ

// List all keys
let text = "";
for (const x of fruits.keys()) {
  text += x;
}

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Map Objects</h2>
<p>Using Map.keys():</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.keys()) {
  text += x + "<br>";
}

document.getElementById("demo").innerHTML = text;
</script>

</body>
</html>

Map.values()

:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﻪﺸﻘﻧ ﺭﺩ ﺩﻮﺟﻮﻣ ﺮﯾﺩﺎﻘﻣ ﺎﺑ ﺍﺭ ﻩﺪﻨﻨﮐ ﺭﺍﺮﮑﺗ ﯽﺷ ﮏﯾ v

ﻝﺎﺜﻣ

// List all values
let text = "";
for (const x of fruits.values()) {
  text += x;
}

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Map Objects</h2>
<p>Using Map.values():</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.values()) {
  text += x + "<br>";
}

document.getElementById("demo").innerHTML = text;
</script>

</body>
</html>

:ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﻪﺸﻘﻧ ﮏﯾ ﺭﺩ ﺮﯾﺩﺎﻘﻣ ﻥﺩﺮﮐ ﻊﻤﺟ ﯼﺍﺮﺑ values()

ﻝﺎﺜﻣ

// Sum all values
let total = 0;
for (const x of fruits.values()) {
  total += x;
}

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Map Objects</h2>
<p>Using Map.values():</p>

<p id="demo"></p>

<script>
// Create a Map
const fruits = new Map([
  ["apples", 500],
  ["bananas", 300],
  ["oranges", 200]
]);

let total = 0;
for (const x of fruits.values()) {
  total += x;
}

document.getElementById("demo").innerHTML = total;
</script>

</body>
</html>

ﺪﯿﻠﮐ ﻥﺍﻮﻨﻋ ﻪﺑ ءﺎﯿﺷﺍ

.ﺖﺳﺍ ﻪﺸﻘﻧ ﻢﻬﻣ ﯼﺎﻫ ﯽﮔﮋﯾﻭ ﺯﺍ ﯽﮑﯾ ﺪﯿﻠﮐ ﻥﺍﻮﻨﻋ ﻪﺑ ءﺎﯿﺷﺍ ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ ﯽﯾﺎﻧﺍﻮﺗ

ﻝﺎﺜﻣ

// Create Objects
const apples = {name: 'Apples'};
const bananas = {name: 'Bananas'};
const oranges = {name: 'Oranges'};

// Create a Map
const fruits = new Map();

// Add new Elements to the Map
fruits.set(apples, 500);
fruits.set(bananas, 300);
fruits.set(oranges, 200);

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Map Objects</h2>
<p>Being able to use objects as keys is an important Map feature:</p>

<p id="demo"></p>

<script>
// Create Objects
const apples = {name: 'Apples'};
const bananas = {name: 'Bananas'};
const oranges = {name: 'Oranges'};

// Create a Map
const fruits = new Map();

// Add the Objects to the Map
fruits.set(apples, 500);
fruits.set(bananas, 300);
fruits.set(oranges, 200);

document.getElementById("demo").innerHTML = fruits.get(apples);
</script>

</body>
</html>

:("ﺐﯿﺳ") ﻪﺘﺷﺭ ﮏﯾ ﻪﻧ ،ﺖﺳﺍ (ﺐﯿﺳ) ﯽﺷ ﮏﯾ ﺪﯿﻠﮐ :ﺪﯿﺷﺎﺑ ﻪﺘﺷﺍﺩ ﺩﺎﯾ ﻪﺑ

ﻝﺎﺜﻣ

fruits.get("apples");  // Returns undefined

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Map Objects</h2>

<p id="demo"></p>

<script>
// Create Objects
const apples = {name: 'Apples'};
const bananas = {name: 'Bananas'};
const oranges = {name: 'Oranges'};

// Create a Map
const fruits = new Map();

// Add Elements to the Map
fruits.set(apples, 500);
fruits.set(bananas, 300);
fruits.set(oranges, 200);

document.getElementById("demo").innerHTML = fruits.get("apples");
</script>

</body>
</html>


ﺮﮔﺭﻭﺮﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ

:ﺩﻮﺷ ﯽﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ ﺭﺭﻮﻠﭙﺴﮐﺍ ﺖﻧﺮﺘﻨﯾﺍ ﺰﺟ ﻪﺑ ﺎﻫﺮﮔﺭﻭﺮﻣ ﻪﻤﻫ ﺭﺩ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫ ﻪﺸﻘﻧ

Chrome Edge Firefox Safari Opera

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