.ﺪﻨﻫﺩ ﯽﻣ ﺹﺎﺼﺘﺧﺍ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫﺮﯿﻐﺘﻣ ﻪﺑ ﺍﺭ ﯼﺮﯾﺩﺎﻘﻣ ﺏﺎﺴﺘﻧﺍ ﯼﺎﻫﺮﮕﻠﻤﻋ
Operator | Example | Same As |
---|---|---|
= | x = y | x = y |
+= | x += y | x = x + y |
-= | x -= y | x = x - y |
*= | x *= y | x = x * y |
/= | x /= y | x = x / y |
%= | x %= y | x = x % y |
**= | x **= y | x = x ** y |
Operator | Example | Same As |
---|---|---|
<<= | x <<= y | x = x << y |
>>= | x >>= y | x = x >> y |
>>>= | x >>>= y | x = x >>> y |
Operator | Example | Same As |
---|---|---|
&= | x &= y | x = x & y |
^= | x ^= y | x = x ^ y |
|= | x |= y | x = x | y |
Operator | Example | Same As |
---|---|---|
&&= | x &&= y | x = x && (x = y) |
||= | x ||= y | x = x || (x = y) |
??= | x ??= y | x = x ?? (x = y) |
ﺪﻨﺘﺴﻫ ES2020 ﯽﻘﻄﻨﻣ ﺺﯿﺼﺨﺗ ﯼﺎﻫﺮﮕﻠﻤﻋ
Simple Assignment Operator ﺪﻫﺩ ﯽﻣ ﺹﺎﺼﺘﺧﺍ ﺮﯿﻐﺘﻣ ﮏﯾ ﻪﺑ ﺍﺭ ﯼﺭﺍﺪﻘﻣ.
let x = 10;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Assignments</h1>
<h2>Simple Assignment</h2>
<h3>The = Operator</h3>
<p id="demo"></p>
<script>
let x = 10;
document.getElementById("demo").innerHTML = "Value of x is: " + x;
</script>
</body>
</html>
let x = 10 + y;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Assignments</h1>
<h2>Simple Assignment</h2>
<h3>The = Operator</h3>
<p id="demo"></p>
<script>
let y = 50
let x = 10 + y;
document.getElementById("demo").innerHTML = "Value of x is: " + x;
</script>
</body>
</html>
Addition Assignment Operator ﺪﻨﮐ ﯽﻣ ﻪﻓﺎﺿﺍ ﺮﯿﻐﺘﻣ ﻪﺑ ﺭﺍﺪﻘﻣ ﮏﯾ.
let x = 10;
x += 5;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Assignments</h1>
<h2>Addition Assignment</h2>
<h3>The += Operator</h3>
<p id="demo"></p>
<script>
let x = 10;
x += 5;
document.getElementById("demo").innerHTML = "Value of x is: " + x;
</script>
</body>
</html>
let text = "Hello";
text += " World";
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Assignments</h1>
<h2>Addition Assignment</h2>
<h3>The += Operator</h3>
<p id="demo"></p>
<script>
let text = "Hello";
text += " World";
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>
ﻖﯾﺮﻔﺗ ﺺﯿﺼﺨﺗ ﺮﮕﻠﻤﻋ ﺪﻨﮐ ﯽﻣ ﻢﮐ ﺮﯿﻐﺘﻣ ﮏﯾ ﺯﺍ ﺍﺭ ﯼﺭﺍﺪﻘﻣ.
let x = 10;
x -= 5;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Assignments</h1>
<h2>Subtraction Assignment</h2>
<h3>The -= Operator</h3>
<p id="demo"></p>
<script>
let x = 10;
x -= 5;
document.getElementById("demo").innerHTML = "Value of x is: " + x;
</script>
</body>
</html>
ﺏﺮﺿ ﺺﯿﺼﺨﺗ ﺭﻮﺗﺍﺮﭘﺍ ﺪﻨﮐ ﯽﻣ ﺏﺮﺿ ﺍﺭ ﺮﯿﻐﺘﻣ ﮏﯾ.
let x = 10;
x *= 5;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Assignments</h1>
<h2>Multiplication Assignment</h2>
<h3>The *= Operator</h3>
<p id="demo"></p>
<script>
let x = 10;
x *= 5;
document.getElementById("demo").innerHTML = "Value of x is: " + x;
</script>
</body>
</html>
ﯽﯾﺎﻤﻧ ﺺﯿﺼﺨﺗ ﺮﮕﻠﻤﻋ ﺪﻫﺩ ﯽﻣ ﺶﯾﺍﺰﻓﺍ ﺪﻧﻮﻠﻤﻋ ﻥﺍﻮﺗ ﻪﺑ ﺍﺭ ﺮﯿﻐﺘﻣ ﮏﯾ.
let x = 10;
x **= 5;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Assignments</h1>
<h2>Exponentiation Assignment</h2>
<h3>The **= Operator</h3>
<p id="demo"></p>
<script>
let x = 10;
x **= 5;
document.getElementById("demo").innerHTML = "Value of x is: " + x;
</script>
</body>
</html>
ﺶﺨﺑ ﯼﺭﺍﺬﮔﺍﻭ ﺭﻮﺗﺍﺮﭘﺍ ﺪﻨﮐ ﯽﻣ ﻢﯿﺴﻘﺗ ﺍﺭ ﺮﯿﻐﺘﻣ ﮏﯾ.
let x = 10;
x /= 5;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Assignments</h1>
<h2>Division Assignment</h2>
<h3>The /= Operator</h3>
<p id="demo"></p>
<script>
let x = 10;
x /= 5;
document.getElementById("demo").innerHTML = x;
</script>
</body>
</html>
Remainder Assignment Operator ﺪﻫﺩ ﯽﻣ ﺹﺎﺼﺘﺧﺍ ﺮﯿﻐﺘﻣ ﮏﯾ ﻪﺑ ﺍﺭ ﻩﺪﻧﺎﻤﯿﻗﺎﺑ.
let x = 10;
x %= 5;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Assignments</h1>
<h2>Remainder Assignment</h2>
<h3>The %= Operator</h3>
<p id="demo"></p>
<script>
let x = 10;
x %= 5;
document.getElementById("demo").innerHTML = "Value of x is: " + x;
</script>
</body>
</html>
Operator ﭗﭼ ﺖﻤﺳ ﺮﯿﯿﻐﺗ ﯼﺭﺍﺬﮔﺍﻭ ﺪﻫﺩ ﯽﻣ ﺮﯿﯿﻐﺗ ﭗﭼ ﻪﺑ ﺍﺭ ﺮﯿﻐﺘﻣ ﮏﯾ.
let x = -100;
x <<= 5;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Assignments</h1>
<h2>Left Shift Assignment</h2>
<h3>The <<= Operator</h3>
<p id="demo"></p>
<script>
let x = -100;
x <<= 5;
document.getElementById("demo").innerHTML = "Value of x is: " + x;
</script>
</body>
</html>
ﺭﻮﺗﺍﺮﭘﺍ ﺺﯿﺼﺨﺗ ﺖﻔﯿﺷ ﺖﺳﺍﺭ ﺪﻨﮐ ﯽﻣ ﺎﺠﺑﺎﺟ ﺖﺳﺍﺭ ﻪﺑ ﺍﺭ (ﺎﻀﻣﺍ) ﺮﯿﻐﺘﻣ ﮏﯾ.
let x = -100;
x >>= 5;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Assignments</h1>
<h2>Right Shift Assignment</h2>
<h3>The >>= Operator</h3>
<p id="demo"></p>
<script>
let x = -100;
x >>= 5;
document.getElementById("demo").innerHTML = "Value of x is: " + x;
</script>
</body>
</html>
ﺖﻣﻼﻋ ﻥﻭﺪﺑ ﺖﻔﯿﺷ ﺺﯿﺼﺨﺗ ﺭﻮﺗﺍﺮﭘﺍ ﺪﻨﮐ ﯽﻣ ﺎﺠﺑﺎﺟ ﺖﺳﺍﺭ ﻪﺑ ﺍﺭ (ﺖﻣﻼﻋ ﻥﻭﺪﺑ) ﺮﯿﻐﺘﻣ ﮏﯾ.
let x = -100;
x >>>= 5;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Assignments</h1>
<h2>Right Shift Assignment</h2>
<h3>The >>>= Operator</h3>
<p id="demo"></p>
<script>
let x = -100;
x >>>= 5;
document.getElementById("demo").innerHTML = "Value of x is: " + x;
</script>
</body>
</html>
Bitwise AND Assignment Operator ﯽﺘﯿﺑ ﻞﻤﻋ ﮏﯾ AND ﺪﻫﺩ ﯽﻣ ﻡﺎﺠﻧﺍ ﺪﻧﻮﻠﻤﻋ ﻭﺩ ﯼﻭﺭ.
let x = 10;
x &= 5;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Assignments</h1>
<h2>Bitwise AND Assignment</h2>
<h3>The &= Operator</h3>
<p id="demo"></p>
<script>
let x = 100;
x &= 5;
document.getElementById("demo").innerHTML = "Value of x is: " + x;
</script>
</body>
</html>
Bitwise OR Assignment Operator ﺕﺎﯿﻠﻤﻋ ﮏﯾ OR ﺪﻫﺩ ﯽﻣ ﻡﺎﺠﻧﺍ ﺪﻧﻮﻠﻤﻋ ﻭﺩ ﯼﻭﺭ ﺍﺭ ﯽﺘﯿﺑ.
let x = 10;
x |= 5;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Assignments</h1>
<h2>Bitwise OR Assignment</h2>
<h3>The |= Operator</h3>
<p id="demo"></p>
<script>
let x = 100;
x |= 5;
document.getElementById("demo").innerHTML = "Value of x is: " + x;
</script>
</body>
</html>
Bitwise XOR Assignment Operator ﺕﺎﯿﻠﻤﻋ ﮏﯾ XOR ﺪﻫﺩ ﯽﻣ ﻡﺎﺠﻧﺍ ﺪﻧﻮﻠﻤﻋ ﻭﺩ ﯼﻭﺭ ﺍﺭ ﯽﺘﯿﺑ.
let x = 10;
x ^= 5;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Assignments</h1>
<h2>Bitwise XOR Assignment</h2>
<h3>The ^= Operator</h3>
<p id="demo"></p>
<script>
let x = 100;
x ^= 5;
document.getElementById("demo").innerHTML = "Value of x is: " + x;
</script>
</body>
</html>
ﯽﻘﻄﻨﻣ ﺺﯿﺼﺨﺗ ﺮﮕﻠﻤﻋ AND ﺩﻮﺷ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﺭﺍﺪﻘﻣ ﻭﺩ ﻦﯿﺑ.
.ﺩﻮﺷ ﯽﻣ ﻩﺩﺍﺩ ﺺﯿﺼﺨﺗ ﻡﻭﺩ ﺭﺍﺪﻘﻣ ،ﺪﺷﺎﺑ ﺖﺳﺭﺩ ﻝﻭﺍ ﺭﺍﺪﻘﻣ ﺮﮔﺍ
let x = 10;
x &&= 5;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Assignments</h1>
<h2>Logical AND Assignment</h2>
<h3>The &&= Operator</h3>
<p>If the first value is true, the second value is assigned.</p>
<p id="demo"></p>
<script>
let x = 100;
x &&= 5;
document.getElementById("demo").innerHTML = "Value of x is: " + x;
</script>
</body>
</html>
.ﺖﺳﺍ ES2020 ﯽﮔﮋﯾﻭ ﮏﯾ &&=
ﺭﻮﺗﺍﺮﭘﺍ
ﯽﻘﻄﻨﻣ ﺺﯿﺼﺨﺗ ﺮﮕﻠﻤﻋ OR ﺩﻮﺷ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﺭﺍﺪﻘﻣ ﻭﺩ ﻦﯿﺑ.
.ﺩﻮﺷ ﯽﻣ ﻩﺩﺍﺩ ﺺﯿﺼﺨﺗ ﻡﻭﺩ ﺭﺍﺪﻘﻣ ،ﺪﺷﺎﺑ ﺖﺳﺭﺩﺎﻧ ﻝﻭﺍ ﺭﺍﺪﻘﻣ ﺮﮔﺍ
let x = 10;
x ||= 5;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Assignments</h1>
<h2>Logical OR Assignment</h2>
<h3>The ||= Operator</h3>
<p>If the first value is false, the second value is assigned:</p>
<p id="demo"></p>
<script>
let x = undefined;
x ||= 5;
document.getElementById("demo").innerHTML = "Value of x is: " + x;
</script>
</body>
</html>
.ﺖﺳﺍ ES2020 ﯽﮔﮋﯾﻭ ﮏﯾ ||=
ﺭﻮﺗﺍﺮﭘﺍ
ﻞﻃﺎﺑ ﻡﺎﻏﺩﺍ ﺺﯿﺼﺨﺗ ﺮﮕﻠﻤﻋ ﺩﻮﺷ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﺭﺍﺪﻘﻣ ﻭﺩ ﻦﯿﺑ.
.ﺩﻮﺷ ﯽﻣ ﻩﺩﺍﺩ ﺺﯿﺼﺨﺗ ﻡﻭﺩ ﺭﺍﺪﻘﻣ ،ﺪﺷﺎﺑ ﯽﻬﺗ ﺎﯾ ﻩﺪﺸﻧ ﻒﯾﺮﻌﺗ ﻝﻭﺍ ﺭﺍﺪﻘﻣ ﺮﮔﺍ
let x;
x ??= 5;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Assignments</h1>
<h2>The ??= Operator</h2>
<p>The ??= operator is used between two values. If the first value is undefined or null, the second value is assigned.</p>
<p id="demo"></p>
<script>
let x;
document.getElementById("demo").innerHTML = x ??= 5;
</script>
</body>
</html>
.ﺖﺳﺍ ES2020 ﯽﮔﮋﯾﻭ ﮏﯾ ??=
ﺭﻮﺗﺍﺮﭘﺍ