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


فهرست مطالب

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

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


ﻪﺘﺷﺭ .1

ﯽﺷ ﻩﺩﺍﺩ ﻉﻮﻧ

:ﺪﺷﺎﺑ ﺮﯾﺯ ﺩﺭﺍﻮﻣ ﻞﻣﺎﺷ ﺪﻧﺍﻮﺗ ﯽﻣ ﯽﺷ ﻩﺩﺍﺩ ﻉﻮﻧ


ﯽﺷ ﮏﯾ .1

ﺎﻫ ﻝﺎﺜﻣ

// Numbers:
let length = 16;
let weight = 7.5;

// Strings:
let color = "Yellow";
let lastName = "Johnson";

// Booleans
let x = true;
let y = false;

// Object:
const person = {firstName:"John", lastName:"Doe"};

// Array object:
const cars = ["Saab", "Volvo", "BMW"];

// Date object:
const date = new Date("2022-03-25"); 

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

.ﺩﺭﺍﺩ ﻪﮕﻧ ﺩﻮﺧ ﺭﺩ ﺍﺭ ﯼﺍ ﻩﺩﺍﺩ ﻉﻮﻧ ﺮﻫ ﺪﻧﺍﻮﺗ ﯽﻣ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺮﯿﻐﺘﻣ ﮏﯾ

ﺎﻫ ﻩﺩﺍﺩ ﻉﺍﻮﻧﺍ ﻡﻮﻬﻔﻣ

.ﺖﺳﺍ ﻢﻬﻣ ﻡﻮﻬﻔﻣ ﮏﯾ ﻩﺩﺍﺩ ﻉﺍﻮﻧﺍ ،ﯽﺴﯾﻮﻧ ﻪﻣﺎﻧﺮﺑ ﺭﺩ

ﺪﯿﻧﺍﺪﺑ ﻥﺁ ﺩﺭﻮﻣ ﺭﺩ ﯼﺰﯿﭼ ﻪﮐ ﺖﺳﺍ ﻢﻬﻣ ،ﺪﯿﻨﮐ ﺭﺎﮐ ﺎﻫﺮﯿﻐﺘﻣ ﯼﻭﺭ ﺪﯿﻧﺍﻮﺘﺑ ﻪﮑﻨﯾﺍ ﯼﺍﺮﺑ

:ﺪﻨﮐ ﻞﺣ ﺍﺭ ﻞﮑﺸﻣ ﻦﯾﺍ ﺖﺣﺍﺭ ﻝﺎﯿﺧ ﺎﺑ ﺪﻧﺍﻮﺗ ﯽﻤﻧ ﺮﺗﻮﯿﭙﻣﺎﮐ ﮏﯾ ،ﻩﺩﺍﺩ ﻉﺍﻮﻧﺍ ﻥﻭﺪﺑ

let x = 16 + "Volvo";

ﺩﺮﮐ ﺪﻫﺍﻮﺧ ﺪﯿﻟﻮﺗ ﺎﯾﺁ ؟ﻢﯿﻨﮐ ﻪﻓﺎﺿﺍ ﻩﺩﺰﻧﺎﺷ ﻪﺑ ﺍﺭ "ﻭﻮﻟﻭ" ﻪﮐ ﺖﺳﺍ ﯽﻘﻄﻨﻣ ﺎﯾﺁ

:ﺪﻨﮐ ﯽﻣ ﺩﺭﻮﺧﺮﺑ ﺮﯾﺯ ﺕﺭﻮﺻ ﻪﺑ ﻻﺎﺑ ﻝﺎﺜﻣ ﺎﺑ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ

let x = "16" + "Volvo";

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

ﺩﺮﯿﮔ ﯽﻣ ﺮﻈﻧ ﺭﺩ ﮏﯾ ﻥﺍﻮﻨﻋ ﻪﺑ ﺍﺭ ﺩﺪﻋ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ،ﻪﺘﺷﺭ ﮏﯾ ﻭ ﺩﺪﻋ ﮏﯾ ﻥﺩﺮﮐ ﻪﻓﺎﺿﺍ ﻡﺎﮕﻨﻫ

