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


فهرست مطالب

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


ﺎﯾ true ﺖﺴﺗ ﯼﺍﺮﺑ ﯽﻘﻄﻨﻣ ﻭ ﻪﺴﯾﺎﻘﻣ ﯼﺎﻫﺮﮕﻠﻤﻋ


ﻪﺴﯾﺎﻘﻣ ﯼﺎﻫﺭﻮﺗﺍﺮﭘﺍ

.ﺪﻧﻮﺷ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﺮﯾﺩﺎﻘﻣ ﺎﯾ ﺎﻫﺮﯿﻐﺘﻣ ﻦﯿﺑ ﺕﻭﺎﻔﺗ ﺎﯾ ﯼﺮﺑﺍﺮﺑ ﻦﯿﯿﻌﺗ ﯼﺍﺮﺑ ﯽﻘﻄﻨﻣ ﯼﺎﻫ ﻩﺭﺍﺰﮔ ﺭﺩ

:ﺪﻫﺩ ﯽﻣ ﺢﯿﺿﻮﺗ ﺍﺭ ﻪﺴﯾﺎﻘﻣ ﯼﺎﻫﺮﮕﻠﻤﻋ ﺮﯾﺯ ﻝﻭﺪﺟ ،x=5 ﻪﮑﻨ

==

ﺕﺎﺤﯿﺿﻮﺗ: ﺖﺳﺍ ﺮﺑﺍﺮﺑ

:ﻥﺩﺮﮐ ﻪﺴﯾﺎﻘﻣ

x == 8

:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ

false

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Comparison</h1>
<h2>The == Operator</h2>

<p>Assign 5 to x, and display the value of the comparison (x == 8):</p>

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

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

</body>
</html>

:ﻥﺩﺮﮐ ﻪﺴﯾﺎﻘﻣ

x == 5

:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ

true

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Comparison</h1>
<h2>The == Operator</h2>

<p>Assign 5 to x, and display the value of the comparison (x == 5):</p>

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

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

</body>
</html>

:ﻥﺩﺮﮐ ﻪﺴﯾﺎﻘﻣ

x == "5"

:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ

true

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Comparison</h1>
<h2>The == Operator</h2>

<p>Assign 5 to x, and display the value of the comparison (x == 5):</p>

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

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

</body>
</html>

===

ﺕﺎﺤﯿﺿﻮﺗ: ﯼﻭﺎﺴﻣ ﻉﻮﻧ ﻭ ﺮﺑﺍﺮﺑ ﺭﺍﺪﻘﻣ

:ﻥﺩﺮﮐ ﻪﺴﯾﺎﻘﻣ

x === 5	

:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ

true

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Comparison</h1>
<h2>The === Operator</h2>

<p>Assign 5 to x, and display the value of the comparison (x === 5):</p>

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

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

</body>
</html>

:ﻥﺩﺮﮐ ﻪﺴﯾﺎﻘﻣ

x === "5"

:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ

false

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Comparison</h1>
<h2>The === Operator</h2>

<p>Assign 5 to x, and display the value of the comparison (x === "5").</p>

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

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

</body>
</html>

!=

ﺕﺎﺤﯿﺿﻮﺗ: ﺖﺴﯿﻧ ﺮﺑﺍﺮﺑ

:ﻥﺩﺮﮐ ﻪﺴﯾﺎﻘﻣ

x != 8

:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ

true

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Comparison</h1>
<h2>The != Operator</h2>

<p>Assign 5 to x, and display the value of the comparison (x != 8).</p>

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

<script>
let x = 5;
document.getElementById("demo").innerHTML = (x != 8);
</script>

</body>
</html>

!==

ﺕﺎﺤﯿﺿﻮﺗ: ﺖﺴﯿﻧ ﯼﻭﺎﺴﻣ ﻉﻮﻧ ﺎﯾ ﺖﺴﯿﻧ ﯼﻭﺎﺴﻣ ﺭﺍﺪﻘﻣ

:ﻥﺩﺮﮐ ﻪﺴﯾﺎﻘﻣ

x !== 5

:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ

false

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Comparison</h1>
<h2>The !== Operator</h2>

<p>Assign 5 to x, and display the value of the comparison (x !== 5):</p>

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

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

</body>
</html>

:ﻥﺩﺮﮐ ﻪﺴﯾﺎﻘﻣ

x !== "5"

:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ

true

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Comparison</h1>
<h2>The !== Operator</h2>

<p>Assign 5 to x, and display the value of the comparison (x !== "5"):</p>

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

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

</body>
</html>

:ﻥﺩﺮﮐ ﻪﺴﯾﺎﻘﻣ

x !== 8

:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ

true

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Comparison</h1>
<h2>The !== Operator</h2>

<p>Assign 5 to x, and display the value of the comparison (x !== 8):</p>

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

