ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫﺮﯿﻐﺘﻣ


فهرست مطالب

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

ﺪﻨﺘﺴﻫ ﺎﻫ ﻩﺩﺍﺩ ﻩﺮﯿﺧﺫ ﯼﺍﺮﺑ ﯽﯾﺎﻫ ﻪﻈﻔﺤﻣ ﺎﻫﺮﯿﻐﺘﻣ

:ﺩﺮﮐ ﻡﻼﻋﺍ ﺵﻭﺭ 4 ﻪﺑ ﻥﺍﻮﺗ ﯽﻣ ﺍﺭ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫﺮﯿﻐﺘﻣ

  • ﺭﺎﮐﺩﻮﺧ ﺭﻮﻄﺑ

  • var ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ ﺎﺑ

  • let ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ ﺎﺑ

  • const ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ ﺎﺑ

،x ،ﻝﻭﺍ ﻝﺎﺜﻣ ﻦﯾﺍ ﺭﺩ

:ﺪﻧﻮﺷ ﯽﻣ ﻡﻼﻋﺍ ﺭﺎﺑ ﻦﯿﻟﻭﺍ ﯼﺍﺮﺑ ﻩﺩﺎﻔﺘﺳﺍ ﻡﺎﮕﻨﻫ ﺭﺎﮐﺩﻮﺧ ﺭﻮﻃ ﻪﺑ ﺎﻬﻧﺁ

ﻝﺎﺜﻣ

x = 5;
y = 6;
z = x + y;

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Variables</h1>

<p>In this example, x, y, and z are undeclared.</p>
<p>They are automatically declared when first used.</p>

<p id="demo"></p>

<script>
x = 5;
y = 6;
z = x + y;
document.getElementById("demo").innerHTML =
"The value of z is: " + z;
</script>

</body>
</html>


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

.ﺪﯿﻨﮐ ﻡﻼﻋﺍ ﻩﺩﺎﻔﺘﺳﺍ ﺯﺍ ﻞﺒﻗ ﺍﺭ ﺎﻫﺮﯿﻐﺘﻣ ﻪﺸﯿﻤﻫ ﻪﮐ ﺩﻮﺷ ﯽﻣ ﻪﺘﻓﺮﮔ ﺮﻈﻧ ﺭﺩ ﯽﺴﯾﻮﻧ ﻪﻣﺎﻧﺮﺑ ﺏﻮﺧ ﻦﯾﺮﻤﺗ ﮏﯾ ﻦﯾﺍ

:ﺪﯿﻧﺰﺑ ﺱﺪﺣ ﺪﯿﻧﺍﻮﺗ ﯽﻣ ﺎﻫ ﻪﻧﻮﻤﻧ ﺯﺍ

  • x ﺪﻨﮐ ﯽﻣ ﻩﺮﯿﺧﺫ ﺍﺭ 5 ﺭﺍﺪﻘﻣ

  • y ﺪﻨﮐ ﯽﻣ ﻩﺮﯿﺧﺫ ﺍﺭ 6 ﺭﺍﺪﻘﻣ

  • z ﺪﻨﮐ ﯽﻣ ﻩﺮﯿﺧﺫ ﺍﺭ 11 ﺭﺍﺪﻘﻣ

var ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ ﺎﺑ ﻝﺎﺜﻣ

var x = 5;
var y = 6;
var z = x + y;

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Variables</h1>

<p>In this example, x, y, and z are variables.</p>

<p id="demo"></p>

<script>
var x = 5;
var y = 6;
var z = x + y;
document.getElementById("demo").innerHTML =
"The value of z is: " + z;
</script>

</body>
</html>


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

.ﺖﺳﺍ ﻩﺪﺷ ﻩﺩﺎﻔﺘﺳﺍ 2015 ﺎﺗ 1995 ﻝﺎﺳ ﺯﺍ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫﺪﮐ ﯽﻣﺎﻤﺗ ﺭﺩ var ﯼﺪﯿﻠﮐ ﻪﻤﻠﮐ

.ﺪﻧﺪﺷ ﻪﻓﺎﺿﺍ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﺑ 2015 ﻝﺎﺳ ﺭﺩ constlet

