.ﺪﻨﻫﺩ ﯽﻣ ﻡﺎﺠﻧﺍ ﺍﺭ ﺏﺎﺴﺣ (ﺎﻫﺮﯿﻐﺘﻣ ﺎﯾ ﯽﻈﻔﻠﻟﺍ) ﺩﺍﺪﻋﺍ ﯼﻭﺭ ﺮﺑ ﯽﺑﺎﺴﺣ ﯼﺎﻫﺮﮕﻠﻤﻋ
ﻥﺪﺷ ﻪﻓﺎﺿﺍ
ﻥﺩﺮﮐ ﺎﻬﻨﻣ
ﺏﺮﺿ
(ES2016) ﯼﺪﻨﻤﻧﺍﻮﺗ
ﺶﺨﺑ
(ﻩﺪﻧﺎﻣ ﯽﻗﺎﺑ) ﻝﻭﺪﻣ
ﺶﯾﺍﺰﻓﺍ
ﺶﻫﺎﮐ
.ﺪﻨﮐ ﯽﻣ ﻞﻤﻋ ﺩﺪﻋ ﻭﺩ ﯼﻭﺭ ﺮﺑ ﯽﻟﻮﻤﻌﻣ ﯽﺑﺎﺴﺣ ﺕﺎﯿﻠﻤﻋ ﮏﯾ
:ﺪﻨﺷﺎﺑ ﯽﻈﻔﻠﻟﺍ ﺖﺤﺗ ﺪﻨﻧﺍﻮﺗ ﯽﻣ ﺩﺪﻋ ﻭﺩ ﻦﯾﺍ
let x = 100 + 50;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Arithmetic</h2>
<p>A typical arithmetic operation takes two numbers and produces a new number.</p>
<p id="demo"></p>
<script>
let x = 100 + 50;
document.getElementById("demo").innerHTML = x;
</script>
</body>
</html>
:ﺎﻫﺮﯿﻐﺘﻣ ﺎﯾ
let x = a + b;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Arithmetic</h2>
<p>A typical arithmetic operation takes two numbers (or variables) and produces a new number.</p>
<p id="demo"></p>
<script>
let a = 100;
let b = 50;
let x = a + b;
document.getElementById("demo").innerHTML = x;
</script>
</body>
</html>
:ﺕﺍﺭﺎﺒﻋ ﺎﯾ
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>
.ﺪﻧﻮﺷ ﯽﻣ ﻩﺪﯿﻣﺎﻧ ﺪﻧﻮﻠﻤﻋ (ﯽﺑﺎﺴﺣ ﺕﺎﯿﻠﻤﻋ ﮏﯾ ﺭﺩ) ﺩﺍﺪﻋﺍ
.ﺩﻮﺷ ﯽﻣ ﻒﯾﺮﻌﺗ ﺮﮕﻠﻤﻋ ﻂﺳﻮﺗ (ﺩﻮﺷ ﯽﻣ ﻡﺎﺠﻧﺍ ﺪﻧﻮﻠﻤﻋ ﻭﺩ ﻦﯿﺑ ﻪﮐ) ﺕﺎﯿﻠﻤﻋ
Operand | Operator | Operand |
---|---|---|
100 | + | 50 |
:ﺪﻨﮐ ﯽﻣ ﻪﻓﺎﺿﺍ ﺍﺭ ﺩﺍﺪﻋﺍaddition (+
)> ﺮﮕﻠﻤﻋ
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 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>
.ﺪﻨﮐ ﯽﻣ ﻢﯿﺴﻘﺗ ﺍﺭ ﺩﺍﺪﻋﺍdivision (/
)> ﺮﮕﻠﻤﻋ
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>
.ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ ﻢﯿﺴﻘﺗ ﻩﺪﻧﺎﻤﯿﻗﺎﺑmodulus (%
)> ﺮﮕﻠﻤﻋ
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>
ﺪﻨﮐ ﯽﻣ ﺪﯿﻟﻮﺗ ﺐﯾﺮﺿﮏﯾ ﺢﯿﺤﺻ ﺩﺪﻋ ﻭﺩ ﻢﯿﺴﻘﺗ ،ﺏﺎﺴﺣ ﺭﺩ
.ﺖﺳﺍ ﯽﺑﺎﺴﺣ ﺖﻤﺴﻗﯽﻗﺎﺑ ﻝﻭﺪﻣ ﺕﺎﯿﻠﻤﻋ ﻪﺠﯿﺘﻧ ،ﺕﺎﯿﺿﺎﯾﺭ ﺭﺩ
.ﺪﻫﺩ ﯽﻣ ﺶﯾﺍﺰﻓﺍ ﺍﺭ ﺩﺍﺪﻋﺍincrement (++
)> ﺮﮕﻠﻤﻋ
let x = 5;
x++;
let z = x;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arithmetic</h1>
<h2>The ++ Operator</h2>
<p id="demo"></p>
<script>
let x = 5;
x++;
let z = x;
document.getElementById("demo").innerHTML = z;
</script>
</body>
</html>
.ﺪﻫﺩ ﯽﻣ ﺶﻫﺎﮐ ﺍﺭ ﺩﺍﺪﻋﺍ (--
)/>ﺶﻫﺎﮐ ﺮﮕﻠﻤﻋ
let x = 5;
x--;
let z = x;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arithmetic</h1>
<h2>The -- Operator</h2>
<p id="demo"></p>
<script>
let x = 5;
x--;
let z = x;
document.getElementById("demo").innerHTML = z;
</script>
</body>
</html>
.ﺪﻫﺩ ﯽﻣ ﺶﯾﺍﺰﻓﺍ ﻡﻭﺩ ﺪﻧﻮﻠﻤﻋ ﻥﺍﻮﺗ ﻪﺑ ﺍﺭ ﻝﻭﺍ ﺪﻧﻮﻠﻤﻋ (**
)/>ﯽﻧﺍﻮﺗ ﺮﮕﻠﻤﻋ
let x = 5;
let z =
x ** 2;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arithmetic</h1>
<h2>The ** Operator</h2>
<p id="demo"></p>
<script>
let x = 5;
document.getElementById("demo").innerHTML = x ** 2;
</script>
</body>
</html>
x ** y ﻪﺑﺎﺸﻣ ﻪﺠﯿﺘﻧ Math.pow(x,y)
ﺪﻨﮐ ﯽﻣ ﺩﺎﺠﯾﺍ ﺍﺭ:
let x = 5;
let z =
Math.pow(x,2);
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arithmetic</h1>
<h2>Math.pow()</h2>
<p id="demo"></p>
<script>
let x = 5;
document.getElementById("demo").innerHTML = Math.pow(x,2);
</script>
</body>
</html>
ﺪﻨﮐ ﯽﻣ ﻒﯿﺻﻮﺗ ﺍﺭ ﺩﻮﺷ ﯽﻣ ﻡﺎﺠﻧﺍ ﻥﺁ ﺭﺩ ﺕﺎﯿﻠﻤﻋ ﻪﮐ ﺍﺭ ﯽﺒﯿﺗﺮﺗ ﺮﮕﻠﻤﻋ ﻡﺪﻘﺗ
let x = 100 + 50 * 3;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arithmetic</h1>
<h2>Operator Precedence</h2>
<p>Multiplication has precedence over addition.</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = 100 + 50 * 3;
</script>
</body>
</html>
ﺖﺳﺍ 100 ﻥﺎﻤﻫ ﺎﯾ ﺖﺳﺍ 3 * 150 ﻥﺎﻤﻫ ﻻﺎﺑ ﻝﺎﺜﻣ ﻪﺠﯿﺘﻧ ﺎﯾﺁ
؟ﺩﻮﺷ ﯽﻣ ﻡﺎﺠﻧﺍ ﺏﺮﺿ ﺎﯾ ﻊﻤﺟ ﺍﺪﺘﺑﺍ ﺎﯾﺁ
.ﺩﻮﺷ ﯽﻣ ﻡﺎﺠﻧﺍ ﺏﺮﺿ ﺍﺪﺘﺑﺍ ،ﯽﺘﻨﺳ ﻪﺳﺭﺪﻣ ﺕﺎﯿﺿﺎﯾﺭ ﺭﺩ ﻪﮐ ﺭﻮﻄﻧﺎﻤﻫ
ﺯﺍ ﺮﺗﻻﺎﺑ ﺖﯿﺟﻭﺍ ﯼﺍﺭﺍﺩ ( ﺩﺍﺩ ﺮﯿﯿﻐﺗ ﻩﺩﺎﻔﺘﺳﺍ ﺎﺑ ﻥﺍﻮﺗ ﯽﻣ ﺍﺭ ﻡﺪﻘﺗ (ﻪﺳﺭﺪﻣ ﺕﺎﯿﺿﺎﯾﺭ ﺭﺩ ﻪﮐ ﺭﻮﻄﻧﺎﻤﻫ) ﻭ ﺩﻮﺷ ﯽﻣ ﻪﺒﺳﺎﺤﻣ ﺰﺘﻧﺍﺮﭘ ﻞﺧﺍﺩ ﺕﺎﯿﻠﻤﻋ ،ﺰﺘﻧﺍﺮﭘ ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ ﻡﺎﮕﻨﻫ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ ﻭ ﻊﻤﺟ ﺪﻨﻧﺎﻣ) ﺪﻨﺘﺴﻫ ﻥﺎﺴﮑﯾ ﺖﯾﻮﻟﻭﺍ ﯼﺍﺭﺍﺩ ﺕﺎﯿﻠﻤﻋ ﺯﺍ ﯼﺭﺎﯿﺴﺑ ﻪﮐ ﯽﻣﺎﮕﻨﻫ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺪﯾﻭﺮﺑ ﺮﯾﺯ ﺱﺭﺩﺁ ﻪﺑ ﺮﮕﻠﻤﻋ ﺖﯾﻮﻟﻭﺍ ﺮﯾﺩﺎﻘﻣ ﺯﺍ ﻞﻣﺎﮐ ﺖﺴﯿﻟ ﮏﯾ ﯼﺍﺮﺑ .ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺭﻮﺗﺍﺮﭘﺍ ﺖﯾﻮﻟﻭﺍ ﺮﯾﺩﺎﻘﻣ/
) ﻢﯿﺴﻘﺗ ﻭ (*
ﻝﺎﺜﻣ
let x = (100 + 50) * 3;
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arithmetic</h1>
<h2>Operator Precedence</h2>
<p>Multiplication has precedence over addition.</p>
<p>But parenthesis has precedence over multiplication.</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = (100 + 50) * 3;
</script>
</body>
</html>
ﺎﻫ ﻝﺎﺜﻣ
let x = 100 + 50 - 3;
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arithmetic</h1>
<h2>Operator Precedence</h2>
<p>When many operations has the same precedence, they are computed from left to right.</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = 100 + 50 - 3;
</script>
</body>
</html>
let x = 100 / 50 * 3;
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arithmetic</h1>
<h2>Operator Precedence</h2>
<p>When many operations has the same precedence, they are computed from left to right.</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = 100 / 50 * 3;
</script>
</body>
</html>
ﺪﯿﺷﺎﺑ ﻪﺘﺷﺍﺩ ﻪﺟﻮﺗ