ﺺﯿﺼﺨﺗ ﺭﻮﺗﺍﺮﭘﺍ (=
) ﺪﻫﺩ ﯽﻣ ﺹﺎﺼﺘﺧﺍ ﺮﯿﻐﺘﻣ ﮏﯾ ﻪﺑ ﺍﺭ ﯼﺭﺍﺪﻘﻣ:
let x = 10;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Operators</h1>
<h2>The = Operator</h2>
<p id="demo"></p>
<script>
let x = 10;
document.getElementById("demo").innerHTML = x;
</script>
</body>
</html>
// Assign the value 5 to x
let x = 5;
// Assign the value 2 to y
let y = 2;
// Assign the value x + y to z:
let z = x + y;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Operators</h1>
<h2>The Assignment (=) Operator</h2>
<p id="demo"></p>
<script>
// Assign the value 5 to x
let x = 5;
// Assign the value 2 to y
let y = 2;
// Assign the value x + y to z
let z = x + y;
// Display z
document.getElementById("demo").innerHTML = "The sum of x + y is: " + z;
</script>
</body>
</html>
Addition Operator (+
) ﺪﻨﮐ ﯽﻣ ﻪﻓﺎﺿﺍ ﺍﺭ ﺩﺍﺪﻋﺍ:
let x = 5;
let y = 2;
let z = x + y;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arithmetic</h1>
<h2>The + Operator</h2>
<p id="demo"></p>
<script>
let x = 5;
let y = 2;
let z = x + y;
document.getElementById("demo").innerHTML = z;
</script>
</body>
</html>
ﺏﺮﺿ ﺮﮕﻠﻤﻋ (*
) ﺪﻨﮐ ﯽﻣ ﺏﺮﺿ ﺍﺭ ﺩﺍﺪﻋﺍ:
let x = 5;
let y = 2;
let z = x * y;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arithmetic</h1>
<h2>The * Operator</h2>
<p id="demo"></p>
<script>
let x = 5;
let y = 2;
let z = x * y;
document.getElementById("demo").innerHTML = z;
</script>
</body>
</html>
:ﺪﻧﺭﺍﺩ ﯽﻔﻠﺘﺨﻣ ﻉﺍﻮﻧﺍ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫﺭﻮﺗﺍﺮﭘﺍ
ﯽﺑﺎﺴﺣ ﯼﺎﻫﺮﮕﻠﻤﻋ
ﯼﺭﺍﺬﮔﺍﻭ ﯼﺎﻫﺭﻮﺗﺍﺮﭘﺍ
ﻪﺴﯾﺎﻘﻣ ﯼﺎﻫﺭﻮﺗﺍﺮﭘﺍ
ﯼﺍ ﻪﺘﺷﺭ ﯼﺎﻫﺮﮕﻠﻤﻋ
ﯽﻘﻄﻨﻣ ﯼﺎﻫﺮﮕﻠﻤﻋ
ﯽﺘﯿﺑ ﯼﺎﻫﺭﻮﺗﺍﺮﭘﺍ
ﯽﯾﺎﺗ ﻪﺳ ﯼﺎﻫﺭﻮﺗﺍﺮﭘﺍ
ﺪﯿﻨﮐ ﭗﯾﺎﺗ ﺍﺭ ﺎﻫﺮﮕﻠﻤﻋ
ﯽﺑﺎﺴﺣ ﯼﺎﻫﺮﮕﻠﻤﻋ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﺩﺍﺪﻋﺍ ﯼﻭﺭ ﺕﺎﺒﺳﺎﺤﻣ ﻡﺎﺠﻧﺍ ﯼﺍﺮﺑﺪﻧﻮﺷ:
let a = 3;
let x = (100 + 50) * a;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arithmetic</h1>
<h2>Arithmetic Operations</h2>
<p>A typical arithmetic operation takes two numbers (or expressions) and produces a new number.</p>
<p id="demo"></p>
<script>
let a = 3;
let x = (100 + 50) * a;
document.getElementById("demo").innerHTML = x;
</script>
</body>
</html>
ﻥﺪﺷ ﻪﻓﺎﺿﺍ
ﻥﺩﺮﮐ ﺎﻬﻨﻣ
ﺏﺮﺿ
(ES2016) ﯼﺪﻨﻤﻧﺍﻮﺗ
ﺶﺨﺑ
(ﻩﺪﻧﺎﻤﯿﻗﺎﺑ ﺶﺨﺑ) ﻝﻭﺪﻣ
ﺶﯾﺍﺰﻓﺍ
ﺶﻫﺎﮐ
ﺪﻧﺍ ﻩﺪﺷ ﻩﺩﺍﺩ ﺢﯿﺿﻮﺗ ﺭﺩ ﻞﻣﺎﮐ ﺭﻮﻃ ﻪﺑ ﯽﺑﺎﺴﺣ ﯼﺎﻫﺮﮕﻠﻤﻋ
.ﺪﻨﻫﺩ ﯽﻣ ﺹﺎﺼﺘﺧﺍ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫﺮﯿﻐﺘﻣ ﻪﺑ ﺍﺭ ﯼﺮﯾﺩﺎﻘﻣ ﺏﺎﺴﺘﻧﺍ ﯼﺎﻫﺮﮕﻠﻤﻋ
Addition Assignment Operator (+=
) ﺪﻨﮐ ﯽﻣ ﻪﻓﺎﺿﺍ ﺮﯿﻐﺘﻣ ﮏﯾ ﻪﺑ ﺭﺍﺪﻘﻣ ﮏﯾ.
let x = 10;
x += 5;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arithmetic</h1>
<h2>The += Operator</h2>
<p id="demo"></p>
<script>
var x = 10;
x += 5;
document.getElementById("demo").innerHTML = x;
</script>
</body>
</html>
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 |
ﺖﺳﺍ ﻩﺪﺷ ﻩﺩﺍﺩ ﺢﯿﺿﻮﺗ ﺭﺩ ﻞﻣﺎﮐ ﺭﻮﻃ ﻪﺑ ﺏﺎﺴﺘﻧﺍ ﯼﺎﻫﺮﮕﻠﻤﻋ
ﺎﺑ ﯼﻭﺎﺴﻣ
ﯼﻭﺎﺴﻣ ﻉﻮﻧ ﻭ ﺮﺑﺍﺮﺑ ﺵﺯﺭﺍ
ﺮﺑﺍﺮﺑ ﺎﻧ
ﺖﺴﯿﻧ ﯼﻭﺎﺴﻣ ﻉﻮﻧ ﺎﯾ ﺖﺴﯿﻧ ﯼﻭﺎﺴﻣ ﺭﺍﺪﻘﻣ
ﺯﺍ ﺮﺘﮔﺭﺰﺑ
ﺯﺍ ﺮﺘﻤﮐ
ﺎﺑ ﯼﻭﺎﺴﻣ ﺎﯾ ﺮﺘﮔﺭﺰﺑ
ﯼﻭﺎﺴﻣ ﺎﯾ ﺮﺘﻤﮐ
ﯽﯾﺎﺗ ﻪﺳ ﺭﻮﺗﺍﺮﭘﺍ
ﺖﺳﺍ ﻩﺪﺷ ﻩﺩﺍﺩ ﺢﯿﺿﻮﺗ ﺭﺩ ﻞﻣﺎﮐ ﺭﻮﻃ ﻪﺑ ﻪﺴﯾﺎﻘﻣ ﯼﺎﻫﺮﮕﻠﻤﻋ
:ﺩﺮﮐ ﻩﺩﺎﻔﺘﺳﺍ ﺰﯿﻧ ﺎﻫ ﻪﺘﺷﺭ ﯼﻭﺭ ﻥﺍﻮﺗ ﯽﻣ ﺍﺭ ﻕﻮﻓ ﻪﺴﯾﺎﻘﻣ ﯼﺎﻫﺮﮕﻠﻤﻋ ﻪﻤﻫ
let text1 = "A";
let text2 = "B";
let result = text1 < text2;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript String Operators</h1>
<p>All conditional operators can be used on both numbers and strings.</p>
<p id="demo"></p>
<script>
let text1 = "A";
let text2 = "B";
let result = text1 < text2;
document.getElementById("demo").innerHTML = "Is A less than B? " + result;
</script>
</body>
</html>
:ﺪﻧﻮﺷ ﯽﻣ ﻪﺴﯾﺎﻘﻣ ﺎﺒﻔﻟﺍ ﻑﻭﺮﺣ ﺱﺎﺳﺍ ﺮﺑ ﺎﻫ ﻪﺘﺷﺭ ﻪﮐ ﺪﯿﺷﺎﺑ ﻪﺘﺷﺍﺩ ﻪﺟﻮﺗ
let text1 = "20";
let text2 = "5";
let result = text1 < text2;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript String Operators</h1>
<p>Note that strings are compared alphabetically:</p>
<p id="demo"></p>
<script>
let text1 = "20";
let text2 = "5";
let result = text1 < text2;
document.getElementById("demo").innerHTML = "Is 20 less than 5? " + result;
</script>
</body>
</html>
+
ﺩﻮﺷ ﻩﺩﺎﻔﺘﺳﺍ ﺎﻫ ﻪﺘﺷﺭ (ﻦﺘﺳﻮﯿﭘ ﻢﻫ ﻪﺑ) ﻥﺩﻭﺰﻓﺍ ﯼﺍﺮﺑ ﺪﻧﺍﻮﺗ ﯽﻣ ﻦﯿﻨﭽﻤﻫ:
let text1 = "John";
let text2 = "Doe";
let text3 = text1 + " " + text2;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript String Operators</h1>
<h2>The + Operator</h2>
<p>The + operator concatenates (adds) strings.</p>
<p id="demo"></p>
<script>
let text1 = "John";
let text2 = "Doe";
let text3 = text1 + " " + text2;
document.getElementById("demo").innerHTML = text3;
</script>
</body>
</html>
:ﺩﻮﺷ ﻩﺩﺎﻔﺘﺳﺍ ﺎﻫ ﻪﺘﺷﺭ (ﻦﺘﺳﻮﯿﭘ ﻢﻫ ﻪﺑ) ﻥﺩﻭﺰﻓﺍ ﯼﺍﺮﺑ ﺪﻧﺍﻮﺗ ﯽﻣ ﻦﯿﻨﭽﻤﻫ +=
ﺺﯿﺼﺨﺗ ﺮﮕﻠﻤﻋ
let text1 = "What a very ";
text1 += "nice day";
:ﺩﻮﺑ ﺪﻫﺍﻮﺧ 1 ﻦﺘﻣ ﻪﺠﯿﺘﻧ
What a very nice day
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript String Operators</h1>
<h2>The += Operator</h2>
<p>The assignment operator += can concatenate strings.</p>
<p id="demo"></p>
<script>
let text1 = "What a very ";
text1 += "nice day";
document.getElementById("demo").innerHTML = text1;
</script>
</body>
</html>
.ﺩﻮﺷ ﯽﻣ ﻩﺪﯿﻣﺎﻧ ﻕﺎﺤﻟﺍ ﺮﮕﻠﻤﻋ + ﺮﮕﻠﻤﻋ ،ﺩﻮﺷ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﺎﻫ ﻪﺘﺷﺭ ﯼﻭﺭ ﺮﺑ ﻪﮐ ﯽﻣﺎﮕﻨﻫ
:ﺩﺩﺮﮔ ﯽﻣﺮﺑ ﻪﺘﺷﺭ ﮏﯾ ،ﻪﺘﺷﺭ ﮏﯾ ﻭ ﺩﺪﻋ ﮏﯾ ﻥﺩﺮﮐ ﻊﻤﺟ ﺎﺑ ﺎﻣﺍ ،ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ ﻉﻮﻤﺠﻣ ،ﺩﺪﻋ ﻭﺩ ﻥﺩﻭﺰﻓﺍ ﺎﺑ
let x = 5 + 5;
let y = "5" + 5;
let z = "Hello" + 5;
:ﺩﻮﺑ ﺪﻫﺍﻮﺧ z ﻭ x، y ﻪﺠﯿﺘﻧ
10
55
Hello5
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript String Operators</h1>
<h2>The + Operator</h2>
<p>Adding a number and a string, returns a string.</p>
<p id="demo"></p>
<script>
let x = 5 + 5;
let y = "5" + 5;
let z = "Hello" + 5;
document.getElementById("demo").innerHTML =
x + "<br>" + y + "<br>" + z;
</script>
</body>
</html>
!ﺩﻮﺑ ﺪﻫﺍﻮﺧ ﻪﺘﺷﺭ ﮏﯾ ﻪﺠﯿﺘﻧ ،ﺪﯿﻨﮐ ﻪﻓﺎﺿﺍ ﻪﺘﺷﺭ ﮏﯾ ﻭ ﺩﺪﻋ ﮏﯾ ﺮﮔﺍ
ﻭ ﯽﻘﻄﻨﻣ
ﺎﯾ ﯽﻘﻄﻨﻣ
ﺖﺴﯿﻧ ﯽﻘﻄﻨﻣ
ﺪﻧﺍ ﻩﺪﺷ ﻩﺩﺍﺩ ﺢﯿﺿﻮﺗ ﺭﺩ ﻞﻣﺎﮐ ﺭﻮﻃ ﻪﺑ ﯽﻘﻄﻨﻣ ﯼﺎﻫﺮﮕﻠﻤﻋ
ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ ﺮﯿﻐﺘﻣ ﮏﯾ ﻉﻮﻧ
ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ true ﺭﺍﺪﻘﻣ ،ﺪﺷﺎﺑ ﯽﺷ ﻉﻮﻧ ﮏﯾ ﺯﺍ ﯼﺍ ﻪﻧﻮﻤﻧ ﯽﺷ ﮏﯾ ﺮﮔﺍ
.ﺖﺳﺍ ﻩﺪﺷ ﻩﺩﺍﺩ ﺢﯿﺿﻮﺗ
.ﺪﻨﻨﮐ ﯽﻣ ﺭﺎﮐ ﯽﺘﯿﺑ 32 ﺩﺍﺪﻋﺍ ﯼﻭﺭ ﺖﯿﺑ ﯼﺎﻫﺮﮕﻠﻤﻋ
.ﺩﻮﺷ ﯽﻣ ﻞﯾﺪﺒﺗ ﯽﺘﯿﺑ 32 ﺩﺪﻋ ﮏﯾ ﻪﺑ ﺕﺎﯿﻠﻤﻋ ﺭﺩ ﯼﺩﺪﻋ ﺪﻧﻮﻠﻤﻋ ﺮﻫ
Operator | Description | Example | Same as | Result | Decimal |
---|---|---|---|---|---|
& | AND | 5 & 1 | 0101 & 0001 | 0001 | 1 |
| | OR | 5 | 1 | 0101 | 0001 | 0101 | 5 |
~ | NOT | ~ 5 | ~0101 | 1010 | 10 |
^ | XOR | 5 ^ 1 | 0101 ^ 0001 | 0100 | 4 |
<< | left shift | 5 << 1 | 0101 << 1 | 1010 | 10 |
>> | right shift | 5 >> 1 | 0101 >> 1 | 0010 | 2 |
>>> | unsigned right shift | 5 >>> 1 | 0101 >>> 1 | 0010 | 2 |
.ﺪﻨﮐ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﯽﺘﯿﺑ 32 ﻩﺪﺷ ﺎﻀﻣﺍ ﺩﺍﺪﻋﺍ ﺯﺍ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺎﻣﺍ .ﺪﻨﻨﮐ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﺖﻣﻼﻋ ﻥﻭﺪﺑ ﯽﺘﯿﺑ 4 ﯼﺎﻫ ﻪﻧﻮﻤﻧ ﺯﺍ ﻻﺎﺑ ﯼﺎﻫ
ﺪﻧﺍ ﻩﺪﺷ ﻩﺩﺍﺩ ﺢﯿﺿﻮﺗJS> ﺭﺩ ﻞﻣﺎﮐ ﺭﻮﻃ ﻪﺑ ﯽﺘﯿﺑ ﯼﺎﻫﺮﮕﻠﻤﻋ