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


فهرست مطالب

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

ﺎﯾ true :ﺪﻫﺩ ﯽﻣ ﻥﺎﺸﻧ ﺍﺭ ﺭﺍﺪﻘﻣ ﻭﺩ ﺯﺍ ﯽﮑﯾ ﯽﻟﻮﺑ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﮏﯾ

ﯽﻟﻮﺑ ﯼﺎﻫ ﺵﺯﺭﺍ

ﺪﺷﺎﺑ ﻪﺘﺷﺍﺩ ﻩﺩﺍﺩ ﻉﻮﻧ ﮏﯾ ﺪﻧﺍﻮﺗ ﯽﻣ ﻂﻘﻓ ﻪﮐ ﺪﯾﺭﺍﺩ ﺯﺎﯿﻧ ﻩﺩﺍﺩ ﻉﻮﻧ ﮏﯾ ﻪﺑ ،ﯽﺴﯾﻮﻧ ﻪﻣﺎﻧﺮﺑ ﺭﺩ ،ﺕﺎ

  • ﺮﯿﺧ ﻪﻠﺑ

  • ﺵﻮﻣﺎﺧ ﻦﺷﻭﺭ

  • ﻂﻠﻏ ﺖﺳﺭﺩ

ﺪﻧﺍﻮﺗ ﯽﻣ ﻂﻘﻓ .ﺖﺳﺍ Boolean ﻩﺩﺍﺩ ﻉﻮﻧ ﮏﯾ ﯼﺍﺭﺍﺩ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ،ﺭﺎﮐ ﻦﯾﺍ ﯼﺍ


.()Boolean ﻊﺑﺎﺗ

(ﺮﯿﻐﺘﻣ ﮏﯾ ﺎﯾ) ﺕﺭﺎﺒﻋ ﮏﯾ ﺪﯿﻤﻬﻔﺑ ﺎﺗ ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ Boolean()

ﻝﺎﺜﻣ

Boolean(10 > 9)

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Booleans</h1>
<p>Display the value of Boolean(10 &gt; 9):</p>

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

<script>
document.getElementById("demo").innerHTML = Boolean(10 > 9);
</script>

</body>
</html>

:ﺮﺗ ﻩﺩﺎﺳ ﯽﺘﺣ ﺎﯾ

ﻝﺎﺜﻣ

(10 > 9)
10 > 9

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Booleans</h1>
<p>Display the value of 10 &gt; 9:</p>

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

<script>
document.getElementById("demo").innerHTML = 10 > 9;
</script>

</body>
</html>

ﻂﯾﺍﺮﺷ ﻭ ﺎﻫ ﻪﺴﯾﺎﻘﻣ

.ﺪﻫﺩ ﯽﻣ ﻪﺴﯾﺎﻘﻣ ﯼﺎﻫﺮﮕﻠﻤﻋ ﺯﺍ ﯽﻠﮐ ﯼﺎﻤﻧ ﮏﯾ JS Comparisons ﻞﺼﻓ

.ﺪﻫﺩ ﯽﻣ ﻪﺋﺍﺭﺍ ﯽﻃﺮﺷ ﺕﺍﺭﺎﺒﻋ ﺯﺍ ﯽﻠﮐ ﯼﺎﻤﻧ ﮏﯾ JS Conditions ﻞﺼﻓ

:ﺖﺳﺍ ﻩﺪﺷ ﻩﺩﺭﻭﺁ ﻪﻧﻮﻤﻧ ﺪﻨﭼ ﺎﺠﻨﯾﺍ ﺭﺩ

==

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

ﻝﺎﺜﻣ:

if (day == "Monday")

>

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

ﻝﺎﺜﻣ:

if (salary > 9000)

<

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

ﻝﺎﺜﻣ:

if (age < 18)

.ﺖﺳﺍ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻂﯾﺍﺮﺷ ﻭ ﺎﻫ ﻪﺴﯾﺎﻘﻣ ﻪﻤﻫ ﯼﺍﺮﺑ ﯽﯾﺎﻨﺒﻣ ﺕﺭﺎﺒﻋ ﮏﯾ ﯽﻟﻮﺑ ﺭﺍﺪﻘﻣ



