ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫﺭﻮﺗﺍﺮﭘﺍ


فهرست مطالب

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

Addition Operator + ﺪﻨﮐ ﯽﻣ ﻪﻓﺎﺿﺍ ﺍﺭ ﺩﺍﺪﻋﺍ:

ﺺﯿﺼﺨﺗ ﺭﻮﺗﺍﺮﭘﺍ = ﺪﻫﺩ ﯽﻣ ﺹﺎﺼﺘﺧﺍ ﺮﯿﻐﺘﻣ ﮏﯾ ﻪﺑ ﺍﺭ ﺭﺍﺪﻘﻣ ﮏﯾ.


ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺺﯿﺼﺨﺗ

ﺺﯿﺼﺨﺗ ﺭﻮﺗﺍﺮﭘﺍ (=) ﺪﻫﺩ ﯽﻣ ﺹﺎﺼﺘﺧﺍ ﺮﯿﻐﺘﻣ ﮏﯾ ﻪﺑ ﺍﺭ ﯼﺭﺍﺪﻘﻣ:

ﻒﯿﻠﮑﺗ ﯼﺎﻫ ﻪﻧﻮﻤﻧ

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;

:ﺩﻮﺑ ﺪﻫﺍﻮﺧ zx، 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>

ﺪﯿﺷﺎﺑ ﻪﺘﺷﺍﺩ ﻪﺟﻮﺗ

!ﺩﻮﺑ ﺪﻫﺍﻮﺧ ﻪﺘﺷﺭ ﮏﯾ ﻪﺠﯿﺘﻧ ،ﺪﯿﻨﮐ ﻪﻓﺎﺿﺍ ﻪﺘﺷﺭ ﮏﯾ ﻭ ﺩﺪﻋ ﮏﯾ ﺮﮔﺍ


ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯽﻘﻄﻨﻣ ﯼﺎﻫﺮﮕﻠﻤﻋ

&&

ﻭ ﯽﻘﻄﻨﻣ

||

ﺎﯾ ﯽﻘﻄﻨﻣ

!

ﺖﺴﯿﻧ ﯽﻘﻄﻨﻣ

ﺪﯿﺷﺎﺑ ﻪﺘﺷﺍﺩ ﻪﺟﻮﺗ

ﺪﻧﺍ ﻩﺪﺷ ﻩﺩﺍﺩ ﺢﯿﺿﻮﺗ ﺭﺩ ﻞﻣﺎﮐ ﺭﻮﻃ ﻪﺑ ﯽﻘﻄﻨﻣ ﯼﺎﻫﺮﮕﻠﻤﻋ


ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻉﻮﻧ ﯼﺎﻫﺮﮕﻠﻤﻋ

typeof

ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ ﺮﯿﻐﺘﻣ ﮏﯾ ﻉﻮﻧ

instanceof

ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ 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> ﺭﺩ ﻞﻣﺎﮐ ﺭﻮﻃ ﻪﺑ ﯽﺘﯿﺑ ﯼﺎﻫﺮﮕﻠﻤﻋ



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