<script>
let x = 5;
document.getElementById("demo").innerHTML = (x !== 8);
</script>

</body>
</html>

>

ﺕﺎﺤﯿﺿﻮﺗ: ﺯﺍ ﺮﺘﺸﯿﺑ

:ﻥﺩﺮﮐ ﻪﺴﯾﺎﻘﻣ

x > 8

:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ

false

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Comparison</h1>
<h2>The &gt; Operator</h2>

<p>Assign 5 to x, and display the value of the comparison (x &gt; 8).</p>
 
<p id="demo"></p>

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

</body>
</html>

<

ﺕﺎﺤﯿﺿﻮﺗ: ﺯﺍ ﺮﺘﻤﮐ

:ﻥﺩﺮﮐ ﻪﺴﯾﺎﻘﻣ

x < 8

:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ

true

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Comparison</h1>
<h2>The &lt; Operator</h2>

<p>Assign 5 to x, and display the value of the comparison (x &lt; 8).</p>

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

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

</body>
</html>

>=

ﺕﺎﺤﯿﺿﻮﺗ: ﯼﻭﺎﺴﻣ ﺎﯾ ﺮﺘﮔﺭﺰﺑ

:ﻥﺩﺮﮐ ﻪﺴﯾﺎﻘﻣ

x >= 8

:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ

false

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Comparison</h1>
<h2>The &gt;= Operator</h2>

<p>Assign 5 to x, and display the value of the comparison (x &gt;= 8).</p>

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

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

</body>
</html>

<=

ﺕﺎﺤﯿﺿﻮﺗ: ﯼﻭﺎﺴﻣ ﺎﯾ ﺮﺘﻤﮐ

:ﻥﺩﺮﮐ ﻪﺴﯾﺎﻘﻣ

x <= 8

:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ

true

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Comparison</h1>
<h2>The &lt;= Operator</h2>

<p>Assign 5 to x, and display the value of the comparison (x &lt;= 8).</p>

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

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

</body>
</html>


ﺩﻮﺷ ﻩﺩﺎﻔﺘﺳﺍ ﺪﻧﺍﻮﺘﯿﻣ ﻮﻄﭼ

ﺩﺮﮐ ﻩﺩﺎﻔﺘﺳﺍ ﺮﯾﺩﺎﻘﻣ ﻪﺴﯾﺎﻘﻣ ﯼﺍﺮﺑ ﯽﻃﺮﺷ ﺕﺍﺭﻮﺘﺳﺩ ﺭﺩ ﻥﺍﻮﺗ ﯽﻣ ﺍﺭ ﻪﺴﯾﺎﻘﻣ ﯼﺎﻫﺮﮕﻠﻤﻋ

if (age < 18) text = "Too young to buy alcohol";

.ﺪﺷ ﺪﯿﻫﺍﻮﺧ ﺎﻨﺷﺁ ﺮﺘﺸﯿﺑ ﯽﻃﺮﺷ ﺕﺍﺭﻮﺘﺳﺩ ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ ﺎﺑ ﺵﺯﻮﻣﺁ ﻦﯾﺍ ﯼﺪﻌﺑ ﻞﺼﻓ ﺭﺩ


ﯽﻘﻄﻨﻣ ﯼﺎﻫﺮﮕﻠﻤﻋ

.ﺪﻧﻮﺷ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﺮﯾﺩﺎﻘﻣ ﺎﯾ ﺎﻫﺮﯿﻐﺘﻣ ﻦﯿﺑ ﻖﻄﻨﻣ ﻦﯿﯿﻌﺗ ﯼﺍﺮﺑ ﯽﻘﻄﻨﻣ ﯼﺎﻫﺮﮕﻠﻤﻋ

:ﺪﻫﺩ ﯽﻣ ﺢﯿﺿﻮﺗ ﺍﺭ ﯽﻘﻄﻨﻣ ﯼﺎﻫﺮﮕﻠﻤﻋ ﺮﯾﺯ ﻝﻭﺪﺟ ،y=3

&&

ﺕﺎﺤﯿﺿﻮﺗ:

:ﻥﺩﺮﮐ ﻪﺴﯾﺎﻘﻣ

 (x < 10 && y > 1)

:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ

true

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Comparison</h1>
<h2>The && Operator (Logical AND)</h2>
<p>The && operator returns true if both expressions are true, otherwise it returns false.</p>

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

<script>
let x = 6;
let y = 3;

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

</body>
</html>

||

ﺕﺎﺤﯿﺿﻮﺗ: ﺎﯾ

:ﻥﺩﺮﮐ ﻪﺴﯾﺎﻘﻣ

(x == 5 || y == 5)

:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ

false

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Comparison</h1>
<h2>The || Operator (Logical OR)</h2>
<p>The || returns true if one or both expressions are true, otherwise it returns false.</p>

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

<script>
let x = 6;
let y = 3;