ﻝﺎﺜﻣ

let x = 16 + "Volvo";

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

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript</h2>

<p>When adding a number and a string, JavaScript will treat the number as a string.</p>

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

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

</body>
</html>


ﻝﺎﺜﻣ

let x = "Volvo" + 16;

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

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript</h2>

<p>When adding a string and a number, JavaScript will treat the number as a string.</p>

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

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

</body>
</html>


ﺪﻨﻧﺍﻮﺗ ﯽﻣ ﻒﻠﺘﺨﻣ ﯼﺎﻫ ﯽﻟﺍﻮﺗ .ﺪﻨﮐ ﯽﻣ ﯽﺑﺎﯾﺯﺭﺍ ﺖﺳﺍﺭ ﻪﺑ ﭗﭼ ﺯﺍ ﺍﺭ ﺕﺍﺭﺎﺒﻋ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ

:ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ

let x = 16 + 4 + "Volvo";

:ﻪﺠﯿﺘﻧ

20Volvo

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

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript</h2>

<p>JavaScript evaluates expressions from left to right. Different sequences can produce different results:</p>

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

<script>
let x = 16 + 4 + "Volvo";
document.getElementById("demo").innerHTML = x;
</script>

</body>
</html>


:ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ

let x = "Volvo" + 16 + 4;

:ﻪﺠﯿﺘﻧ

Volvo164

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

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript</h2>

<p>JavaScript evaluates expressions from left to right. Different sequences can produce different results:</p>

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

<script>
let x = "Volvo" + 16 + 4;
document.getElementById("demo").innerHTML = x;
</script>

</body>
</html>


.ﺪﺳﺮﺑ "Volvo" ﻪﺑ ﻪﮐ ﯽﻧﺎﻣﺯ ﺎﺗ ﺪﻨﮐ ﯽﻣ ﺭﺎﺘﻓﺭ ﺩﺍﺪﻋﺍ ﻥﺍﻮﻨﻋ ﻪﺑ 4 ﻭ 16 ﺎﺑ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ،ﻝﻭﺍ ﻝﺎﺜﻣ ﺭﺩ

ﺪﻨﺘﺴﻫ ﺎﻫﺪﻧﻮﻠﻤﻋ ﻪﻤﻫ ،ﺖﺳﺍ ﻪﺘﺷﺭ ﮏﯾ ﻝﻭﺍ ﺪﻧﻮﻠﻤﻋ ﻪﮐ ﯽﯾﺎﺠﻧﺁ ﺯﺍ ،ﻡﻭﺩ ﻝﺎﺜﻣ ﺭﺩ



ﺪﻨﺘﺴﻫ ﺎﯾﻮﭘ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻉﺍﻮﻧﺍ

ﺩﺮﮐ ﻩﺩﺎﻔﺘﺳﺍ ﺮﯿﻐﺘﻣ ﻥﺎﻤﻫ ﺯﺍ ﻥﺍﻮﺗ ﯽﻣ ﯽﻨﻌﯾ .ﺩﺭﺍﺩ ﺎﯾﻮﭘ ﻉﺍﻮﻧﺍ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ

ﻝﺎﺜﻣ

let x;       // Now x is undefined
x = 5;       // Now x is a Number
x = "John";  // Now x is a String

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

.ﺖﺳﺍ «ﻭﺩ ﻥﺎﺟ» ﺪﻨﻧﺎﻣ ﺎﻫﺮﺘﮐﺍﺭﺎﮐ ﺯﺍ ﯼﺍ ﻪﻋﻮﻤﺠﻣ (ﻦﺘﻣ ﻪﺘﺷﺭ ﮏﯾ ﺎﯾ) ﻪﺘﺷﺭ ﮏﯾ


:ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﻪﻧﺎﮔﻭﺩ ﺎﯾ ﮏﺗ ﯼﺎﻫ ﻝﻮﻗ ﻞﻘﻧ ﺯﺍ ﺪﯿﻧﺍﻮﺗ ﯽﻣ .ﺪﻧﻮﺷ ﯽﻣ ﻪﺘﺷﻮﻧ ﻝﻮﻗ ﻞﻘﻧ ﺎﺑ ﺎﻫ ﻪﺘﺷﺭ

ﻝﺎﺜﻣ

// Using double quotes:
let carName1 = "Volvo XC60";

// Using single quotes:
let carName2 = 'Volvo XC60';

ﺪﻨﺷﺎﺑ ﻪﺘﺷﺍﺪﻧ ﺖﻘﺑﺎﻄﻣ ﺎﻫ ﻝﻮﻗ ﻞﻘﻧ ﺎﺑ ﻪﮐ ﯽﻃﺮﺷ ﻪﺑ ،ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﻪﺘﺷﺭ ﮏﯾ ﻞﺧﺍﺩ ﺭﺩ ﺎﻫ ﻝﻮﻗ ﻞﻘﻧ ﺯﺍ ﺪﯿﻧﺍﻮﺗ ﯽﻣ

ﻝﺎﺜﻣ

// Single quote inside double quotes:
let answer1 = "It's alright";
 

// Single quotes inside double quotes:
let answer2 = "He is called 'Johnny'";

// Double quotes inside single quotes:
let answer3 = 'He is called "Johnny"';

.ﺖﺧﻮﻣﺁ ﺪﯿﻫﺍﻮﺧ ﺎﻫ ﻪﺘﺷﺭ ﻩﺭﺎﺑﺭﺩ ﺮﺘﺸﯿﺑ ﺵﺯﻮﻣﺁ ﻦﯾﺍ ﺭﺩ ﺍًﺪﻌﺑ


ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺩﺍﺪﻋﺍ

.ﺪﻧﻮﺷ ﯽﻣ ﻩﺮﯿﺧﺫ (ﺭﻭﺎﻨﺷ ﺰﯿﻣ) ﯼﺭﺎﺸﻋﺍ ﺩﺍﺪﻋﺍ ﺕﺭﻮﺻ ﻪﺑ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺩﺍﺪﻋﺍ ﻪﻤﻫ

:ﺖﺷﻮﻧ ﺭﺎﺸﻋﺍ ﻥﻭﺪﺑ ﺎﯾ ﺎﺑ ﻥﺍﻮﺗ ﯽﻣ ﺍﺭ ﺩﺍﺪﻋﺍ

ﻝﺎﺜﻣ

// With decimals:
let x1 = 34.00;

 
// Without decimals:
let x2 = 34; 

ﯽﯾﺎﻤﻧ ﯼﺭﺍﺬﮔﺩﺎﻤﻧ

ﺖﺷﻮﻧ ﯽﻤﻠﻋ ﺎﺑ ﻥﺍﻮﺗ ﯽﻣ ﺍﺭ ﮏﭼﻮﮐ ﯽﻠﯿﺧ ﺎﯾ ﮒﺭﺰﺑ ﯽﻠﯿﺧ ﺩﺍﺪﻋﺍ

ﻝﺎﺜﻣ

let y = 123e5;    // 12300000
let z = 123e-5;   // 0.00123

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

:ﺪﻧﺭﺍﺩ ﯽﻔﻠﺘﺨﻣ ﻉﺍﻮﻧﺍ ﯽﺴﯾﻮﻧ ﻪﻣﺎﻧﺮﺑ ﯼﺎﻫ ﻥﺎﺑﺯ ﺮﺘﺸﯿﺑ


:(ﺢﯿﺤﺻ ﺩﺍﺪﻋﺍ) ﻞﻣﺎﮐ ﺩﺍﺪﻋﺍ


