ﺖﺳﺍ ﻪﻧﻮﮕﭼ ﻪﮐ ﺖﺳﺍ ﻦﯿﻧﺍﻮﻗ ﺯﺍ ﯼﺍ ﻪﻋﻮﻤﺠﻣ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻮﺤﻧ
// How to create variables:
var x;
let y;
// How to use variables:
x = 5;
y = 6;
let z = x + y;
:ﺪﻨﮐ ﯽﻣ ﻒﯾﺮﻌﺗ ﺍﺭ ﺭﺍﺪﻘﻣ ﻉﻮﻧ ﻭﺩ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻮﺤﻧ
ﺖﺑﺎﺛ ﺮﯾﺩﺎﻘﻣ
ﺮﯿﻐﺘﻣ ﺮﯾﺩﺎﻘﻣ
.ﺪﻧﻮﺷ ﯽﻣ ﻩﺪﯿﻣﺎﻧ Literals ﺖﺑﺎﺛ ﺮﯾﺩﺎﻘﻣ
.ﺪﻨﯾﻮﮔ ﯽﻣ ﺮﯿﻐﺘﻣ ﺮﯿﻐﺘﻣ ﺮﯾﺩﺎﻘﻣ ﻪﺑ
:ﺯﺍ ﺪﻨﺗﺭﺎﺒﻋ ﺖﺑﺎﺛ ﺮﯾﺩﺎﻘﻣ ﯼﺍﺮﺑ ﻢﻬﻣ ﯼﻮﺤﻧ ﻥﻮﻧﺎﻗ ﻭﺩ
1. ﺩﺍﺪﻋﺍ ﺪﻧﻮﺷ ﯽﻣ ﻪﺘﺷﻮﻧ ﺎﯾ ﺎﺑ
10.50
1001
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Numbers</h2>
<p>Number can be written with or without decimals.</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = 10.50;
</script>
</body>
</html>
2. ﻪﺘﺷﺭﺎﻫ ﻪﻣﻮﯿﮔ ﺭﺩ ﻪﮐ ﺪﻨﺘﺴﻫ ﯽﻨﺘﻣﯽﻣ ﻪﺘﺷﻮﻧ ﯽﮑﺗ ﺎﯾ ﯽﯾﺎﺗﻭﺩ ﯼﺎﻫﺪﻧﻮﺷ:
"John Doe"
'John Doe'
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Strings</h2>
<p>Strings can be written with double or single quotes.</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = 'John Doe';
</script>
</body>
</html>
ﺎﻫﺮﯿﻐﺘﻣ ،ﯽﺴﯾﻮﻧ ﻪﻣﺎﻧﺮﺑ ﻥﺎﺑﺯ ﮏﯾ ﺭﺩ
،ﺪﻨﮐ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ var
ﯼﺪﯿﻠﮐ ﺕﺎﻤﻠﮐ ﺯﺍ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ
.ﺩﻮﺷﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﺎﻫﺮﯿﻐﺘﻣ ﻪﺑ ﺮﯾﺩﺎﻘﻣ ﺺﯿﺼﺨﺗ ﯼﺍﺮﺑ ﯼﻭﺎﺴﻣ ﺖﻣﻼﻋ ﮏﯾ
ﺖﺳﺍ x ،ﺲﭙﺳ .ﺖﺳﺍ ﻩﺪﺷ ﻒﯾﺮﻌﺗ ﺮﯿﻐﺘﻣ ﮏﯾ ﻥﺍﻮﻨﻋ ﻪﺑ x ،ﻝﺎﺜﻣ ﻦﯾﺍ ﺭﺩ
let x;
x = 6;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Variables</h2>
<p>In this example, x is defined as a variable.
Then, x is assigned the value of 6:</p>
<p id="demo"></p>
<script>
let x;
x = 6;
document.getElementById("demo").innerHTML = x;
</script>
</body>
</html>
ﻪﺑ ( → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ .ﺪﻨﮐ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﺺﯿﺼﺨﺗ ﯼﺍﺮﺑ ( → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ .ﺖﺳﺍ ﺎﻫﺮﮕﻠﻤﻋ ﻭ ﺎﻫﺮﯿﻐﺘﻣ ،ﺮﯾﺩﺎﻘﻣ ﺯﺍ ﯽﺒﯿﮐﺮﺗ ﺕﺭﺎﺒﻋ ﮏﯾ .ﺩﻮﺷ ﯽﻣ ﻩﺪﯿﻣﺎﻧ ﯽﺑﺎﯾﺯﺭﺍ ﺕﺎﺒﺳﺎﺤﻣ :ﺩﻮﺷ ﯽﻣ ﯽﺑﺎﯾﺯﺭﺍ 50 ﻪﺑ 10 * 5 ،ﻝﺎﺜﻣ ﻥﺍﻮﻨﻋ ﻪﺑ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺪﻨﺷﺎﺑ ﺮﯿﻐﺘﻣ ﺮﯾﺩﺎﻘﻣ ﯼﻭﺎﺣ ﺪﻨﻧﺍﻮﺗ ﯽﻣ ﻦﯿﻨﭽﻤﻫ ﺕﺍﺭﺎﺒﻋ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ .ﺎﻫ ﻪﺘﺷﺭ ﻭ ﺩﺍﺪﻋﺍ ﺪﻨﻧﺎﻣ ،ﺪﻨﺷﺎﺑ ﻪﺘﺷﺍﺩ ﯽﻔﻠﺘﺨﻣ ﻉﺍﻮﻧﺍ ﺪﻨﻧﺍﻮﺗ ﯽﻣ ﺮﯾﺩﺎﻘﻣ :ﺩﻮﺷ ﯽﻣ ﯽﺑﺎﯾﺯﺭﺍ "ﻭﺩ ﻥﺎﺟ" ﻪﺑ ،"ﻭﺩ" + "" + "ﻥﺎﺟ" ،ﻝﺎﺜﻣ ﻥﺍﻮﻨﻋ ﻪﺑ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ ﺩﻮﺷ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﻩﮊﺍﻭ ﺪﯿﻠﮐ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻦﯾﺍ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ ﻦﯾﺍ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ ﺖﺧﻮﻣﺁ ﺪﯿﻫﺍﻮﺧ ﺮﺘﺸﯿﺑ .ﺪﻧﻮﺷ ﯽﻤﻧ "ﺍﺮﺟﺍ" ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺕﺍﺭﻮﺘﺳﺩ ﻪﻤﻫ ﻞﺑﻭﺩ ﯼﺎﻫ ﺶﻠﺳﺍ ﺯﺍ ﺪﻌﺑ ﺪﮐ ﺩﻮﺑ ﺪﻨﻫﺍﻮﺨﻧ ﻭ ﺪﻧﻮﺷ ﯽﻣ ﻪﺘﻓﺮﮔ ﻩﺪﯾﺩﺎﻧ ﺕﺍﺮﻈﻧ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ .ﺖﺧﻮﻣﺁ ﺪﯿﻫﺍﻮﺧ ﺮﺘﺸﯿﺑ ﺕﺍﺮﻈﻧ ﻩﺭﺎﺑﺭﺩ ﺪﻌﺑ ﻞﺼﻓ ﺭﺩ .ﺪﻨﺘﺴﻫ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻡﺎﻧ ﺎﻫ ﻪﺳﺎﻨﺷ .ﺪﻧﻮﺷ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﻊﺑﺍﻮﺗ ﻭ ﯼﺪﯿﻠﮐ ﺕﺎﻤﻠﮐ ﻭ ﺎﻫﺮﯿﻐﺘﻣ ﯼﺭﺍﺬﮕﻣﺎﻧ ﯼﺍﺮﺑ ﺎﻫ ﻪﺳﺎﻨﺷ .ﺖﺳﺍ ﻥﺎﺴﮑﯾ ﯽﺴﯾﻮﻧ ﻪﻣﺎﻧﺮﺑ ﯼﺎﻫ ﻥﺎﺑﺯ ﺮﺜﮐﺍ ﺭﺩ ﯽﻧﻮﻧﺎﻗ ﯼﺎﻫ ﻡﺎﻧ ﻦﯿﻧﺍﻮﻗ :ﺎﺑ ﺪﯾﺎﺑ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻡﺎﻧ (a-z ﺎﯾ A-Z) ﻑﺮﺣ ﮏﯾ ($) ﺭﻻﺩ ﺖﻣﻼﻋ (_) ﺮﯾﺯ ﻂﺧ ﺎﯾ .ﺪﻨﺷﺎﺑ ﺭﻻﺩ ﺖﻣﻼﻋ ﺎﯾ ﻂﺧﺮﯾﺯ ،ﺩﺍﺪﻋﺍ ،ﻑﻭﺮﺣ ﺖﺳﺍ ﻦﮑﻤﻣ ﯼﺪﻌﺑ ﯼﺎﻫﺮﺘﮐﺍﺭﺎﮐ .ﺪﻨﺘﺴﯿﻧ ﺯﺎﺠﻣ ﺎﻫ ﻡﺎﻧ ﺭﺩ ﺮﺘﮐﺍﺭﺎﮐ ﻦﯿﻟﻭﺍ ﻥﺍﻮﻨﻋ ﻪﺑ ﺩﺍﺪﻋﺍ .ﺪﻫﺩ ﺺﯿﺨﺸﺗ ﺩﺍﺪﻋﺍ ﺯﺍ ﺍﺭ ﺎﻫ ﻪﺳﺎﻨﺷ ﯽﺘﺣﺍﺭ ﻪﺑ ﺪﻧﺍﻮﺗ ﯽﻣ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺐﯿﺗﺮﺗ ﻦﯾﺍ ﻪﺑ ﺪﻨﺘﺴﻫ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫ ﻪﺳﺎﻨﺷ ﻪﻤﻫ ، → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ .ﺪﻨﮐ ﯽﻤﻧ ﺮﯿﺴﻔﺗ let ﯼﺪﯿﻠﮐ ﻪﻤﻠﮐ ﻥﺍﻮﻨﻋ ﻪﺑ ﺍﺭ Let ﺎﯾ LET ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ :ﺪﻧﺍ ﻩﺩﺮﮐ ﻩﺩﺎﻔﺘﺳﺍ ﺮﯿﻐﺘﻣ ﻡﺎﻧ ﮏﯾ ﻪﺑ ﻪﻤﻠﮐ ﺪﻨﭼ ﻕﺎﺤﻟﺍ ﯼﺍﺮﺑ ﯽﻔﻠﺘﺨﻣ ﯼﺎﻫ ﺵﻭﺭ ﺯﺍ ﻥﺎﺴﯾﻮﻧ ﻪﻣﺎﻧﺮﺑ ،ﯽﺨﯾﺭﺎﺗ ﻅﺎﺤﻟ ﺯﺍ ﻦﻔﯿﻫ: .ﯼﺮﻬﺷ ﻦﯿﺑ ،ﺕﺭﺎﮐ ﺮﺘﺴﻣ ،ﯽﮔﺩﺍﻮﻧﺎﺧ ﻡﺎﻧ ،ﻡﺎﻧ .ﺪﻧﺍ ﻩﺪﺷ ﻭﺭﺯﺭ ﻖﯾﺮﻔﺗ ﯼﺍﺮﺑ ﺎﻬﻧﺁ .ﺖﺴﯿﻧ ﺯﺎﺠﻣ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺭﺩ ﻪﻠﺻﺎﻓ ﻂﺧ ﻂﺧ ﺮﯾﺯ: first_name، ﯽﮔﺩﺍﻮﻧﺎﺧ ﻡﺎﻧ، master_card، inter_city. (ﻝﺎﮑﺳﺎﭘ ﺏﺎﻗ) ﯽﯾﻻﺎﺑ ﺮﺘﺷ ﺏﺎﻗ: FirstName، LastName، MasterCard، InterCity. ﻦﯿﯾﺎﭘ ﺮﺘﺷ ﻪﺒﻌﺟ: :ﺩﻮﺷ ﯽﻣ ﻉﻭﺮﺷ ﮏﭼﻮﮐ ﻑﻭﺮﺣ ﺎﺑ ﻪﮐ ﺪﻨﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ camel case ﺯﺍ ﺪﻧﺭﺍﺩ ﻞﯾﺎﻤﺗ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻥﺎﺴﯾﻮﻧ ﻪﻣﺎﻧﺮﺑ firstName, lastName, mastercard, interCity. .ﺪﻨﮐ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﺪﮑﯿﻧﻮﯾ ﺮﺘﮐﺍﺭﺎﮐ ﻪﻋﻮﻤﺠﻣ ﺯﺍ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ .ﺪﻫﺩ ﯽﻣ ﺶﺷﻮﭘ ﺍﺭ ﻥﺎﻬﺟ ﯼﺎﻫﺩﺎﻤﻧ ﻭ ﯼﺭﺍﺬﮔ ﻪﻄﻘﻧ ﻢﺋﻼﻋ ،ﺎﻫﺮﺘﮐﺍﺭﺎﮐ ﻡﺎﻤﺗ (ﺎﺒﯾﺮﻘﺗ) ﺪﮑﯿﻧﻮﯾ .ﺪﯿﻨﮐ ﻪﻌﻟﺎﻄﻣ ﺍﺭ ﺎﻣ ﺪﮑﯿﻧﻮﯾ ﻞﻣﺎﮐ ﻊﺟﺮﻣ ﺎﻔﻄﻟ ،ﺮﺗ ﻖﯿﻗﺩ ﻩﺎﮕﻧ ﯼﺍﺮﺑ
*<" ﺪﻨﮐ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ "code class="w3-codespan">+ /
(5 + 6) * 10
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Operators</h2>
<p>JavaScript uses arithmetic operators to compute values (just like algebra).</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = (5 + 6) * 10;
</script>
</body>
</html>
=
)/>ﺹﺎﺼﺘﺧﺍ ﺮﮕﻠﻤﻋ ﮏﯾ ﺯlet x, y;
x = 5;
y = 6;
<!DOCTYPE html>
<html>
<body>
<h2>Assigning JavaScript Values</h2>
<p>In JavaScript the = operator is used to assign values to variables.</p>
<p id="demo"></p>
<script>
let x, y;
x = 5;
y = 6;
document.getElementById("demo").innerHTML = x + y;
</script>
</body>
</html>
ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺕﺍﺭﺎﺒﻋ
5 * 10
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Expressions</h2>
<p>Expressions compute to values.</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = 5 * 10;
</script>
</body>
</html>
x * 10
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Expressions</h2>
<p>Expressions compute to values.</p>
<p id="demo"></p>
<script>
var x;
x = 5;
document.getElementById("demo").innerHTML = x * 10;
</script>
</body>
</html>
"John" + " " + "Doe"
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Expressions</h2>
<p>Expressions compute to values.</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = "John" + " " + "Doe";
</script>
</body>
</html>
ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺪﯿﻠﮐ ﺕﺎﻤﻠﮐ
let x, y;
x = 5 + 6;
y = x * 10;
<!DOCTYPE html>
<html>
<body>
<h2>The <b>let</b> Keyword Creates Variables</h2>
<p id="demo"></p>
<script>
let x, y;
x = 5 + 6;
y = x * 10;
document.getElementById("demo").innerHTML = y;
</script>
</body>
</html>
var x, y;
x = 5 + 6;
y = x * 10;
<!DOCTYPE html>
<html>
<body>
<h2>The var Keyword Creates Variables</h2>
<p id="demo"></p>
<script>
var x, y;
x = 5 + 6;
y = x * 10;
document.getElementById("demo").innerHTML = y;
</script>
</body>
</html>
var
ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ ﺎﺑ ﺎﻫ ﻝﺎﺜﻣ ﻦﯾﺍ ﺭﺩvar
ﻩﺭﺎﺑﺭﺩ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺕﺍﺮﻈﻧ
let x = 5; // I will be executed
// x = 6; I will
NOT be executed
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Comments are NOT Executed</h2>
<p id="demo"></p>
<script>
let x;
x = 5;
// x = 6; I will not be executed
document.getElementById("demo").innerHTML = x;
</script>
</body>
</html>
ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫ ﻡﺎﻧ/ﺎﻫ ﻪﺳﺎﻨﺷ
ﺪﯿﺷﺎﺑ ﻪﺘﺷﺍﺩ ﻪﺟﻮﺗ
ﺖﺳﺍ ﺱﺎﺴﺣ ﮏﭼﻮﮐ ﻭ ﮒﺭﺰﺑ ﻑﻭﺮﺣ ﻪﺑ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ
ﯽﮔﺩﺍﻮﻧﺎﺧ ﻡﺎﻧ<"code class="w3-codespan> ﻭ
lastName
ﯼﺎﻫﺮﯿﻐﺘﻣlet lastname, lastName;
lastName = "Doe";
lastname = "Peterson";
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript is Case Sensitive</h2>
<p>Try to change lastName to lastname.</p>
<p id="demo"></p>
<script>
let lastname, lastName;
lastName = "Doe";
lastname = "Peterson";
document.getElementById("demo").innerHTML = lastName;
</script>
</body>
</html>
ﺮﺘﺷ ﺩﺭﻮﻣ ﻭ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ
ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫﺮﺘﮐﺍﺭﺎﮐ ﻪﻋﻮﻤﺠﻣ