.ﺩﻮﺷ ﻩﺩﺎﻔﺘﺳﺍ ﯽﻤﯾﺪﻗ ﯼﺎﻫﺮﮔﺭﻭﺮﻣ ﯼﺍﺮﺑ ﻩﺪﺷ ﻪﺘﺷﻮﻧ ﺪﮐ ﺭﺩ ﺪﯾﺎﺑ ﻂﻘﻓ var ﯼﺪﯿﻠﮐ ﻪﻤﻠﮐ

let ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ ﺎﺑ ﻝﺎﺜﻣ

let x = 5;
let y = 6;
let z = x + y;

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Variables</h1>

<p>In this example, x, y, and z are variables.</p>

<p id="demo"></p>

<script>
let x = 5;
let y = 6;
let z = x + y;
document.getElementById("demo").innerHTML =
"The value of z is: " + z;
</script>

</body>
</html>


const ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ ﺎﺑ ﻝﺎﺜﻣ

const x = 5;
const y = 6;
const z = x + y;

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Variables</h1>

<p>In this example, x, y, and z are variables.</p>

<p id="demo"></p>

<script>
const x = 5;
const y = 6;
const z = x + y;
document.getElementById("demo").innerHTML =
"The value of z is: " + z;
</script>

</body>
</html>


ﻂﻠﺘﺨﻣ ﻝﺎﺜﻣ

const price1 = 5;
const price2 = 6;
let total = price1 + price2;

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Variables</h1>

<p>In this example, price1, price2, and total are variables.</p>

<p id="demo"></p>

<script>
const price1 = 5;
const price2 = 6;
let total = price1 + price2;
document.getElementById("demo").innerHTML =
"The total is: " + total;
</script>

</body>
</html>


price2price1 ﺮﯿﻐﺘﻣ ﻭﺩ

.ﺪﻨﺘﺴﯿﻧ ﺮﯿﯿﻐﺗ ﻞﺑﺎﻗ ﻭ ﺪﻨﺘﺴﻫ ﺖﺑﺎﺛ ﺮﯾﺩﺎﻘﻣ ﻦﯾﺍ

.ﺩﻮﺷ ﯽﻣ ﻡﻼﻋﺍ let ﯼﺪﯿﻠﮐ ﻪﻤﻠﮐ ﺎﺑ total ﺮﯿﻐﺘﻣ

.ﺖﺳﺍ ﺮﯿﯿﻐﺗ ﻞﺑﺎﻗ total ﺭﺍﺪﻘﻣ

؟ﻢﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ const ﺎﯾ var، let ﺯﺍ ﯽﻧﺎﻣﺯ ﻪﭼ

ﺪﯿﻨﮐ ﻡﻼﻋﺍ ﺍﺭ ﺎﻫﺮﯿﻐﺘﻣ ﻪﺸﯿﻤﻫ .1

ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ const ﺯﺍ ﻪﺸﯿﻤﻫ ،ﺪﻨﮐ ﺮﯿﯿﻐﺗ ﺪﯾﺎﺒﻧ ﺭﺍﺪﻘﻣ ﺮﮔﺍ .2

.ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ const ﺯﺍ ﻪﺸﯿﻤﻫ (ﺎﯿﺷﺍ ﻭ ﺎﻫ ﻪﯾﺍﺭﺁ) ﺪﻨﮐ ﺮﯿﯿﻐﺗ ﺪﯾﺎﺒﻧ ﻉﻮﻧ ﺮﮔﺍ .3

.ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ let ﺯﺍ ﻂﻘﻓ ،ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ const ﺯﺍ ﺪﯿﻧ

.ﺪﯿﻨﮐ ﯽﻧﺎﺒﯿﺘﺸﭘ ﯽﻤﯾﺪﻗ ﯼﺎﻫﺮﮔﺭﻭﺮﻣ ﺯﺍ ﺪﯾﺎﺑ ﻪﮐ ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ var ﺯﺍ ﯽﺗﺭﻮﺻ ﺭﺩ ﻂﻘﻓ .5


ﺮﺒﺟ ﻞﺜﻣ ﺖﺳﺭﺩ