:(ﺭﻭﺎﻨﺷ ﺰﯿﻣ) ﯽﻘﯿﻘﺣ ﺩﺍﺪﻋﺍ

ﺪﻨﺘﺴﻫ ﻉﻮﻧ ﮏﯾ ﻪﺸﯿﻤﻫ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺩﺍﺪﻋﺍ:

.ﺖﺧﻮﻣﺁ ﺪﯿﻫﺍﻮﺧ ﺩﺍﺪﻋﺍ ﻩﺭﺎﺑﺭﺩ ﺮﺘﺸﯿﺑ ﺵﺯﻮﻣﺁ ﻦﯾﺍ ﺭﺩ ﺍًﺪﻌﺑ


BigInt ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ

.ﺪﻧﻮﺷ ﯽﻣ ﻩﺮﯿﺧﺫ ﯽﺘﯿﺑ 64 ﺭﻭﺎﻨﺷ ﺰﯿﻤﻣ ﺖﻣﺮﻓ ﮏﯾ ﺭﺩ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺩﺍﺪﻋﺍ ﻡﺎﻤﺗ

.ﺩﻮﺷ ﻩﺩﺎﻔﺘﺳﺍ ﺶﯾﺎﻤﻧ ﯼﺍﺮﺑ ﺪﻨﺘﺴﻫ ﮒﺭﺰﺑ ﯽﻠﯿﺧ ﻪﮐ ﯽﺤﯿﺤﺻ ﺮﯾﺩﺎﻘﻣ ﻩﺮﯿﺧﺫ ﯼﺍﺮﺑ ﺪﻧﺍﻮﺗ ﯽﻣ ﻪﮐ ﺖﺳﺍ (ES2020) ﺪﯾﺪﺟ ﻩﺩﺍﺩ ﻉﻮﻧ ﮏﯾ BigInt ﺖ

ﻝﺎﺜﻣ

let x = BigInt("123456789012345678901234567890");

.ﺖﺧﻮﻣﺁ ﺪﯿﻫﺍﻮﺧ BigInt ﻩﺭﺎﺑﺭﺩ ﺮﺘﺸﯿﺑ ﺵﺯﻮﻣﺁ ﻦﯾﺍ ﺭﺩ ﺍًﺪﻌﺑ


ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫ ﻦﯿﻟﻮﺑ

Booleans ﯽﻣ ﻂﻘﻓﺪﺷﺎﺑ ﻪﺘﺷﺍﺩ ﺭﺍﺪﻘﻣ ﻭﺩ ﺪﻧﺍﻮﺗ: true ﺎﯾ fal

ﻝﺎﺜﻣ

let x = 5;
let y = 5;
let z = 6;
(x == y)       
  // Returns true
(x == z)       // Returns 
  false

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

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Booleans</h2>

<p>Booleans can have two values: true or false:</p>

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

<script>
let x = 5;
let y = 5;
let z = 6;

document.getElementById("demo").innerHTML =
(x == y) + "<br>" + (x == z);
</script>

</body>
</html>

Booleans ﺩﻮﺷ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﯽﻃﺮﺷ ﺖﺴﺗ ﺭﺩ ﺐﻠﻏﺍ.

.ﺖﺧﻮﻣﺁ ﺪﯿﻫﺍﻮﺧ booleans ﻩﺭﺎﺑﺭﺩ ﺮﺘﺸﯿﺑ ﺵﺯﻮﻣﺁ ﻦﯾﺍ ﺭﺩ ﺍًﺪﻌﺑ


ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫ ﻪﯾﺍﺭﺁ

.ﺪﻧﻮﺷ ﯽﻣ ﻪﺘﺷﻮﻧ ﻊﺑﺮﻣ ﺖﮐﺍﺮﺑ ﺎﺑ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫ ﻪﯾﺍﺭﺁ

