.ﺪﯿﻧﺎﺳﺮﺑ ﻞﻗﺍﺪﺣ ﻪﺑ ﺍﺭ ﯼﺮﺳﺍﺮﺳ ﯼﺎﻫﺮﯿﻐﺘﻣ ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ .ﺩﻮﺷ ﯽﻣ ﻊﺑﺍﻮﺗ ﻭ ءﺎﯿﺷﺍ ،ﺎﻫ ﻩﺩﺍﺩ ﻉﺍﻮﻧﺍ ﻡﺎﻤﺗ ﻞﻣﺎﺷ ﻦﯾﺍ .ﺩﺮﮐ ﯽﺴﯾﻮﻧﺯﺎﺑ ﺮﮕﯾﺩ ﯼﺎﻫ ﺖﭙﯾﺮﮑﺳﺍ ﻂﺳﻮﺗ ﻥﺍﻮﺗ ﯽﻣ ﺍﺭ ﯼﺮﺳﺍﺮﺳ ﻊﺑﺍﻮﺗ ﻭ ﺎﻫﺮﯿﻐﺘﻣ ﺪﯾﺮﯿﮕﺑ ﺩﺎﯾ ﺍﺭ ﻩﺩﺎﻔﺘﺳﺍ ﻩﻮﺤﻧ ﻭ ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﯽﻠﺤﻣ ﯼﺎﻫﺮﯿﻐﺘﻣ ﺯﺍ ﻥﺁ ﯼﺎﺟ ﻪﺑ .ﺪﻧﻮﺷ ﻥﻼﻋﺍ ﯽﻠﺤﻣ ﯼﺎﻫﺮﯿﻐﺘﻣ ﻥﺍﻮﻨﻋ ﻪﺑ ﺪﯾﺎﺑ ﻊﺑﺎﺗ ﮏﯾ ﺭﺩ ﻩﺪﺷ ﻩﺩﺎﻔﺘﺳﺍ ﯼﺎﻫﺮﯿﻐ ،ﺪﻧﻮﺷ ﻥﻼﻋﺍ .ﺪﺷﺎﺑ ﻩﺪﺸﻧ ﻡﻼﻋﺍ ﯼﺎﻫﺮﯿﻐﺘﻣ ﺪﻫﺩ ﯽﻤﻧ ﻩﺯﺎﺟﺍ ﻪﻧﺍﺮﯿﮔ ﺖﺨﺳ ﺖﻟﺎﺣ ﺖﺳﺍ ﺏﻮﺧ ﯽﺴﯾﻮﻧﺪﮐ ﻦﯾﺮﻤﺗ ﮏﯾ ﺖﭙﯾﺮﮑﺳﺍ ﺮﻫ ﯼﻻﺎﺑ ﺭﺩ ﺎﻫ ﻥﻼﻋﺍ ﻡﺎﻤﺗ ﻥﺩﺍﺩ ﺭﺍﺮﻗ :ﻩﺩﺍﺭﺍ ﻦﯾﺍ ﻩﺪﺑ ﻩﺪﻨﻨﮐ ﮎﺎﭘ ﺪﮐ ﺪﯿﻨﮐ ﻢﻫﺍﺮﻓ ﯽﻠﺤﻣ ﯼﺎﻫﺮﯿﻐﺘﻣ ﯼﻮﺠﺘﺴﺟ ﯼﺍﺮﺑ ﺪﺣﺍﻭ ﻥﺎﮑﻣ ﮏﯾ ﺪﯿﻨﮐ ﺮﺗ ﻥﺎﺳﺁ ﺍﺭ (ﯽﺤﯾﻮﻠﺗ) ﻪﺘﺳﺍﻮﺧﺎﻧ ﯼﺮﺳﺍﺮﺳ ﯼﺎﻫﺮﯿﻐﺘﻣ ﺯﺍ ﯼﺮﯿﮔﻮﻠﺟ ﻪﺘﺳﺍﻮﺧﺎﻧ ﺩﺪﺠﻣ ﻡﻼﻋﺍ ﻝﺎﻤﺘﺣﺍ ﺶﻫﺎﮐ :ﺪﻨﮐ ﯽﻣ ﻕﺪﺻ ﻪﻘﻠﺣ ﯼﺎﻫﺮﯿﻐﺘﻣ ﯼﺍﺮﺑ ﻦﯿﻨﭽﻤﻫ ﻦﯾﺍ .ﺪﯿﻨﮐ ﻪﯿﻟﻭﺍ ﯽﻫﺩﺭﺍﺪﻘﻣ ﺪﯿﻨﮐ ﯽﻣ ﻡﻼﻋﺍ ﺍﺭ ﺎﻬﻧﺁ ﻪﮐ ﯽﻧﺎﻣﺯ ﺍﺭ ﺎﻫﺮﯿﻐﺘﻣ ﻪﮐ ﺖﺳﺍ ﺏﻮﺧ ﯽﺴﯾﻮﻧ ﺪﮐ ﻦﯾﺮ :ﻩﺩﺍﺭﺍ ﻦﯾﺍ ﻩﺪﺑ ﻩﺪﻨﻨﮐ ﮎﺎﭘ ﺪﮐ ﺪﯿﻨﮐ ﻢﻫﺍﺮﻓ ﺎﻫﺮﯿﻐﺘﻣ ﻪﯿﻟﻭﺍ ﯽﻫﺩﺭﺍﺪﻘﻣ ﯼﺍﺮﺑ ﺪﺣﺍﻭ ﻥﺎﮑﻣ ﮏﯾ ﺪﯿﻨﮐ ﺏﺎﻨﺘﺟﺍ ﻩﺪﺸﻧ ﻒﯾﺮﻌﺗ ﺮﯾﺩﺎﻘﻣ ﺯﺍ .ﺪﻫﺩ ﯽﻣ ﻪﺋﺍﺭﺍ ﺍﺭ (ﺮﻈﻧ ﺩﺭﻮﻣ ﻩﺩﺍﺩ ﻉﻮﻧ ﻭ) ﺮﻈﻧ ﺩﺭﻮﻣ ﺩﺮﺑﺭﺎﮐ ﺯﺍ ﯼﺍ ﻩﺪﯾﺍ ﺎﻫﺮﯿﻐﺘﻣ ﻪﯿﻟﻭﺍ ﯽﻫﺩﺭﺍ :ﺪﻨﮐ ﯽﻣ ﯼﺮﯿﮔﻮﻠﺟ ﻉﻮﻧ ﯽﻓﺩﺎﺼﺗ ﺮﯿﯿﻐﺗ ﻪﻧﻮﮔﺮﻫ ﺯﺍ const ﺎﺑ ﺎﯿﺷﺍ ﻥﻼﻋﺍ :ﺪﻨﮐ ﯽﻣ ﯼﺮﯿﮔﻮﻠﺟ ﻉﻮﻧ ﯽﻓﺩﺎﺼﺗ ﺮﯿﯿﻐﺗ ﻪﻧﻮﮔﺮﻫ ﺯﺍ const ﺎﺑ ﺎﻫ ﻪﯾﺍﺭﺁ ﻥﻼﻋﺍ ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ .ﺖﺳﺍ ﻩﺪﺷ ﭗﯾﺎﺗ ﻞﺷ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ .ﺪﺷﺎﺑ ﺎﻫ ﻩﺩﺍﺩ ﻉﺍﻮﻧﺍ ﻡﺎﻤﺗ ﻞﻣﺎﺷ ﺪﻧﺍﻮﺗ ﯽﻣ ﺮﯿﻐﺘﻣ ﮏﯾ :ﺪﻫﺩ ﺮﯿﯿﻐﺗ ﺍﺭ ﺩﻮﺧ ﻩﺩﺍﺩ ﻉﻮﻧ ﺪﻧﺍﻮﺗ ﯽﻣ ﺮﯿﻐﺘﻣ ﮏﯾ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ ﻪﻧ) ﺪﻧﻮﺷ ﻞﯾﺪﺒﺗ :ﺪﻨﮐ ﻞﯾﺪﺒﺗ ﻪﺘﺷﺭ ﻪﺑ ﺍﺭ ﺩﺍﺪﻋﺍ ﺪﻧﺍﻮﺗ ﯽﻣ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ،ﯽﺿﺎﯾﺭ ﺕﺎﯿﻠﻤﻋ ﻡﺎﺠﻧﺍ ﻡﺎﮕﻨﻫ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ ﺩﻮﺷ ﯽﻤﻧ ﻡﺎﺠﻧﺍ ،ﻪﺘﺷﺭ ﮏﯾ ﺯﺍ ﻪﺘﺷﺭ ﮏﯾ ﻥﺩﺮﮐ ﻢﮐ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ ﺯﺍ ﻞﺒﻗ (ﻖﺒﻄﻨﻣ ﻉﺍﻮﻧﺍ ﻪﺑ) ﻪﺸﯿﻤﻫ :ﺪﻨﮐ ﯽﻣ ﺭﻮﺒﺠﻣ ﺍﺭ ﻉﻮﻧ ﻭ ﺮﯾﺩﺎﻘﻣ ﻪﺴﯾﺎﻘﻣ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ ﺖﺳﺍ ﻪﺘﻓﺭ ﺖﺳﺩ ﺯﺍ ﻥﺁ ﺭﺍﺪﻘﻣ ،ﺩﻮﺷ ﯽﻧﺍﻮﺧﺍﺮﻓ ﻩﺪﺷ ﻢﮔ ﻥﺎﻣﻮﮔﺭﺁ ﺎﺑ ﯽﻌﺑﺎﺗ ﺮﮔﺍ ﺖﺳﺍ ﺏﻮﺧ ﺕﺩﺎﻋ ﮏﯾ ﺽﺮﻓ ﺶﯿﭘ ﺺﯿﺼﺨﺗ .ﺪﻨﻨﮑﺸﺑ ﺍﺭ ﺎﻤﺷ ﺪﮐ ﺪﻨﻧﺍﻮﺗ ﯽﻣ ﻩﺪﺸﻧ ﻒﯾﺮﻌﺗ ﺮﯾﺩﺎﻘﻣ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ ECMAScript 2015 ﺪﻫﺩ ﯽﻣ ﻩﺯﺎﺟﺍ ﻊﺑﺎﺗ ﻒﯾﺮﻌﺗ ﺭﺩ ﺽﺮﻓ ﺶﯿﭘ ﯼﺎﻫﺮﺘﻣﺍﺭﺎﭘ ﻪﺑ: ﺪﯿﻧﺍﻮﺨﺑ ﺮﺘﺸﯿﺑ ﻊﺑﺎﺗ ﯼﺎﻫﺮﺘﻣﺍﺭﺎﭘ ﺭﺩ ﺎﻫ ﻥﺎﻣﻮﮔﺭﺁ ﻭ ﻊﺑﺎﺗ ﯼﺎﻫﺮﺘﻣﺍﺭﺎﭘ ﺩﺭﻮﻣ ﺭﺩ ﺩﺭﺍﺩ ﺩﻮﺟﻭ ﺪﯿﻨﮐ ﯽﻣ ﺮﮑﻓ ﺮﮔﺍ ﯽﺘﺣ .ﺪﯿﻫﺩ ﻥﺎﯾﺎﭘ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ ﻥﺍﻮﻨﻋ ﻪﺑ ﻪﻧ .ﺪﯾﺮﯿﮕﺑ ﺮﻈﻧ ﺭﺩ ﻪﯿﻟﻭﺍ ﺮﯾﺩﺎﻘﻣ ﻥﺍﻮﻨﻋ ﻪﺑ ﺍﺭ ﺎﻫ ﯽﻟﻮﺑ ﺎﯾ ﺎﻫ ﻪﺘﺷﺭ ،ﺩﺍﺪﻋﺍ ﻪﺸﯿﻤﻫ ،ﺪﻫﺩ ﯽﻣ ﺶﻫﺎﮐ ﺍﺭ ﺍﺮﺟﺍ ﺖﻋﺮﺳ ،ﺎﯿﺷﺍ ﻥﺍﻮﻨﻋ ﻪﺑ ﻉﻮﻧ ﻦﯾﺍ ﻡﻼﻋﺍ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺮﺗﺪﺑ ﯽﺘﺣ ﺎﯾ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ ﺍﺭ ﻥﺁ ،ﺩﺭﺍﻮﻣ ﻪﻤﻫ ﺭﺩ ﺎﺒﯾﺮﻘﺗ .ﺩﻮﺷ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﺪﮐ ﻥﺍﻮﻨﻋ ﻪﺑ ﻦﺘﻣ ﯼﺍﺮﺟﺍ ﯼﺍﺮﺑ eval()
ﺯﺍ ﺏﺎﻨﺘﺟﺍ ،==
ﺪﯿﻨﮐ ﺏﺎﻨﺘﺟﺍ ﯽﻧﺎﻬﺟ ﯼﺎﻫﺮﯿﻐﺘﻣ ﺯﺍ
ﺪﯿﻨﮐ ﻡﻼﻋﺍ ﺍﺭ ﯽﻠﺤﻣ ﯼﺎﻫﺮﯿﻐﺘﻣ ﻪﺸﯿﻤﻫ
var
ﺎﺑ ﺪﯾﺎﺑ ﯽﻠﺤﻣ ﯼﺎﻫﺮﯿﻐﺘ ﻻﺎﺑ ﺭﺩ ﺎﻫ ﻪﯿﻣﻼﻋﺍ
// Declare at the beginning
let firstName, lastName, price, discount, fullPrice;
// Use later
firstName = "John";
lastName = "Doe";
price = 19.90;
discount = 0.10;
fullPrice = price - discount;
for (let i = 0; i < 5; i++)
{
ﺎﻫﺮﯿﻐﺘﻣ ﻪﯿﻟﻭﺍ ﯽﻫﺩﺭﺍﺪﻘﻣ
// Declare and initiate at the beginning
let firstName = "";
let lastName = "";
let price = 0;
let discount = 0;
let fullPrice = 0,
const myArray = [];
const myObject = {};
ﺪﯿﻨﮐ ﻥﻼﻋﺍ const ﺎﺑ ﺍﺭ ءﺎﯿﺷﺍ
ﻝﺎﺜﻣ
let car = {type:"Fiat", model:"500", color:"white"};
car = "Fiat"; // Changes object to string
const car = {type:"Fiat", model:"500", color:"white"};
car = "Fiat"; // Not possible
ﺪﯿﻨﮐ ﻡﻼﻋﺍ const ﺎﺑ ﺍﺭ ﺎﻫ ﻪﯾﺍﺭﺁ
ﻝﺎﺜﻣ
let cars = ["Saab", "Volvo", "BMW"];
cars = 3; // Changes array to number
const cars = ["Saab", "Volvo", "BMW"];
cars = 3; // Not possible
ﺪﯿﻨﮑﻧ ﻩﺩﺎﻔﺘﺳﺍ()New Object ﺯﺍ
""
ﺯﺍ new Str
0
ﺯﺍ new Numb
false
ﺯﺍ new
{}
ﺯﺍ new Obj
[]
ﺯﺍ new Arr
/()/
ﺯﺍ new R
new Function()
ﯼﺎﺟ ﻪﺑ {}() ﻊﺑﺎﺗ<
ﻝﺎﺜﻣ
let x1 = ""; // new primitive string
let x2 = 0; // new primitive number
let x3 = false; // new primitive boolean
const x4 = {}; // new object
const x5 = []; // new array object
const x6 = /()/; // new regexp object
const x7 = function(){}; // new function object
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Literal Constructors</h2>
<p id="demo"></p>
<script>
let x1 = "";
let x2 = 0;
let x3 = false;
const x4 = {};
const x5 = [];
const x6 = /()/;
const x7 = function(){};
document.getElementById("demo").innerHTML =
"x1: " + typeof x1 + "<br>" +
"x2: " + typeof x2 + "<br>" +
"x3: " + typeof x3 + "<br>" +
"x4: " + typeof x4 + "<br>" +
"x5: " + typeof x5 + "<br>" +
"x6: " + typeof x6 + "<br>" +
"x7: " + typeof x7 + "<br>";
</script>
</body>
</html>
ﺪﯿﺷﺎﺑ ﺭﺎﮐﺩﻮﺧ ﻉﻮﻧ ﻞﯾﺪﺒﺗ ﺐﻗﺍﺮﻣ
ﻝﺎﺜﻣ
let x = "Hello"; // typeof x is a string
x = 5; // changes typeof x to a number
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Variables</h2>
<p>A variable can chang its type. In this example x is first a string then a number:</p>
<p id="demo"></p>
<script>
let x = "Hello";
x = 5;
document.getElementById("demo").innerHTML = typeof x;
</script>
</body>
</html>
NaN
ﺎﯾ ﻪﺘﺷﺭ ﻪﺑ ﯽﻓﺩﺎﺼﺗ ﺭﻮﻃ ﻪﺑ ﺖﺳﺍ ﻦﮑﻤﻣ ﻝﺎﺜﻣ
let x = 5 + 7; // x.valueOf() is 12, typeof x is a number
let x = 5 + "7"; // x.valueOf() is 57, typeof x is a string
let x = "5" + 7; // x.valueOf() is 57, typeof x is a string
let x = 5 - 7; // x.valueOf() is -2, typeof x is a number
let x = 5 - "7"; // x.valueOf() is -2, typeof x is a number
let x = "5" - 7; // x.valueOf() is -2, typeof x is a number
let x = 5 - "x"; // x.valueOf() is NaN, typeof x is a number
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Variables</h2>
<p>Remove the comment (at the beginning of the lines) to test each case:</p>
<p id="demo"></p>
<script>
let x = 5;
//x = 5 + 7; // x.valueOf() is 12, typeof x is a number
//x = 5 + "7"; // x.valueOf() is 57, typeof x is a string
//x = "5" + 7; // x.valueOf() is 57, typeof x is a string
//x = 5 - 7; // x.valueOf() is -2, typeof x is a number
//x = 5 - "7"; // x.valueOf() is -2, typeof x is a number
//x = "5" - 7; // x.valueOf() is -2, typeof x is a number
//x = 5 - "x"; // x.valueOf() is NaN, typeof x is a number
document.getElementById("demo").innerHTML = x.valueOf() + " " + typeof x;
</script>
</body>
</html>
ﻝﺎﺜﻣ
"Hello" - "Dolly" // returns NaN
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Variables</h2>
<p>Subtracting a string from a string, does not generate an error but returns NaN (Not a Number):</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = "Hello" - "Dolly";
</script>
</body>
</html>
ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﻪﺴﯾﺎﻘﻣ === ﺯﺍ
==
ﻪﺴﯾﺎﻘﻣ ﺮﮕﻠﻤﻋ===
ﺮﮕﻠﻤﻋ ﻝﺎﺜﻣ
0 == ""; // true
1 == "1"; // true
1 == true; // true
0 === ""; // false
1 === "1"; // false
1 === true;
// false
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Comparisons</h2>
<p>Remove the comment (at the beginning of each line) to test each case:</p>
<p id="demo"></p>
<script>
let x;
//x = (0 == ""); // true
//x = (1 == "1"); // true
//x = (1 == true); // true
//x = (0 === ""); // false
//x = (1 === "1"); // false
//x = (1 === true); // false
document.getElementById("demo").innerHTML = x;
</script>
</body>
</html>
ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﺽﺮﻓ ﺶﯿﭘ ﯼﺎﻫﺮﺘﻣﺍﺭﺎﭘ ﺯﺍ
ﻝﺎﺜﻣ
function myFunction(x, y) {
if (y === undefined) {
y = 0;
}
}
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Functions</h2>
<p>Setting a default value to a function parameter.</p>
<p id="demo"></p>
<script>
function myFunction(x, y) {
if (y === undefined) {
y = 0;
}
return x * y;
}
document.getElementById("demo").innerHTML = myFunction(4);
</script>
</body>
</html>
function (a=1, b=1) { /*function code*/ }
ﺪﯿﻫﺩ ﻥﺎﯾﺎﭘ ﺎﻫ ﺽﺮﻓ ﺶﯿﭘ ﺎﺑ ﺍﺭ ﺩﻮﺧ ﯼﺎﻫ ﭻﯿﺋﻮﺳ
ﺽﺮﻓﺶﯿﭘ<"code class="w3-codespan
ﻝﺎﺜﻣ
switch (new Date().getDay()) {
case 0:
day = "Sunday";
break;
case 1:
day = "Monday";
break;
case 2:
day = "Tuesday";
break;
case 3:
day = "Wednesday";
break;
case 4:
day = "Thursday";
break;
case 5:
day = "Friday";
break;
case 6:
day = "Saturday";
break;
default:
day =
"Unknown";
}
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
let day;
switch (new Date().getDay()) {
case 0:
day = "Sunday";
break;
case 1:
day = "Monday";
break;
case 2:
day = "Tuesday";
break;
case 3:
day = "Wednesday";
break;
case 4:
day = "Thursday";
break;
case 5:
day = "Friday";
break;
case 6:
day = "Saturday";
break;
default:
day = "unknown";
}
document.getElementById("demo").innerHTML = "Today is " + day;
</script>
</body>
</html>
ﺪﯿﻨﮐ ﺏﺎﻨﺘﺟﺍ ﺎﯿﺷﺍ ﻥﺍﻮﻨﻋ ﻪﺑ ﯽﻟﻮﺑ ﻭ ﻪﺘﺷﺭ ،ﺩﺪﻋ ﺯﺍ
ﻝﺎﺜﻣ
let x = "John";
let y = new String("John");
(x === y) // is false because x is a string and y is an object.
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript String Objects</h2>
<p>Never create strings as objects.</p>
<p>Strings and objects cannot be safely compared.</p>
<p id="demo"></p>
<script>
let x = "John"; // x is a string
let y = new String("John"); // y is an object
document.getElementById("demo").innerHTML = (x === y);
</script>
</body>
</html>
ﻝﺎﺜﻣ
let x = new String("John");
let y = new String("John");
(x == y) // is false because you cannot compare objects.
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript String Objects</h2>
<p>Never create strings as objects.</p>
<p>JavaScript cannot compare objects.</p>
<p id="demo"></p>
<script>
let x = new String("John");
let y = new String("John");
document.getElementById("demo").innerHTML = (x == y);
</script>
</body>
</html>
()eval ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ ﺯﺍ ﺏﺎﻨﺘﺟﺍ