:ﺪﻧﺭﺍﺩ ﯽﻣ ﻪﮕﻧ ﺍﺭ ﺮﯾﺯ ﺮﯾﺩﺎﻘﻣ ﺎﻫﺮﯿﻐﺘﻣ ،ﺮﺒﺟ ﺪﻨﻧﺎﻣ ﺖﺳﺭﺩ

let x = 5;
let y = 6;

:ﺩﻮﺷ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﺕﺍﺭﺎﺒﻋ ﺭﺩ ﺎﻫﺮﯿﻐﺘﻣ ﺯﺍ ،ﺮﺒﺟ ﺪﻨﻧﺎﻣ ﺖﺳﺭﺩ

let z = x + y;

.ﺖﺳﺍ ﻩﺪﺷ ﻪﺒﺳﺎﺤﻣ 11 ﻞﮐ ﻪﮐ ﺪﯿﻧﺰﺑ ﺱﺪﺣ ﺪﯿﻧﺍﻮﺗ ﯽﻣ ﻻﺎﺑ ﻝﺎﺜﻣ ﺯﺍ

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

.ﺪﻨﺘﺴﻫ ﺮﯾﺩﺎﻘﻣ ﻩﺮﯿﺧﺫ ﯼﺍﺮﺑ ﯽﯾﺎﻫ ﻪﻈﻔﺤﻣ ﺎﻫﺮﯿﻐﺘﻣ



ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫ ﻪﺳﺎﻨﺷ

ﺪﻨﺷﺎﺑ ﺪﯾﺎﺑ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫﺮﯿﻐﺘﻣ ﻪﻤﻫ

.ﺪﻧﻮﺷﯽﻣ ﻩﺪﯿﻣﺎﻧ ﻪﺳﺎﻨﺷ ﺩﺮﻓﻪﺑﺮﺼﺤﻨﻣ ﯼﺎﻫﻡﺎﻧ ﻦﯾﺍ

.ﺪﻨﺷﺎﺑ (ﻞﮐ ﻢﺠﺣ ،ﻉﻮﻤﺠﻣ ،ﻦﺳ) ﺮﺗ ﯽﻔﯿﺻﻮﺗ ﯼﺎﻫ ﻡﺎﻧ ﺎﯾ (y ﻭ x ﺪﻨﻧﺎﻣ) ﻩﺎﺗﻮﮐ ﯼﺎﻫ ﻡﺎﻧ ﺪﻨﻧﺍﻮﺗ ﯽﻣ ﺎﻫ ﻪﺳﺎﻨﺷ

:ﺯﺍ ﺪﻨﺗﺭﺎﺒﻋ (ﺩﺮﻓ ﻪﺑ ﺮﺼﺤﻨﻣ ﯼﺎﻫ ﻪﺳﺎﻨﺷ) ﺎﻫﺮﯿﻐﺘﻣ ﯼﺍﺮﺑ ﻡﺎﻧ ﺖﺧﺎﺳ ﯼﺍﺮﺑ ﯽﻠﮐ ﻦﯿﻧﺍﻮﻗ

  • .ﺪﻨﺷﺎﺑ ﺭﻻﺩ ﺖﻣﻼﻋ ﻭ ﻂﺧﺮﯾﺯ ،ﺩﺍﺪﻋﺍ ،ﻑﻭﺮﺣ ﻞﻣﺎﺷ ﺪﻨﻧﺍﻮﺗ ﯽﻣ ﺎﻫ ﻡﺎﻧ

  • .ﺪﻧﻮﺷ ﻉﻭﺮﺷ ﻑﺮﺣ ﺎﺑ ﺪﯾﺎﺑ ﺎﻫ ﻡﺎﻧ

  • .(ﻢﯿﻨﮐ ﯽﻤﻧ ﻩﺩﺎﻔﺘﺳﺍ ﻥﺁ ﺯﺍ ﺵﺯﻮﻣﺁ ﻦﯾﺍ ﺭﺩ ﺎﻣﺍ) ﺪﻧﻮﺷ ﻉﻭﺮﺷ _ ﻭ $ﺎﺑ ﺪﻨﻧﺍﻮﺗ ﯽﻣ ﻦﯿﻨﭽﻤﻫ ﺎﻫ ﻡﺎﻧ

  • .(ﺪﻨﺘﺴﻫ ﯽﻔﻠﺘﺨﻣ ﯼﺎﻫﺮﯿﻐﺘﻣ Y ﻭ y) ﺪﻨﺘﺴﻫ ﺱﺎﺴﺣ ﮏﭼﻮﮐ ﻭ ﮒﺭﺰﺑ ﻑﻭﺮﺣ ﻪﺑ ﺎﻫ ﻡﺎﻧ

  • .ﺩﺮﮐ ﻩﺩﺎﻔﺘﺳﺍ ﻡﺎﻧ ﻥﺍﻮﻨﻋ ﻪﺑ ﻥﺍﻮﺗ ﯽﻤﻧ ﺍﺭ (ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺪﯿﻠﮐ ﺕﺎﻤﻠﮐ ﺪﻨﻧﺎﻣ) ﻩﺪﺷ ﻭﺭﺯﺭ ﺕﺎﻤﻠﮐ

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