document.getElementById("demo").innerHTML = 
(x == 5 || y == 5) + "<br>" + 
(x == 6 || y == 0) + "<br>" + 
(x == 0 || y == 3) + "<br>" + 
(x == 6 || y == 3);
</script>

</body>
</html>

!

ﺕﺎﺤﯿﺿﻮﺗ: ﻪﻧ

:ﻥﺩﺮﮐ ﻪﺴﯾﺎﻘﻣ

!(x == y)

:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ

true

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Comparison</h2>

<p>The NOT operator (!) returns true for false statements and false for true statements.</p>

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

<script>
let x = 6;
let y = 3;

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

</body>
</html>

.(ﯽﯾﺎﺗ ﻪﺳ) ﻁﻭﺮﺸﻣ ﺭﻮﺗﺍﺮﭘﺍ

.ﺪﻫﺩ ﯽﻣ ﺹﺎﺼﺘﺧﺍ ﯼﺭﺍﺪﻘﻣ ﺮﯿﻐﺘﻣ ﮏﯾ ﻪﺑ ﯽﻄﯾﺍﺮﺷ ﺱﺎﺳﺍ ﺮﺑ ﻪﮐ ﺖﺳﺍ ﯽﻃﺮﺷ ﺮﮕﻠﻤﻋ ﮏﯾ ﻞﻣﺎﺷ ﻦﯿﻨﭽﻤﻫ ﺖﭙﯾ

ﻮﺤﻧ

variablename = (condition) ? value1:value2 

ﻝﺎﺜﻣ

let voteable = (age < 18) ? "Too young":"Old enough";

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Comparison</h1>
<h2>The () ? : Ternary Operator</h2>

<p>Input your age and click the button:</p>

<input id="age" value="18" />

<button onclick="myFunction()">Try it</button>

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

<script>
function myFunction() {
  let age = document.getElementById("age").value;
  let voteable = (age < 18) ? "Too young":"Old enough";
  document.getElementById("demo").innerHTML = voteable + " to vote.";
}
</script>

</body>
</html>

ﺖﺳﺍ ﯼﺃﺭ ﻞﺑﺎﻗ ﺮﯿﻐﺘﻣ ﺭﺍﺪﻘﻣ ،ﺪﺷﺎﺑ 18 ﺮﯾﺯ ﯼﺭﺍﺪﻘﻣ ﻦﺳ ﺮﯿﻐﺘﻣ ﺮﮔﺍ


ﻒﻠﺘﺨﻣ ﻉﺍﻮﻧﺍ ﻪﺴﯾﺎﻘﻣ

.ﺪﺷﺎﺑ ﻪﺘﺷﺍﺩ ﻩﺍﺮﻤﻫ ﻪﺑ ﯼﺍ ﻩﺮﻈﺘﻨﻣﺮﯿﻏ ﺞﯾﺎﺘﻧ ﺖﺳﺍ ﻦﮑﻤﻣ ﻒﻠﺘﺨﻣ ﻉﺍﻮﻧﺍ ﯼﺎﻫ ﻩﺩﺍﺩ ﻪﺴﯾﺎﻘﻣ

ﻪﺑ ﺍﺭ ﻪﺘﺷﺭ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ،ﺩﺪﻋ ﮏﯾ ﺎﺑ ﻪﺘﺷﺭ ﮏﯾ ﻪﺴﯾﺎﻘﻣ ﻡﺎﮕﻨﻫ

2 < 12

ﺭﺍﺪﻘﻣ:

true

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Comparison</h2>

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

<script>
document.getElementById("demo").innerHTML = 2 < 12;
</script>

</body>
</html>

2 < "12"

ﺭﺍﺪﻘﻣ:

true

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Comparison</h2>

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

<script>
document.getElementById("demo").innerHTML = 2 < "12";
</script>

</body>
</html>

2 < "John"

ﺭﺍﺪﻘﻣ:

false

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Comparison</h2>

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

<script>
document.getElementById("demo").innerHTML = 2 < "John";
</script>

</body>
</html>

2 > "John"

ﺭﺍﺪﻘﻣ:

false

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Comparison</h2>

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

<script>
document.getElementById("demo").innerHTML = 2 > "John";
</script>

</body>
</html>

2 == "John"

ﺭﺍﺪﻘﻣ:

false

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Comparison</h2>

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

<script>
document.getElementById("demo").innerHTML = 2 == "John";
</script>

</body>
</html>

"2" < "12"

ﺭﺍﺪﻘﻣ:

false

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Comparison</h2>

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

<script>
document.getElementById("demo").innerHTML = "2" < "12";
</script>

</body>
</html>

"2" > "12"

ﺭﺍﺪﻘﻣ:

true

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Comparison</h2>

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

<script>
document.getElementById("demo").innerHTML = "2" > "12";
</script>