ﺖﺳﺍ ﺖﺳﺭﺩ "ﺵﺯﺭﺍ" ﮏﯾ ﺎﺑ ﯼﺰﯿﭼ ﺮﻫ

ﺎﻫ ﻝﺎﺜﻣ

100

3.14

-15

"Hello"

"false"

7 + 1 + 3.14

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Booleans</h1>
<p id="demo"></p>

<script>
document.getElementById("demo").innerHTML =
"100 is " + Boolean(100) + "<br>" +
"3.14 is " + Boolean(3.14) + "<br>" +
"-15 is " + Boolean(-15) + "<br>" +
"Any (not empty) string is " + Boolean("Hello") + "<br>" +
"Even the string 'false' is " + Boolean('false') + "<br>" +
"Any expression (except zero) is " + Boolean(1 + 7 + 3.14);
</script>

</body>
</html>

ﺖﺳﺍ ﺖﺳﺭﺩﺎﻧ "ﺵﺯﺭﺍ" ﻥﻭﺪﺑ ﺰﯿﭼ ﻪﻤﻫ

:ﺖﺳﺍ ﺖﺳﺭﺩﺎﻧ (ﺮﻔﺻ) 0 ﯽﻟﻮﺑ ﺭﺍﺪﻘﻣ

let x = 0;
Boolean(x);

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Booleans</h1>
<p>Display the Boolean value of 0:</p>

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

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

</body>
</html>

:ﺖﺳﺍ ﺖﺳﺭﺩﺎﻧ (ﺮﻔﺻ ﯼﺎﻬﻨﻣ) -0 ﯽﻟﻮﺑ ﺭﺍﺪﻘﻣ

let x = -0;
Boolean(x);

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Booleans</h1>
<p>Display the Boolean value of  -0:</p>

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

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

</body>
</html>

:ﺖﺳﺍ ﺖﺳﺭﺩﺎﻧ (ﯽﻟﺎﺧ ﻪﺘﺷﺭ)"" ﯽﻟﻮﺑ ﺭﺍﺪﻘﻣ

let x = "";
Boolean(x);

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Booleans</h1>
<p>Display the Boolean value of "":</p>

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

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

</body>
</html>

:ﺖﺳﺍ undefined false ﯽﻟﻮﺑ ﺭﺍﺪﻘﻣ

let x;
Boolean(x);

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Booleans</h1>
<p>Display the Boolean value of undefined:</p>

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

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

</body>
</html>

:ﺖﺳﺍ null false ﯽﻟﻮﺑ ﺭﺍﺪﻘﻣ

let x = null;
Boolean(x);

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Booleans</h1>
<p>Display the Boolean value of null:</p>

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

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

</body>
</html>

:ﺖﺳﺍ false (ﺪﯾﺩﺯ ﺱﺪﺣ ﺎﻤﺷ) false ﯽﻟﻮﺑ ﺭﺍﺪﻘﻣ

let x = false;
Boolean(x);

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Booleans</h1>
<p>Display the Boolean value of false:</p>

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

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

</body>
</html>

:ﺖﺳﺍ ﺖﺳﺭﺩﺎﻧNaN ﯽﻟﻮﺑ ﺭﺍﺪﻘﻣ

let x = 10 / "Hallo";
Boolean(x);

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Booleans</h1>
<p>Display the Boolean value of NaN:</p>

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

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

</body>
</html>

ﺎﯿﺷﺍ ﻥﺍﻮﻨﻋ ﻪﺑ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫ ﻦﯿﻟﻮﺑ

:ﺪﻧﻮﺷ ﯽﻣ ﺩﺎﺠﯾﺍ ﻆﻔﻟ ﺯﺍ ﻪﮐ ﺪﻨﺘﺴﻫ ﯽﯾﺍﺪﺘﺑﺍ ﺮﯾﺩﺎﻘﻣ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫ ﻦﯿﻟﻮﺑ ﻝﻮﻤﻌﻣ ﺭﻮﻃ ﻪﺑ

let x = false;

:ﺪﻧﻮﺷ ﻒﯾﺮﻌﺗ new ﯼﺪﯿﻠﮐ ﻪﻤﻠﮐ ﺎﺑ ﯽﯾﺎﯿﺷﺍ ﻥﺍﻮﻨﻋ ﻪﺑ ﺪﻨﻧﺍﻮﺗ