.ﺪﻨﺘﺴﻫ ﺱﺎﺴﺣ ﮏﭼﻮﮐ ﻭ ﮒﺭﺰﺑ ﻑﻭﺮﺣ ﻪﺑ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫ ﻪﺳﺎﻨﺷ


ﯼﺭﺍﺬﮔﺍﻭ ﺭﻮﺗﺍﺮﭘﺍ

ﺮﮕﻠﻤﻋ ﮏﯾ ﻪﻧ ،ﺖﺳﺍ "ﺏﺎﺴﺘﻧﺍ" ﺮﮕﻠﻤﻋ ﮏﯾ (=) ﺮﺑﺍﺮﺑ ﺖﻣﻼﻋ ،ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺭﺩ

ﺩﺭﺍﺪﻧ ﯽﻨﻌﻣ ﺮﯾﺯ ﺩﺭﺍﻮﻣ .ﺖﺳﺍ ﺕﻭﺎﻔﺘﻣ ﺮﺒﺟ ﺎﺑ ﻦﯾﺍ

x = x + 5 

ﺪﻫﺩ ﯽﻣ ﺹﺎﺼﺘﺧﺍ ﻥﺁ ﻪﺑ ﺍﺭ x + 5 ﺭﺍﺪﻘﻣ :ﺖﺳﺍ ﯽﻘﻄﻨﻣ ﻼًﻣﺎﮐ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺭﺩ ،ﻝﺎﺣ ﻦﯾﺍ ﺎﺑ

x ﺭﺍﺪﻘﻣ .ﺪﻫﺩ ﯽﻣ ﺭﺍﺮﻗ x ﺭﺩ ﺍﺭ ﻪﺠﯿﺘﻧ ﻭ ﺪﻨﮐ ﯽﻣ ﻪﺒﺳﺎﺤﻣ ﺍﺭ x + 5 ﺭﺍﺪﻘﻣ)

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

.ﺩﻮﺷ ﯽﻣ ﻪﺘﺷﻮﻧ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺭﺩ == ﺪﻨﻧﺎﻣ "ﺎﺑ ﺮﺑﺍﺮﺑ" ﺮﮕﻠﻤﻋ


ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻩﺩﺍﺩ ﻉﺍﻮﻧﺍ

ﻥﺎﺟ" ﺪﻨﻧﺎﻣ ﯽﻨﺘﻣ ﺮﯾﺩﺎﻘﻣ ﻭ 100 ﺪﻨﻧﺎﻣ ﯼﺩﺍﺪﻋﺍ ﺪﻨﻧﺍﻮﺗ ﯽﻣ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫﺮﯿﻐﺘﻣ

.ﺪﻨﯾﻮﮔ ﯽﻣ ﯽﻨﺘﻣ ﯼﺎﻫ ﻪﺘﺷﺭ ﻦﺘﻣ ﺮﯾﺩﺎﻘﻣ ﻪﺑ ﯽﺴﯾﻮﻧ ﻪﻣﺎﻧﺮﺑ ﺭﺩ