</body>
</html>

"2" == "12"

ﺭﺍﺪﻘﻣ:

false

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Comparison</h2>

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

<script>
document.getElementById("demo").innerHTML = "2" == "12";
</script>

</body>
</html>

ﺍﺮﯾﺯ ،ﺩﻮﺑ ﺪﻫﺍﻮﺧ "12" ﺯﺍ ﺮﺘﮔﺭﺰﺑ "2" ،ﻪﺘﺷﺭ ﻭﺩ ﻪﺴﯾﺎﻘﻣ ﻡﺎﮕﻨﻫ

ﺪﻧﻮﺷ ﻞﯾﺪﺒﺗ ﺐﺳﺎﻨﻣ ﻉﻮﻧ ﻪﺑ ﺪﯾﺎﺑ ﺎﻫﺮﯿﻐﺘﻣ ،ﺐﺳﺎﻨﻣ ﻪﺠﯿﺘﻧ ﮏﯾ ﺯﺍ ﻥﺎﻨﯿﻤﻃﺍ ﯼﺍﺮﺑ

age = Number(age);
if (isNaN(age)) {
  voteable = "Input is not a number";
} else {
    voteable = (age < 18) ? "Too young" : "Old enough";
}

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

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Comparisons</h2>

<p>Input your age and click the button:</p>

<input id="age" value="18" />

<button onclick="myFunction()">Try it</button>

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

<script>
function myFunction() {
  let voteable;
  let age = Number(document.getElementById("age").value);
  if (isNaN(age)) {
    voteable = "Input is not a number";
  } else {
    voteable = (age < 18) ? "Too young" : "Old enough";
  }
  document.getElementById("demo").innerHTML = voteable + " to vote";
}
</script>

</body>
</html>

(??) Nullish Coalescing ﺭﻮﺗﺍﺮﭘﺍ

.ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺪﺷﺎﺒﻧ ﻞﻃﺎﺑ ﻪﮐ ﯽﺗﺭﻮﺻ ﺭﺩ ﺍﺭ ﻥﺎﻣﻮﮔﺭﺁ ﻦﯿﻟﻭﺍ

.ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ ﻡﻭﺩ ﻥﺎﻣﻮﮔﺭﺁ ﺕﺭﻮﺻ ﻦﯾﺍ ﺮﯿﻏ ﺭﺩ

ﻝﺎﺜﻣ

let name = null;
let text = "missing";
let result = name ?? text;

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Operators</h1>
<h2>The ?? Operator</h2>
<p>The ?? operator returns the first argument if it is not nullish (null or undefined). Otherwise it returns the second.</p>

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

<script>
let name = null;
let text = "missing";
let result = name ?? text;
document.getElementById("demo").innerHTML = "The name is " + result; 
</script>

</body>
</html>


:ﺩﻮﺷ ﯽﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ ﺎﻫﺮﮔﺭﻭﺮﻣ ﻪﻤﻫ ﺭﺩ 2020 ﺱﺭﺎﻣ ﺯﺍ nullish ﺭﻮﺗﺍﺮﭘﺍ

Chrome 80 Edge 80 Firefox 72 Safari 13.1 Opera 67
Feb 2020 Feb 2020 Jan 2020 Mar 2020 Mar 2020

(.?) ﯼﺍ ﻩﺮﯿﺠﻧﺯ ﯼﺭﺎﯿﺘﺧﺍ ﺭﻮﺗﺍﺮﭘﺍ

ﺪﺷﺎﺑ ءﯽﺷ ﮏﯾ ﺮﮔﺍ ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ ﻩﺪﺸﻧ ﻒﯾﺮﻌﺗ<"code>

ﻝﺎﺜﻣ

// Create an object:
const car = {type:"Fiat", model:"500", color:"white"};
// Ask for car name:
document.getElementById("demo").innerHTML = car?.name;

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Operators</h1>
<h2>The ?. Operator</h2>
<p>The ?. operator returns undefined if an object is undefined or null (instead of throwing an error).</p>

<p>Car name is:</p>
<p id="demo"></p>

<script>
const car = {type:"Fiat", model:"500", color:"white"};
let name = car?.name;
document.getElementById("demo").innerHTML = name;
</script>

</body>
</html>

:ﺩﻮﺷ ﯽﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ ﺎﻫﺮﮔﺭﻭﺮﻣ ﻪﻤﻫ ﺭﺩ 2020 ﺱﺭﺎﻣ ﺯﺍ ﯼﺍ ﻩﺮﯿﺠﻧﺯ ﯼﺭﺎﯿﺘﺧﺍ ﺭﻮﺗﺍﺮﭘﺍ

Chrome 80 Edge 80 Firefox 72 Safari 13.1 Opera 67
Feb 2020 Feb 2020 Jan 2020 Mar 2020 Mar 2020

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