let y = new Boolean(false);

ﻝﺎﺜﻣ

let x = false;
let y = new Boolean(false);

 //
typeof x returns boolean
 //
typeof y returns object

.ﺪﯿﻨﮑﻧ ﺩﺎﺠﯾﺍ ﯽﻟﻮﺑ ءﺎﯿﺷﺍ

.ﺪﻫﺩ ﯽﻣ ﺶﻫﺎﮐ ﺍﺭ ﺍﺮﺟﺍ ﺖﻋﺮﺳ ﻭ ﺪﻨﮐ ﯽﻣ ﻩﺪﯿﭽﯿﭘ ﺍﺭ ﺪﮐ new

:ﺪﻨﻨﮐ ﺩﺎﺠﯾﺍ ﯼﺍ ﻩﺮﻈﺘﻨﻣﺮﯿﻏ ﺞﯾﺎﺘﻧ ﺪﻨﻧﺍﻮﺗ ﯽﻣ ﯽﻟﻮﺑ ءﺎﯿﺷﺍ

:ﺪﻨﺘﺴﻫ ﺮﺑﺍﺮﺑ==، x> ﺮﮕﻠﻤﻋ ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ ﻡﺎﮕﻨﻫ

let x = false;
let y = new Boolean(false);

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Booleans</h1>
<p>Booleans and Boolean objects cannot be safely compared:</p>

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

<script>
let x = false;         // x is a boolean
let y = new Boolean(false);  // y is an object
document.getElementById("demo").innerHTML = (x==y);
</script>

</body>
</html>

:ﺪﻨﺘﺴﯿﻧ ﺮﺑﺍﺮﺑ===، x> ﺮﮕﻠﻤﻋ ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ ﻡﺎﮕ

let x = false;
let y = new Boolean(false);

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Booleans</h1>
<p>Booleans and Boolean objects cannot be safely compared:</p>

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

<script>
let x = false;         // x is a Boolean
let y = new Boolean(false);  // y is an object
document.getElementById("demo").innerHTML = (x===y);
</script>

</body>
</html>

.ﺪﯿﻨﮐ ﻪﺟﻮﺗ (x===y) ﻭ (x==y) ﻦﯿﺑ ﺕﻭﺎﻔﺗ ﻪﺑ

(x == y) ؟ﺖﺳﺭﺩﺎﻧ ﺎﯾ ﺖﺳﺍ ﺖﺳﺭﺩ

let x = new Boolean(false);
let y = new Boolean(false);

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Booleans</h1>
<p>Booleans and Boolean objects cannot be safely compared.</p>

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

<script>
const x = new Boolean(false);
const y = new Boolean(false);
document.getElementById("demo").innerHTML = (x==y);
</script>

</body>
</html>

(x === y) ؟ﺖﺳﺭﺩﺎﻧ ﺎﯾ ﺖﺳﺍ ﺖﺳﺭﺩ

let x = new Boolean(false);
let y = new Boolean(false);

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Booleans</h1>
<p>Booleans and Boolean objects cannot be safely compared.</p>

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

<script>
const x = new Boolean(false);
const y = new Boolean(false);
document.getElementById("demo").innerHTML = (x===y);
</script>

</body>
</html>

.ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ falseﻪﺸﯿﻤﻫ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯽﺷ ﻭﺩ ﻪﺴﯾﺎﻘﻣ

ﻞﻣﺎﮐ ﯽﻟﻮﺑ ﻊﺟﺮﻣ

ﺪﯾﻭﺮﺑ ﺎﻣ Complete ﻪﺑ ،ﻞﻣﺎﮐ ﻊﺟﺮﻣ ﮏﯾ ﯼﺍﺮﺑ

.ﺖﺳﺍ ﯽﻟﻮﺑ ﯼﺎﻫ ﺵﻭﺭ ﻭ ﺹﺍﻮﺧ ﻡﺎﻤﺗ ﺯﺍ ﯽﯾﺎﻫ ﻪﻧﻮﻤﻧ ﻭ ﺕﺎﺤﯿﺿﻮﺗ ﯼﻭﺎﺣ ﻊﺟﺮﻣ

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