.ﺪﯿﻨﮐ ﺮﮑﻓ ﺎﻫ ﻪﺘﺷﺭ ﻭ ﺩﺍﺪﻋﺍ ﻪﺑ ﻂﻘﻓ ،ﺮﺿﺎﺣ ﻝﺎﺣ ﺭﺩ ﺎﻣﺍ ،ﺪﻨﮐ ﺖﯾﺮﯾﺪﻣ ﺍﺭ ﺎﻫ ﻩﺩﺍﺩ ﺯﺍ ﯽﻔﻠﺘﺨﻣ ﻉﺍﻮﻧﺍ ﺪﻧﺍﻮﺗ ﯽﻣ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ

ﺖﺳﺍ ﻩﺪﺷ ﻪﺘﺷﻮﻧ ﺩﺍﺪﻋﺍ .ﺪﻧﻮﺷ ﯽﻣ ﻪﺘﺷﻮﻧ ﯽﮑﺗ ﺎﯾ ﯽﯾﺎﺗﻭﺩ ﯼﺎﻫ ﻪﻣﻮﯿﮔ ﻞﺧﺍﺩ ﺎﻫ ﻪﺘﺷﺭ

.ﺩﻮﺷ ﯽﻣ ﻪﺘﻓﺮﮔ ﺮﻈﻧ ﺭﺩ ﻦﺘﻣ ﻪﺘﺷﺭ ﮏﯾ ﻥﺍﻮﻨﻋ ﻪﺑ ،ﺪﯿﻫﺩ ﺭﺍﺮﻗ ﻪﻣﻮﯿﮔ ﺭﺩ ﺍﺭ ﯼﺩﺪﻋ ﺮﮔﺍ

ﻝﺎﺜﻣ

const pi = 3.14;
let person = "John Doe";
let answer = 'Yes I am!';

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Variables</h1>

<p>Strings are written with quotes.</p>
<p>Numbers are written without quotes.</p>

<p id="demo"></p>

<script>
const pi = 3.14;
let person = "John Doe";
let answer = 'Yes I am!';

document.getElementById("demo").innerHTML =
pi + "<br>" + person + "<br>" + answer;
</script>

</body>
</html>



ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺮﯿﻐﺘﻣ ﮏﯾ ﻥﻼﻋﺍ

.ﺩﻮﺷ ﯽﻣ ﻩﺪﯿﻣﺎﻧ ﺮﯿﻐﺘﻣ ﮏﯾ "ﻥﻼﻋﺍ" ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺭﺩ ﺮﯿﻐﺘﻣ ﮏﯾ ﺩﺎﺠﯾﺍ

:ﺪﯿﻨﮐﯽﻣ ﻡﻼﻋﺍ let ﯼﺪﯿﻠﮐ ﻪﻤﻠﮐ ﺎﯾ var ﺎﺑ ﺍﺭ ﺖﭙﯾﺮﮑ

var carName;
let carName;

.(ﺖﺳﺍ ﻩﺪﺸﻧ ﻒﯾﺮﻌﺗ<"code class="w3-codespan> ﯽﻨﻓ ﺮﻈﻧ ﺯﺍ) ﺩﺭﺍﺪﻧ ﯼﺭﺍﺪﻘﻣ ﭻﯿﻫ ﺮﯿﻐﺘﻣ ،ﻥﻼﻋﺍ ﺯﺍ ﺪﻌﺑ

:ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﯼﻭﺎﺴﻣ ﺖﻣﻼﻋ ﺯﺍ ،ﺮﯿﻐﺘﻣ ﻪﺑ ﯼﺭﺍﺪﻘﻣ ﺺﯿﺼﺨﺗ ﯼﺍﺮﺑ

carName = "Volvo";

:ﺪﯿﻫﺩ ﺹﺎﺼﺘﺧﺍ ﻥﺁ ﻪﺑ ﺍﺭ ﯼﺭﺍﺪﻘﻣ ،ﺪﯿﻨﮐﯽﻣ ﻡﻼﻋﺍ ﺍﺭ ﺮﯿﻐﺘﻣ ﯽﺘﻗﻭ ﺪﯿﻧﺍﻮﺗﯽﻣ ﻦﯿﻨﭽﻤﻫ

let carName = "Volvo";

.ﻢﯿﻫﺩ ﯽﻣ ﺹﺎﺼﺘﺧﺍ ﻥﺁ ﻪﺑ ﺍﺭ ﺭﺍﺪﻘﻣ ﻭ ﻩﺩﺮﮐ ﺩﺎﺠﯾﺍ carName ﻡﺎﻧ ﻪﺑ ﯼﺮﯿﻐﺘﻣ ،ﺮﯾﺯ ﻝﺎﺜﻣ ﺭﺩ