.ﺪﻧﻮﺷ ﯽﻣ ﺍﺪﺟ ﻢﻫ ﺯﺍ ﺎﻣﺎﮐ ﺎﺑ ﻪﯾﺍﺭﺁ ﯼﺎﻫ ﻢﺘﯾﺁ

ﻪﺳ ﻞﻣﺎﺷ ﻪﮐ (ﺪﻨﮐ ﯽﻣ ﺩﺎﺠﯾﺍ) ﺪﻨﮐ ﯽﻣ ﻡﻼﻋﺍ ﺍﺭ cars ﻡﺎﻧ ﻪﺑ ﯼﺍ ﻪﯾﺍﺭﺁ ﺮﯾﺯ ﺪﮐ

ﻝﺎﺜﻣ

const cars = ["Saab", "Volvo", "BMW"];

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

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Arrays</h2>

<p>Array indexes are zero-based, which means the first item is [0].</p>

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

<script>
const cars = ["Saab","Volvo","BMW"];

document.getElementById("demo").innerHTML = cars[0];
</script>

</body>
</html>

ﺖﺳﺍ ﻡﻭﺩ ،ﺖﺳﺍ [0] ﺩﺭﻮﻣ ﻦﯿﻟﻭﺍ ﻪﮐ ﯽﻨﻌﻣ ﻦﯾﺍ ﻪﺑ ،ﺪﻨﺘﺴﻫ ﺮﻔﺻ ﻪﯾﺎﭘ ﺮﺑ ﻪﯾﺍﺭﺁ ﯼﺎﻫ ﺺﺧﺎﺷ

.ﺖﺧﻮﻣﺁ ﺪﯿﻫﺍﻮﺧ ﺎﻫ ﻪﯾﺍﺭﺁ ﻩﺭﺎﺑﺭﺩ ﺮﺘﺸﯿﺑ ﺵﺯﻮﻣﺁ ﻦﯾﺍ ﺭﺩ ﺍًﺪﻌﺑ


ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ءﺎﯿﺷﺍ

.ﺪﻧﻮﺷﯽﻣ ﻪﺘﺷﻮﻧ {} ﯼﺮﻓﺮﻓ ﯼﺎﻫﺰﺘﻧﺍﺮﭘ ﺎﺑ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ءﺎﯿﺷﺍ

ﯽﺷ - ﻑﺪﻫ

ﻝﺎﺜﻣ

const person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};

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

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Objects</h2>

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

<script>
const person = {
  firstName : "John",
  lastName  : "Doe",
  age     : 50,
  eyeColor  : "blue"
};

document.getElementById("demo").innerHTML =
person.firstName + " is " + person.age + " years old.";
</script>

</body>
</html>

،firstName :ﺖﺳﺍ ﯽﮔﮋﯾﻭ 4 ﯼﺍﺭﺍﺩ ﻻﺎﺑ ﻝﺎﺜﻣ ﺭﺩ (ﺺﺨﺷ) ﯽﺷ

.ﺖﺧﻮﻣﺁ ﺪﯿﻫﺍﻮﺧ ءﺎﯿﺷﺍ ﻩﺭﺎﺑﺭﺩ ﺮﺘﺸﯿﺑ ﺵﺯﻮﻣﺁ ﻦﯾﺍ ﺭﺩ ﺍًﺪﻌﺑ


ﺭﻮﺗﺍﺮﭘﺍ ﻉﻮﻧ

.ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ typeof ﺮﮕﻠﻤﻋ ﺯﺍ ﺪﯿﻧﺍﻮﺗ ﯽﻣ ﻉﻮﻧ ﻦﺘﻓﺎﯾ ﯼﺍﺮﺑ

:ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ ﺕﺭﺎﺒﻋ ﺎﯾ ﺮﯿﻐﺘﻣ ﮏﯾ ﻉﻮﻧ typeof ﺮﮕﻠﻤﻋ

ﻝﺎﺜﻣ

typeof ""             // Returns 
 "string"
