ﺎﯾ 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 > 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
:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ
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 >= 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
:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ
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>
ﺩﺮﮐ ﻩﺩﺎﻔﺘﺳﺍ ﺮﯾﺩﺎﻘﻣ ﻪﺴﯾﺎﻘﻣ ﯼﺍﺮﺑ ﯽﻃﺮﺷ ﺕﺍﺭﻮﺘﺳﺩ ﺭﺩ ﻥﺍﻮﺗ ﯽﻣ ﺍﺭ ﻪﺴﯾﺎﻘﻣ ﯼﺎﻫﺮﮕﻠﻤﻋ
if (age < 18) text = "Too young to buy alcohol";
.ﺪﺷ ﺪﯿﻫﺍﻮﺧ ﺎﻨﺷﺁ ﺮﺘﺸﯿﺑ ﯽﻃﺮﺷ ﺕﺍﺭﻮﺘﺳﺩ ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ ﺎﺑ ﺵﺯﻮﻣﺁ ﻦﯾﺍ ﯼﺪﻌﺑ ﻞﺼﻓ ﺭﺩ
.ﺪﻧﻮﺷ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﺮﯾﺩﺎﻘﻣ ﺎﯾ ﺎﻫﺮﯿﻐﺘﻣ ﻦﯿﺑ ﻖﻄﻨﻣ ﻦﯿﯿﻌﺗ ﯼﺍﺮﺑ ﯽﻘﻄﻨﻣ ﯼﺎﻫﺮﮕﻠﻤﻋ
:ﺪﻫﺩ ﯽﻣ ﺢﯿﺿﻮﺗ ﺍﺭ ﯽﻘﻄﻨﻣ ﯼﺎﻫﺮﮕﻠﻤﻋ ﺮﯾﺯ ﻝﻭﺪﺟ ، ﺕﺎﺤﯿﺿﻮﺗ: ﻭ :ﻥﺩﺮﮐ ﻪﺴﯾﺎﻘﻣ :ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺕﺎﺤﯿﺿﻮﺗ: ﺎﯾ :ﻥﺩﺮﮐ ﻪﺴﯾﺎﻘﻣ :ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺕﺎﺤﯿﺿﻮﺗ: ﻪﻧ :ﻥﺩﺮﮐ ﻪﺴﯾﺎﻘﻣ :ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ .ﺪﻫﺩ ﯽﻣ ﺹﺎﺼﺘﺧﺍ ﯼﺭﺍﺪﻘﻣ ﺮﯿﻐﺘﻣ ﮏﯾ ﻪﺑ ﯽﻄﯾﺍﺮﺷ ﺱﺎﺳﺍ ﺮﺑ ﻪﮐ ﺖﺳﺍ ﯽﻃﺮﺷ ﺮﮕﻠﻤﻋ ﮏﯾ ﻞﻣﺎﺷ ﻦﯿﻨﭽﻤﻫ ﺖﭙﯾ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ ﺖﺳﺍ ﯼﺃﺭ ﻞﺑﺎﻗ ﺮﯿﻐﺘﻣ ﺭﺍﺪﻘﻣ ،ﺪﺷﺎﺑ 18 ﺮﯾﺯ ﯼﺭﺍﺪﻘﻣ ﻦﺳ ﺮﯿﻐﺘﻣ ﺮﮔﺍ .ﺪﺷﺎﺑ ﻪﺘﺷﺍﺩ ﻩﺍﺮﻤﻫ ﻪﺑ ﯼﺍ ﻩﺮﻈﺘﻨﻣﺮﯿﻏ ﺞﯾﺎﺘﻧ ﺖﺳﺍ ﻦﮑﻤﻣ ﻒﻠﺘﺨﻣ ﻉﺍﻮﻧﺍ ﯼﺎﻫ ﻩﺩﺍﺩ ﻪﺴﯾﺎﻘﻣ ﻪﺑ ﺍﺭ ﻪﺘﺷﺭ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ،ﺩﺪﻋ ﮏﯾ ﺎﺑ ﻪﺘﺷﺭ ﮏﯾ ﻪﺴﯾﺎﻘﻣ ﻡﺎﮕﻨﻫ ﺭﺍﺪﻘﻣ: → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺭﺍﺪﻘﻣ: → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺭﺍﺪﻘﻣ: → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺭﺍﺪﻘﻣ: → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺭﺍﺪﻘﻣ: → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺭﺍﺪﻘﻣ: → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺭﺍﺪﻘﻣ: → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺭﺍﺪﻘﻣ: → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺮﯾﺯ ،ﺩﻮﺑ ﺪﻫﺍﻮﺧ "12" ﺯﺍ ﺮﺘﮔﺭﺰﺑ "2" ،ﻪﺘﺷﺭ ﻭﺩ ﻪﺴﯾﺎﻘﻣ ﻡﺎﮕﻨﻫ ﺪﻧﻮﺷ ﻞﯾﺪﺒﺗ ﺐﺳﺎﻨﻣ ﻉﻮﻧ ﻪﺑ ﺪﯾﺎﺑ ﺎﻫﺮﯿﻐﺘﻣ ،ﺐﺳﺎﻨﻣ ﻪﺠﯿﺘﻧ ﮏﯾ ﺯﺍ ﻥﺎﻨﯿﻤﻃﺍ ﯼﺍﺮﺑ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ .ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺪﺷﺎﺒﻧ ﻞﻃﺎﺑ ﻪﮐ ﯽﺗﺭﻮﺻ ﺭﺩ ﺍﺭ ﻥﺎﻣﻮﮔﺭﺁ ﻦﯿﻟﻭﺍ .ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ ﻡﻭﺩ ﻥﺎﻣﻮﮔﺭﺁ ﺕﺭﻮﺻ ﻦﯾﺍ ﺮﯿﻏ ﺭﺩ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺩﻮﺷ ﯽﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ ﺎﻫﺮﮔﺭﻭﺮﻣ ﻪﻤﻫ ﺭﺩ 2020 ﺱﺭﺎﻣ ﺯﺍ nullish ﺭﻮﺗﺍﺮﭘﺍ ﺪﺷﺎﺑ ءﯽﺷ ﮏﯾ ﺮﮔﺍ ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ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>
ﻒﻠﺘﺨﻣ ﻉﺍﻮﻧﺍ ﻪﺴﯾﺎﻘﻣ
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>
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>
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 |