:ﻢﯿﻨﮐ ﯽﻣ "ﯽﺟﻭﺮﺧ" "id="demo ﺎﺑ ﺍﺭ HTML ﻑﺍﺮﮔﺍﺭﺎﭘ ﮏﯾ ﻞﺧﺍﺩ ﺭﺍﺪﻘﻣ ﺲﭙﺳ

ﻝﺎﺜﻣ

<p id="demo"></p>
<script>
let carName = "Volvo";
document.getElementById("demo").innerHTML = carName; 
</script>

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Variables</h1>

<p>Create a variable, assign a value to it, and display it:</p>

<p id="demo"></p>

<script>
let carName = "Volvo";
document.getElementById("demo").innerHTML = carName;
</script>

</body>
</html>

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

.ﺪﯿﻨﮐ ﻡﻼﻋﺍ ﺖﭙﯾﺮﮑﺳﺍ ﮏﯾ ﯼﺍﺪﺘﺑﺍ ﺭﺩ ﺍﺭ ﺎﻫﺮﯿﻐﺘﻣ ﻪﻤﻫ ﻪﮐ ﺖﺳﺍ ﺏﻮﺧ ﯽﺴﯾﻮﻧ ﻪﻣﺎﻧﺮﺑ ﻦﯾﺮﻤﺗ ﮏﯾ ﻦﯾﺍ


ﺩﺪﻌﺘﻣ ﯼﺎﻫﺮﯿﻐﺘﻣ ،ﻪﯿﻧﺎﯿﺑ ﮏﯾ

.ﺪﯿﻨﮐ ﻡﻼﻋﺍ ﺕﺭﺎﺒﻋ ﮏﯾ ﺭﺩ ﺍﺭ ﯼﺩﺎﯾﺯ ﯼﺎﻫﺮﯿﻐﺘﻣ ﺪﯿﻧﺍﻮﺗ ﯽﻣ ﺎﻤﺷ

ﺪﯿﻨﮐ ﻉﻭﺮﺷ ﺍﺭ ﻪﯿﻧﺎﯿﺑ

ﻝﺎﺜﻣ

let person = "John Doe", carName = "Volvo", price = 200;

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Variables</h1>

<p>You can declare many variables in one statement.</p>

<p id="demo"></p>

<script>
let person = "John Doe", carName = "Volvo", price = 200;
document.getElementById("demo").innerHTML = carName;
</script>

</body>
</html>


:ﺩﻮﺷ ﻞﻣﺎﺷ ﺍﺭ ﻂﺧ ﻦﯾﺪﻨﭼ ﺪﻧﺍﻮﺗ ﯽﻣ ﻥﻼﻋﺍ ﮏﯾ

ﻝﺎﺜﻣ

let person = "John Doe",
carName = "Volvo",
price = 200;

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Variables</h1>

<p>You can declare many variables in one statement.</p>

<p id="demo"></p>

<script>
let person = "John Doe",
carName = "Volvo",
price = 200;
document.getElementById("demo").innerHTML = carName;
</script>

</body>
</html>



ﻩﺪﺸﻧ ﻒﯾﺮﻌﺗ=ﺵﺯﺭﺍ

ﺵﺯﺭﺍ .ﺪﻧﻮﺷ ﯽﻣ ﻥﻼﻋﺍ ﺭﺍﺪﻘﻣ ﻥﻭﺪﺑ ﺐﻠﻏﺍ ﺎﻫﺮﯿﻐﺘﻣ ،ﯼﺮﺗﻮﯿﭙﻣﺎﮐ ﯼﺎﻫ ﻪﻣﺎﻧﺮﺑ ﺭﺩ

ﺩﻮﺑ ﺪﻫﺍﻮﺧ <"code class="w3-codespan> ﺭﺍﺪﻘﻣ ﯼﺍﺭﺍﺩ ﺭﺍﺪﻘﻣ ﻥﻭﺪﺑ ﻩﺪﺷ ﻡﻼﻋﺍ ﺮﯿﻐﺘﻣ