typeof "John"         // Returns 
 "string"
typeof "John Doe"     // Returns 
 "string"

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Operators</h1>
<h2>The typeof Operator</h2>
<p>The typeof operator returns the type of a variable or an expression.</p>

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

<script>
document.getElementById("demo").innerHTML = 
typeof "" + "<br>" +
typeof "John" + "<br>" + 
typeof "John Doe";
</script>
</body>
</html>


ﻝﺎﺜﻣ

typeof 0              // Returns 
 "number"
  typeof 314            // Returns 
 "number"
  typeof 3.14           // Returns 
 "number"
  typeof (3)            // Returns 
 "number"
typeof (3 + 4)        // Returns 
 "number"

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Operators</h1>
<h2>The typeof Operator</h2>
<p>The typeof operator returns the type of a variable or an expression.</p>

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

<script>
document.getElementById("demo").innerHTML = 
typeof 0 + "<br>" + 
typeof 314 + "<br>" +
typeof 3.14 + "<br>" +
typeof (3) + "<br>" +
typeof (3 + 4);
</script>

</body>
</html>


.ﺖﺧﻮﻣﺁ ﺪﯿﻫﺍﻮﺧ ﻉﻮﻧ ﻩﺭﺎﺑﺭﺩ ﺮﺘﺸﯿﺑ ﺵﺯﻮﻣﺁ ﻦﯾﺍ ﺭﺩ ﺍًﺪﻌﺑ


ﻩﺪﺸﻧ ﻒﯾﺮﻌﺗ

.ﺖﺳﺍ undefined ﺭﺍﺪﻘﻣ ﯼﺍﺭﺍﺩ ،ﺭﺍﺪﻘﻣ ﻥﻭﺪﺑ ﺮﯿﻐﺘﻣ ﮏﯾ ،ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺭﺩ

ﻝﺎﺜﻣ

let car;    // Value is undefined, 
    type is undefined

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Operators</h1>
<h2>The typeof Operator</h2>
<p>The value (and the data type) of a variable with no value is <b>undefined</b>.</p>

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

<script>
let car;
document.getElementById("demo").innerHTML =
car + "<br>" + typeof car;
</script>

</body>
</html> 

.ﺩﺮﮐ ﯽﻟﺎﺧ undefined ﺭﺍﺪﻘﻣ ﻢﯿﻈﻨﺗ ﺎﺑ ﻥﺍﻮﺗ ﯽﻣ ﺍﺭ ﯼﺮﯿﻐﺘﻣ ﺮﻫ

ﻝﺎﺜﻣ

   car = undefined;    // Value is undefined, 
    type is undefined

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Operators</h1>
<h2>The typeof Operator</h2>
<p>Variables can be emptied if you set the value to <b>undefined</b>.</p>

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

<script>
let car = "Volvo";
car = undefined;

document.getElementById("demo").innerHTML = car + "<br>" + typeof car;
</script>

</body>
</html> 

ﯽﻟﺎﺧ ﯼﺎﻫ ﺵﺯﺭﺍ

.ﺩﺭﺍﺪﻧ undefined ﻪﺑ ﯽﻄﺑﺭ ﯽﻟﺎﺧ ﺭﺍﺪﻘﻣ ﮏﯾ

.ﺩﺭﺍﺩ ﻉﻮﻧ ﻢﻫ ﻭ ﯽﻧﻮﻧﺎﻗ ﺵﺯﺭﺍ ﻢﻫ ﯽﻟﺎﺧ ﻪﺘﺷﺭ ﮏﯾ

ﻝﺎﺜﻣ

let car = "";    // The value is  "", the typeof is "string"

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

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript</h2>

<p>An empty string has both a legal value and a type:</p>

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

<script>
let car = "";
document.getElementById("demo").innerHTML =
"The value is: " +
car + "<br>" +
"The type is: " + typeof car;
</script>

</body>
</html>




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