.ﺖﺳﺍ ﺩﺮﻓ ﻪﺑ ﺮﺼﺤﻨﻣ ﺮﯾﺩﺎﻘﻣ ﺯﺍ ﯼﺍ ﻪﻋﻮﻤﺠﻣ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﻋﻮﻤﺠﻣ
.ﺪﻫﺩ ﺥﺭ ﻪﻋﻮﻤﺠﻣ ﮏﯾ ﺭﺩ ﺭﺎﺑ ﮏﯾ ﺪﻧﺍﻮﺗ ﯽﻣ ﻂﻘﻓ ﺭﺍﺪﻘﻣ ﺮﻫ
ﺪﻨﮐ ﯽﻣ ﺩﺎﺠﯾﺍ ﺪﯾﺪﺟ ﻪﻋﻮﻤﺠﻣ ﮏﯾ
ﺪﻨﮐ ﯽﻣ ﻪﻓﺎﺿﺍ ﻪﻋﻮﻤﺠﻣ ﻪﺑ ﺪﯾﺪﺟ ﺮﺼﻨﻋ ﮏﯾ
ﺪﻨﮐ ﯽﻣ ﻑﺬﺣ ﻪﻋﻮﻤﺠﻣ ﮏﯾ ﺯﺍ ﺍﺭ ﺮﺼﻨﻋ ﮏﯾ
ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ true ﺭﺍﺪﻘﻣ ،ﺪﺷﺎﺑ ﻪﺘﺷﺍﺩ ﺩﻮﺟﻭ ﻪﻋﻮﻤﺠﻣ ﺭﺩ ﯼﺭﺍﺪﻘﻣ ﺮﮔﺍ
ﺪﻨﮐ ﯽﻣ ﯽﻧﺍﻮﺧﺍﺮﻓ ﯽﺘﺸﮔﺮﺑ ﺱﺎﻤﺗ ﮏﯾ ،ﻪﻋﻮﻤﺠﻣ ﺭﺩ ﺮﺼﻨﻋ ﺮﻫ ﯼﺍﺮﺑ
ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﻪﻋﻮﻤﺠﻣ ﮏﯾ ﺭﺩ ﺩﻮﺟﻮﻣ ﺮﯾﺩﺎﻘﻣ ﻡﺎﻤﺗ ﺎﺑ ﺍﺭ ﻩﺪﻨﻨﮐ ﺭﺍﺮﮑﺗ ﮏﯾ
ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ ﻪﻋﻮﻤﺠﻣ ﮏﯾ ﺮﺻﺎﻨﻋ ﺩﺍﺪﻌﺗ
:ﺪﯿﻨﮐ ﺩﺎﺠﯾﺍ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﻋﻮﻤﺠﻣ ﮏﯾ ﺪﯿﻧﺍﻮﺗ ﯽﻣ ﺎﻤﺷ
New Set()
ﻪﺑ ﻪﯾﺍﺭﺁ ﮏﯾ ﻝﺎﺳﺭﺍ
.ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﺮﯾﺩﺎﻘﻣ ﻥﺩﺮﮐ ﻪﻓﺎﺿﺍ ﯼﺍﺮﺑ add()
ﺯﺍ ﻭ ﺪﯿﻨﮐ
.ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﺎﻫﺮﯿﻐﺘﻣ ﻥﺩﻭﺰﻓﺍ ﯼﺍﺮﺑ add()
ﺯﺍ ﻭ ﺪﯿﻨﮐ ﺩﺎ
new Set()
ﺵﻭﺭ :new Set()
ﻩﺪﻧﺯﺎﺳ ﻪﺑ ﻪﯾﺍﺭﺁ ﮏﯾ ﻝﺎﺳﺭﺍ
// Create a Set
const letters = new Set(["a","b","c"]);
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Sets</h2>
<p>Create a Set from an Array:</p>
<p id="demo"></p>
<script>
// Create a Set
const letters = new Set(["a","b","c"]);
// Display set.size
document.getElementById("demo").innerHTML = letters.size;
</script>
</body>
</html>
:ﺪﯿﻨﮐ ﻪﻓﺎﺿﺍ ﺍﺭ ﺮﯾﺩﺎﻘﻣ ﻭ ﺪﯿﻨﮐ ﺩﺎﺠﯾﺍ ﻪﻋﻮﻤﺠﻣ ﮏﯾ
// Create a Set
const letters = new Set();
// Add Values to the Set
letters.add("a");
letters.add("b");
letters.add("c");
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Sets</h2>
<p>Add values to a Set:</p>
<p id="demo"></p>
<script>
// Create a Set
const letters = new Set();
// Add Values to the Set
letters.add("a");
letters.add("b");
letters.add("c");
// Display set.size
document.getElementById("demo").innerHTML = letters.size;
</script>
</body>
</html>
:ﺪﯿﻨﮐ ﻪﻓﺎﺿﺍ ﺍﺭ ﺎﻫﺮﯿﻐﺘﻣ ﻭ ﺪﯿﻨﮐ ﺩﺎﺠﯾﺍ ﻪﻋﻮﻤﺠﻣ ﮏﯾ
// Create a Set
const letters = new Set();
// Create Variables
const a = "a";
const b = "b";
const c = "c";
// Add Variables to the Set
letters.add(a);
letters.add(b);
letters.add(c);
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Sets</h2>
<p>Add variables to a Set:</p>
<p id="demo"></p>
<script>
// Create a Set
const letters = new Set();
// Create Variables
const a = "a";
const b = "b";
const c = "c";
// Add the Variables to the Set
letters.add(a);
letters.add(b);
letters.add(c);
// Display set.size
document.getElementById("demo").innerHTML = letters.size;
</script>
</body>
</html>
add()
ﺵﻭﺭletters.add("d");
letters.add("e");
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Sets</h2>
<p>Adding new elements to a Set:</p>
<p id="demo"></p>
<script>
// Create a new Set
const letters = new Set(["a","b","c"]);
// Add a new Element
letters.add("d");
letters.add("e");
// Display set.size
document.getElementById("demo").innerHTML = letters.size;
</script>
</body>
</html>
:ﺩﻮﺷ ﯽﻣ ﻩﺮﯿﺧﺫ ﯽﻟﻭﺍ ﻂﻘﻓ ،ﺪﯿﻨﮐ ﻪﻓﺎﺿﺍ ﯼﻭﺎﺴﻣ ﺮﺻﺎﻨﻋ ﺮﮔﺍ
letters.add("a");
letters.add("b");
letters.add("c");
letters.add("c");
letters.add("c");
letters.add("c");
letters.add("c");
letters.add("c");
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Sets</h2>
<p>Adding equal elements to a Set:</p>
<p id="demo"></p>
<script>
// Create a Set
const letters = new Set();
// Add values to the Set
letters.add("a");
letters.add("b");
letters.add("c");
letters.add("c");
letters.add("c");
letters.add("c");
letters.add("c");
letters.add("c");
// Display set.size
document.getElementById("demo").innerHTML = letters.size;
</script>
</body>
</html>
forEach()
ﺵﻭﺭ:ﺪﻨﮐ ﯽﻣ ﯽﻧﺍﻮﺧﺍﺮﻓ ﻪﻋﻮﻤﺠﻣ ﺮﺼﻨﻋ ﺮﻫ ﯼﺍﺮﺑ ﺍﺭ ﻊﺑﺎﺗ ﮏﯾ forEach()
// Create a Set
const letters = new Set(["a","b","c"]);
// List all Elements
let text = "";
letters.forEach (function(value) {
text += value;
})
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Sets</h2>
<p>forEach() calls a function for each element:</p>
<p id="demo"></p>
<script>
// Create a Set
const letters = new Set(["a","b","c"]);
// List all Elements
let text = "";
letters.forEach (function(value) {
text += value + "<br>";
})
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>
values()
ﺵﻭﺭ:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ ﻪﻋﻮﻤﺠﻣ ﮏﯾ ﺮﯾﺩﺎﻘﻣ ﻡﺎﻤﺗ ﯼﻭﺎﺣ ﺪﯾﺪﺟ ﻩﺪﻨﻨﮐ ﺭﺍﺮﮑﺗ ﯽﺷ ﮏﯾ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ ﻝﺎﺜﻣ
letters.values() // Returns [object Set Iterator]
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Sets</h2>
<p>Set.values() returns a Set Iterator:</p>
<p id="demo"></p>
<script>
// Create a Set
const letters = new Set(["a","b","c"]);
// Display set.size
document.getElementById("demo").innerHTML = letters.values();
</script>
</body>
</html>
:ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﺮﺻﺎﻨﻋ ﻪﺑ ﯽﺳﺮﺘﺳﺩ ﯼﺍﺮﺑ Iterator ﯽﺷ ﺯﺍ ﺪﯿﻧﺍﻮﺗ ﯽﻣ ﻥﻮﻨﮐﺍ
// List all Elements
let text = "";
for (const x of letters.values()) {
text += x;
}
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Sets</h2>
<p>Iterating Set values:</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.values()) {
text += x + "<br>";
}
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>