:ﺩﻮﺑ ﺪﻫﺍﻮﺧ undefined ﺭﺍﺪﻘﻣ ﯼﺍﺭﺍﺩ ﺭﻮﺘﺳﺩ ﻦﯾﺍ ﯼﺍﺮﺟﺍ ﺯﺍ ﺲﭘ carName ﺮﯿﻐﺘﻣ

ﻝﺎﺜﻣ

let carName;

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Variables</h1>

<p>A variable without a value has the value of:</p>
<p id="demo"></p>

<script>
let carName;
document.getElementById("demo").innerHTML = carName;
</script>

</body>
</html>



ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫﺮﯿﻐﺘﻣ ﺩﺪﺠﻣ ﻥﻼﻋﺍ

.ﺩﺍﺩ ﺪﻫﺍﻮﺨﻧ ﺖﺳﺩ ﺯﺍ ﺍﺭ ﺩﻮﺧ ﺵﺯﺭﺍ ،ﺪﯿﻨﮐ ﻡﻼﻋﺍ ﺍًﺩﺪﺠﻣ ﺍﺭ var ﺎﺑ ﻩﺪﺷ ﻡﻼﻋﺍ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺮﯿﻐﺘ

:ﺖﺷﺍﺩ ﺪﻫﺍﻮﺧ ﺕﺍﺭﻮﺘﺳﺩ ﻦﯾﺍ ﯼﺍﺮﺟﺍ ﺯﺍ ﺲﭘ ﺍﺭ "Volvo" ﺭﺍﺪﻘﻣ ﻥﺎﻨﭽﻤﻫ carName ﺮﯿﻐﺘﻣ

ﻝﺎﺜﻣ

var carName = "Volvo";
var carName;

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Variables</h1>

<p>If you re-declare a JavaScript variable, it will not lose its value.</p>

<p id="demo"></p>

<script>
var carName = "Volvo";
var carName;
document.getElementById("demo").innerHTML = carName;
</script>

</body>
</html>


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

.ﺪﯿﻨﮐ ﻡﻼﻋﺍ ﺍًﺩﺪﺠﻣ ﺍﺭ const ﺎﯾ let ﺎﺑ ﻩﺪﺷ ﻡﻼﻋﺍ ﺮﯿﻐﺘﻣ

:ﺩﺮﮐ ﺪﻫﺍﻮﺨﻧ ﺭﺎﮐ ﻦﯾﺍ

let carName = "Volvo";
let carName;

ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺕﺎﺒﺳﺎﺤﻣ

ﺪﯿﻫﺩ ﻡﺎﺠﻧﺍ ﺍﺭ ﺏﺎﺴﺣ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫﺮﯿﻐﺘﻣ ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ ﺎﺑ ﺪﯿﻧﺍﻮﺗ ﯽﻣ ،ﺮﺒﺟ ﺪﻨﻧﺎﻤﻫ

ﻝﺎﺜﻣ

let x = 5 + 2 + 3;

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Variables</h1>

<p>The result of adding 5 + 2 + 3 is:</p>
<p id="demo"></p>

<script>
let x = 5 + 2 + 3;
document.getElementById("demo").innerHTML = x;
</script>

</body>
</html>

:ﺪﻧﻮﺷ ﯽﻣ ﻞﺼﺘﻣ ﻢﻫ ﻪﺑ ﺎﻫ ﻪﺘﺷﺭ ﺎﻣﺍ ،ﺪﯿﻨﮐ ﻪﻓﺎﺿﺍ ﺍﺭ ﺎﻫ ﻪﺘﺷﺭ ﺪﯿﻧﺍﻮﺗ ﯽﻣ ﻦﯿﻨﭽﻤﻫ ﺎﻤﺷ

ﻝﺎﺜﻣ

let x = "John" + " " + "Doe";

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Variables</h1>

<p>The result of adding "John" + " " + "Doe" is:</p>
<p id="demo"></p>

<script>
let x = "John" + " " + "Doe";
document.getElementById("demo").innerHTML = x;
</script>

</body>
</html>

:ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﻢﻫ ﺍﺭ ﻦﯾﺍ

ﻝﺎﺜﻣ

let x = "5" + 2 + 3;

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Variables</h1>

<p>The result of adding "5" + 2 + 3 is:</p>
<p id="demo"></p>

<script>
let x = "5" + 2 + 3;
document.getElementById("demo").innerHTML = x;
</script>

</body>
</html>

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

.ﺪﻧﻮﺷ ﯽﻣ ﻞﺼﺘﻣ ﻢﻫ ﻪﺑ ﻭ ﺪﻧﻮﺷ ﯽﻣ ﻪﺘﻓﺮﮔ ﺮﻈﻧ ﺭﺩ ﻪﺘﺷﺭ ﻥﺍﻮﻨﻋ ﻪﺑ ﺩﺍﺪﻋﺍ ﻪﯿﻘﺑ ،ﺪﯿﻫﺩ ﺭﺍﺮﻗ ﻪﻣﻮﯿﮔ ﺭﺩ ﺍﺭ ﯼﺩﺪﻋ ﺮﮔﺍ

:ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻦﯾﺍ ﻻﺎﺣ

ﻝﺎﺜﻣ

let x = 2 + 3 + "5";

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Variables</h1>

<p>The result of adding 2 + 3 + "5" is:</p>
<p id="demo"></p>

<script>
let x = 2 + 3 + "5";
document.getElementById("demo").innerHTML = x;
</script>

</body>
</html>

$ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺭﻻﺩ ﺖﻣﻼﻋ

:ﺪﻨﺘﺴﻫ ﺮﺒﺘﻌﻣ ﯼﺎﻫﺮﯿﻐﺘﻣ ﻡﺎﻧ $ﯼﻭﺎﺣ ﯼﺎﻫ ﻪﺳﺎﻨﺷ ،ﺩﺮﯿﮔ ﯽﻣ ﺮﻈﻧ ﺭﺩ ﻑﺮﺣ ﮏﯾ ﻥﺍﻮﻨﻋ ﻪﺑ ﺍﺭ ﺭﻻﺩ ﺖﻣﻼﻋ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﮐ ﯽﯾﺎﺠﻧﺁ ﺯﺍ

ﻝﺎﺜﻣ

let $ = "Hello World";
let $$$ = 2;
let $myMoney = 5;

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Variables</h1>

<p>The dollar sign is treated as a letter in JavaScript names.</p>

<p id="demo"></p>

<script>
let $$$ = 2;
let $myMoney = 5;
document.getElementById("demo").innerHTML = $$$ + $myMoney;
</script>

</body>
</html>

،ﺖﺴﯿﻧ ﺞﯾﺍﺭ ﯽﻠﯿﺧ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺭﺩ ﺭﻻﺩ ﺖﻣﻼﻋ ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ

ﺖﺳﺍ ﯽﻠﺻﺍ ﻊﺑﺎﺗ ،jQuery ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﻧﺎﺨﺑﺎﺘﮐ ﺭﺩ ،ﻝﺎﺜﻣ ﻥﺍﻮﻨﻋ ﻪﺑ


(_) ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻂﺧ ﺮﯾﺯ

:ﺪﻨﺘﺴﻫ ﺮﺒﺘﻌﻣ ﯼﺎﻫﺮﯿﻐﺘﻣ ﻡﺎﻧ _ ﯼﻭﺎﺣ ﯼﺎﻫ ﻪﺳﺎﻨﺷ ،ﺩﺮﯿﮔ ﯽﻣ ﺮﻈﻧ ﺭﺩ ﻑﺮﺣ ﮏﯾ ﻥﺍﻮﻨﻋ ﻪﺑ ﺍﺭ ﺮﯾﺯ ﻂﺧ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﮐ ﯽﯾﺎﺠﻧﺁ ﺯﺍ

ﻝﺎﺜﻣ

let _lastName = "Johnson";
let _x = 2;
let _100 = 5;

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Variables</h1>

<p>The underscore is treated as a letter in JavaScript names.</p>

<p id="demo"></p>

<script>
let _x = 2;
let _100 = 5;

document.getElementById("demo").innerHTML = _x + _100;
</script>

</body>
</html>

،ﺖﺴﯿﻧ ﺞﯾﺍﺭ ﯽﻠﯿﺧ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺭﺩ ﺮﯾﺯ ﻂﺧ ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ



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