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


فهرست مطالب

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


.ﺪﯿﻨﮐ ﯽﻣ ﮎﺭﺩ ﺍﺭ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ،ﺪﯿﻨﮐ ﮎﺭﺩ ﺍﺭ ءﺎﯿﺷﺍ ﺮﮔﺍ .ﺪﻨﺘﺴﻫ ﻩﺎﺷﺩﺎﭘ ﺎﯿﺷﺍ ،ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ


.ﺖﺳﺍ ﯽﺷ ﮏﯾ «ﺰﯿﭼ ﻪﻤﻫ» ﺎًﺒﯾﺮﻘﺗ ،ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺭﺩ

  • (ﺪﻨﺷﺎﺑ ﻩﺪﺷ ﻒﯾﺮﻌﺗ new ﯼﺪﯿﻠﮐ ﻪﻤﻠﮐ ﺎﺑ ﺮﮔﺍ) ﺪﻨﺷﺎﺑ ﺎﯿﺷﺍ ﺪ

  • (ﺪﻨﺷﺎﺑ ﻩﺪﺷ ﻒﯾﺮﻌﺗ ﺪﯾﺪﺟ<"code class="w3-codespan> ﯼﺪﯿﻠﮐ ﻪﻤﻠﮐ ﺎﺑ ﺮﮔﺍ) ﺪﻨﺷﺎﺑ ﺎﯿﺷﺍ

  • (ﺪﻨﺷﺎﺑ ﻩﺪﺷ ﻒﯾﺮﻌﺗ new ﯼﺪﯿﻠﮐ ﻪﻤﻠﮐ ﺎﺑ ﺮﮔﺍ) ﺪﻨﺷﺎﺑ ﺎﯿﺷﺍ ﺪ

  • ﺖﺳﺍ ﯽﺷ ﻪﺸﯿﻤﻫ ﺎﻣﺮﺧ

  • ﺪﻨﺘﺴﻫ ﯽﺷ ﻪﺸﯿﻤﻫ ﺕﺎﯿﺿﺎﯾﺭ

  • ﺪﻨﺘﺴﻫ ﯽﺷ ﻪﺸﯿﻤﻫ ﻢﻈﻨﻣ ﺕﺍﺭﺎﺒﻋ

  • ﺪﻨﺘﺴﻫ ﺎﯿﺷﺍ ﻪﺸﯿﻤﻫ ﺎﻫ ﻪﯾﺍﺭﺁ

  • ﺪﻨﺘﺴﻫ ﺎﯿﺷﺍ ﻪﺸﯿﻤﻫ ﻊﺑﺍﻮﺗ

  • ﺪﻨﺘﺴﻫ ﺎﯿﺷﺍ ﻪﺸﯿﻤﻫ ﺎﯿﺷﺍ

.ﺪﻨﺘﺴﻫ ﺎﯿﺷﺍ ،ﻪﯿﻟﻭﺍ ﺮﯾﺩﺎﻘﻣ ﺰﺟ ﻪﺑ ،ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺮﯾﺩﺎﻘﻣ ﻡﺎﻤﺗ


JavaScript Primitives

ﻪﯿﻟﻭﺍ ﺭﺍﺪﻘﻣ ﺩﺭﺍﺪﻧ ﯽﺷﻭﺭ ﺎﯾ ﯽﮔﮋﯾﻭ ﭻﯿﻫ ﻪﮐ ﺖﺳﺍ ﯼﺭﺍﺪﻘﻣ.

3.14 ﺖﺳﺍ ﻪﯿﻟﻭﺍ ﺭﺍﺪﻘﻣ ﮏﯾ

ﻪﯿﻟﻭﺍ ﻩﺩﺍﺩ ﻉﻮﻧ ﻩﺩﺍﺩﺖﺳﺍ ﻪﯿﻟﻭﺍ ﺭﺍﺪﻘﻣ ﯼﺍﺭﺍﺩ ﻪﮐ ﺖﺳﺍ ﯼﺍ.

:ﺪﻨﮐ ﯽﻣ ﻒﯾﺮﻌﺗ ﺍﺭ ﻪﯿﻟﻭﺍ ﻩﺩﺍﺩ ﻉﻮﻧ ﻉﻮﻧ 7 ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ

ﺎﻫ ﻝﺎﺜﻣ

  • string
  • number
  • boolean
  • null
  • undefined
  • symbol
  • bigint

ﺮﯾﺬﭘﺎﻧﺮﯿﯿﻐﺗ

.(ﺪﻨﺘﺴﯿﻧ ﺮﯿﯿﻐﺗ ﻞﺑﺎﻗ ﻭ ﺪﻨﺘﺴﻫ ﻩﺪﺷ ﯼﺭﺍﺬﮔﺪﮐ ﺎﻬﻧﺁ) ﺪﻨﺘﺴﻫ ﺮﯾﺬﭘﺎﻧ ﺮﯿﯿﻐﺗ ﻪﯿﻟﻭﺍ ﺮﯾﺩﺎﻘﻣ

.ﺪﯿﻫﺩ ﺮﯿﯿﻐﺗ ﺍﺭ 3.14 ﺭﺍﺪﻘﻣ ﺪﯿﻧﺍﻮﺗ ﯽﻤﻧ ﺎﻣﺍ ،ﺪﯿﻫﺩ ﺮﯿﯿﻐﺗ ﺍﺭ x ﺭﺍﺪﻘﻣ ﺪﯿﻧﺍﻮﺗ ﯽﻣ ،ﺪﺷﺎﺑ x=3

ValueTypeComment
"Hello"string"Hello" is always "Hello"
3.14number3.14 is always 3.14
truebooleantrue is always true
falsebooleanfalse is always false
nullnull (object)null is always null
undefinedundefinedundefined is always undefined

ﺪﻨﺘﺴﻫ ﺮﯿﻐﺘﻣ ءﺎﯿﺷﺍ

:ﺪﻨﺷﺎﺑ ﺩﺮﻔﻨﻣ ﺮﯾﺩﺎﻘﻣ ﯼﻭﺎﺣ ﺪﻨﻧﺍﻮﺗ ﯽﻣ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫﺮﯿﻐﺘﻣ

ﻝﺎﺜﻣ

let person = "John Doe";

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

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Variables</h2>

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

<script>
// Create and display a variable:
let person = "John Doe";
document.getElementById("demo").innerHTML = person;
</script>

</body>
</html>

.ﺪﻨﺷﺎﺑ ﯼﺩﺎﯾﺯ ﺮﯾﺩﺎﻘﻣ ﯼﻭﺎﺣ ﺪﻨﻧﺍﻮﺗ ﯽﻣ ﻦﯿﻨﭽﻤﻫ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫﺮﯿﻐﺘﻣ

ﺪﻨﺷﺎﺑ ﯼﺩﺎﯾﺯ ﺩﺭﺍﻮﻣ ﻞﻣﺎﺷ ﺪﻨﻧﺍﻮﺗ ﯽﻣ ءﺎﯿﺷﺍ ﺎﻣﺍ .ﺪﻨﺘﺴﻫ ﺮﯿﻐﺘﻣ ﺰﯿﻧ ﺎﯿﺷﺍ

ﮏﯾ ﺎﺑ ﺭﺍﺪﻘﻣ ﻭ ﻡﺎﻧ) ﺪﻧﻮﺷ ﯽﻣ ﻪﺘﺷﻮﻧ name : value ﺖﻔﺟ ﺕﺭﻮﺻ ﻪﺑ ءﯽﺷ ﺮﯾﺩﺎﻘﻣ

ﻝﺎﺜﻣ

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

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

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Objects</h2>
<p>Creating an object:</p>

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

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

document.getElementById("demo").innerHTML = person.firstName + " " + person.lastName;
</script>

</body>
</html>

ﺖﺳﺍ ﻩﺪﺷ ﯼﺭﺍﺬﮕﻣﺎﻧ ﺮﯾﺩﺎﻘﻣ ﺯﺍ ﯼﺍ ﻪﻋﻮﻤﺠﻣ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯽﺷ ﮏﯾ

.ﺪﯿﻨﮐ ﻡﻼﻋﺍ const ﯼﺪﯿﻠﮐ ﻪﻤﻠﮐ ﺎﺑ ﺍﺭ ﺎﯿﺷﺍ ﻪﮐ ﺖﺳﺍ ﻝﻮﻤﻌﻣ

ﻝﺎﺜﻣ

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

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

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Objects</h2>
<p>Creating an object:</p>

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

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

document.getElementById("demo").innerHTML = person.firstName + " " + person.lastName;
</script>

</body>
</html>


ﯽﺷ ﯼﺎﻫ ﯽﮔﮋﯾﻭ

.ﺪﻧﻮﺷ ﯽﻣ ﻩﺪﯿﻣﺎﻧ ﯽﮔﮋﯾﻭ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ءﺎﯿﺷﺍ ﺭﺩ ﻩﺪﺷ ﯼﺭﺍﺬﮕﻣﺎﻧ ﺮﯾﺩﺎﻘﻣ

firstName

ﻥﺎﺟ

lastName

ﻥﺯﻮﮔ

age

50

eyeColor

ﯽﺑﺁ

:ﺪﻨﺘﺴﻫ ﺮﯾﺯ ﺩﺭﺍﻮﻣ ﻪﺑﺎﺸﻣ ﺪﻧﻮﺷ ﯽﻣ ﻪﺘﺷﻮﻧ ﻡﺎﻧ ﺵﺯﺭﺍ ﺖﻔﺟ ﻥﺍﻮﻨﻋ ﻪﺑ ﻪﮐ ﯽﯾﺎﯿﺷﺍ

  • PHP ﺭﺩ ﯽﻨﻤﺠﻧﺍ ﯼﺎﻫ ﻪﯾﺍﺭﺁ

  • ﻥﻮﺘﯾﺎﭘ ﺭﺩ ﺖﻐﻟ ﮓﻨﻫﺮﻓ

  • C ﺭﺩ ﺶﻫ ﻝﻭﺍﺪﺟ

  • ﺍﻭﺎﺟ ﺭﺩ ﺶﻫ ﻪﺸﻘﻧ

  • ﻝﺮﭘ ﻭ ﯽﺑﻭﺭ ﺭﺩ ﺶﻫ


ﯽﺷ ﯼﺎﻫ ﺵﻭﺭ

.ﺩﺍﺩ ﻡﺎﺠﻧﺍ ﺎﯿﺷﺍ ﯼﻭﺭ ﻥﺍﻮﺗﯽﻣ ﻪﮐ ﺪﻨﺘﺴﻫ ﯽﯾﺎﻫﻞﻤﻋ ﺎﻫﺵﻭﺭ

.ﺪﺷﺎﺑ ﻊﺑﺍﻮﺗ ﻢﻫ ﻭ ﺮﮕﯾﺩ ءﺎﯿﺷﺍ ﻢﻫ ،ﻪﯿﻟﻭﺍ ﺮﯾﺩﺎﻘﻣ ﻢﻫ ﺪﻧﺍﻮﺗ ﯽﻣ ﯽﺷ ﯼﺎﻫ ﯽﮔﮋﯾﻭ

ﯽﺷ ﺵﻭﺭ ﻊﺑﺎﺗ ﮏﯾ ﯼﻭﺎﺣ ﻪﮐ ﺖﺳﺍ ﯽﺷ ﯽﮔﮋﯾﻭ ﮏﯾ ﺖﺳﺍ

firstName

ﻥﺎﺟ

lastName

ﻥﺯﻮﮔ

age

50

eyeColor

ﯽﺑﺁ

fullName

function() {return this.firstName + " " + this.lastName;}

.ﺪﻧﻮﺷ ﯽﻣ ﻩﺪﯿﻣﺎﻧ ﺎﻫﺪﺘﻣ ﻭ ﺹﺍﻮﺧ ﻪﮐ ﺪﻨﺘﺴﻫ ﻩﺪﺷ ﯼﺭﺍﺬﮕﻣﺎﻧ ﺮﯾﺩﺎﻘﻣ ﯼﺍﺮﺑ ﯽﯾﺎﻫ ﻪﻈﻔﺤﻣ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎ

.ﺪﺷ ﺪﯿﻫﺍﻮﺧ ﺎﻨﺷﺁ ﺮﺘﺸﯿﺑ ﺎﻫ ﺵﻭﺭ ﺎﺑ ﯼﺪﻌﺑ ﯼﺎﻫ ﻞﺼﻓ ﺭﺩ


ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯽﺷ ﮏﯾ ﺩﺎﺠﯾﺍ

.ﺪﯿﻨﮐ ﺩﺎﺠﯾﺍ ﻭ ﻒﯾﺮﻌﺗ ﺍﺭ ﺩﻮﺧ ءﺎﯿﺷﺍ ﺪﯿﻧﺍﻮﺗ ﯽﻣ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺎﺑ

:ﺩﺭﺍﺩ ﺩﻮﺟﻭ ﺪﯾﺪﺟ ءﺎﯿﺷﺍ ﺩﺎﺠﯾﺍ ﯼﺍﺮﺑ ﯽﻔﻠﺘﺨﻣ ﯼﺎﻫ ﻩﺍﺭ

  • .ﯽﻈﻔﻠﻟﺍ ﺖﺤﺗ ﯽﺷ ﮏﯾ ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ ﺎﺑ ،ﺪﺣﺍﻭ ﯽﺷ ﮏﯾ ﺩﺎﺠﯾﺍ

  • .ﺪﯿﻨﮐ ﺩﺎﺠﯾﺍ new ﯼﺪﯿﻠﮐ ﻪﻤﻠﮐ ﺎﺑ ﺪﺣﺍﻭ ءﯽﺷ ﮏﯾ

  • .ﺪﯿﻨﮐ ﺩﺎﺠﯾﺍ ﻩﺪﺷ ﻪﺘﺧﺎﺳ ﻉﻮﻧ ﺯﺍ ﯽﯾﺎﯿﺷﺍ ﺲﭙﺳ ﻭ ﺪﯿﻨﮐ ﻒﯾﺮﻌﺗ ﯽﺷ ﻩﺪﻧﺯﺎﺳ ﮏﯾ

  • .ﺪﯿﻨﮐ ﺩﺎﺠﯾﺍ ﯽﺷ ﮏﯾ Object.create() ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ ﺎﺑ


Literal ءﯽﺷ ﮏﯾ ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ

.ﺖﺳﺍ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯽﺷ ﮏﯾ ﺩﺎﺠﯾﺍ ﯼﺍﺮﺑ ﻩﺍﺭ ﻦﯾﺮﺗ ﻩﺩﺎﺳ ﻦﯾﺍ

ﺪﯿﻨﮐ ﯽﻣ ﺩﺎﺠﯾﺍ ﯽﺷ ﮏﯾ ﺭﺩ ﻢﻫ ﻭ ﺪﯿﻨﮐ ﯽﻣ ﻒﯾﺮﻌﺗ ﺍﺭ ﯽﺷ ﮏﯾ ﻢﻫ ،ﻪﻤﻠﮐ ﯽﻌﻗﺍﻭ ﯼﺎﻨﻌﻣ ﻪﺑ ﯽﺷ ﮏﯾ ﺯﺍ ﻩ

.ﺖﺳﺍ {} ﯼﺮﻓﺮﻓ ﯼﺎﻫﺰﺘﻧﺍﺮﭘ ﻞﺧﺍﺩ ﺭﺩ (50 :ﻦﺳ ﺪﻨﻧﺎﻣ) name:value ﯼﺎﻫﺖﻔﺟ ﺯﺍ ﯽﺘﺳﺮﻬﻓ ﯽﻈﻔﻟ

:ﺪﻨﮐ ﯽﻣ ﺩﺎﺠﯾﺍ ﯽﮔﮋﯾﻭ ﺭﺎﻬﭼ ﺎﺑ ﺪﯾﺪﺟ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯽﺷ ﮏﯾ ﺮﯾﺯ ﻝﺎﺜﻣ

ﻝﺎﺜﻣ

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

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

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Objects</h2>
<p>Creating a JavaScript Object:</p>

<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>

:ﺩﺮﯿﮕﺑ ﺮﺑ ﺭﺩ ﺍﺭ ﻂﺧ ﻦﯾﺪﻨﭼ ﺪﻧﺍﻮﺗ ﯽﻣ ﯽﺷ ﻒﯾﺮﻌﺗ ﮏﯾ .ﺖﺴﯿﻧ ﻢﻬﻣ ﺖﺴﮑﺷ ﻁﻮﻄﺧ ﻭ ﺎﻫ ﻪﻠﺻﺎﻓ

ﻝﺎﺜﻣ

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

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

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Objects</h2>
<p>Creating a JavaScript Object:</p>

<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>

،ﺪﻨﮐ ﯽﻣ ﺩﺎﺠﯾﺍ ﯽﻟﺎﺧ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯽﺷ ﮏﯾ ﻝﺎﺜﻣ ﻦﯾﺍ

ﻝﺎﺜﻣ

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

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

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Objects</h2>
<p>Creating a JavaScript Object:</p>

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

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

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

</body>
</html>

new ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺪﯿﻠﮐ ﻪﻤﻠﮐ ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ

ﺪﻨﮐ ﯽﻣ ﺩﺎﺠﯾﺍ ﺪﯾﺪﺟ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯽﺷ ﮏﯾ ﺮﯾﺯ ﻝﺎﺜﻣ

ﻝﺎﺜﻣ

const person = new Object();
person.firstName = "John";
person.lastName = "Doe";
person.age = 50;
person.eyeColor = "blue";

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

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Objects</h2>
<p>Creating a JavaScript Object:</p>

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

<script>
const person = new Object();
person.firstName = "John";
person.lastName = "Doe";
person.age = 50;
person.eyeColor = "blue"; 

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

</body>
</html>

.ﺪﻨﻨﮐ ﯽﻣ ﺍﺭ ﺭﺎﮐ ﻦﯿﻤﻫ ﺎًﻘﯿﻗﺩ ﻻﺎﺑ ﯼﺎﻫ ﻝﺎﺜﻣ

.ﺖﺴﯿﻧ new Object() ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ ﻪﺑ ﯼﺯﺎﯿﻧ ﺎﻣﺍ

.ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﯽﻈﻔﻟ ﯽﺷ ﺵﻭﺭ ﺯﺍ ،ﺍﺮﺟﺍ ﺖﻋﺮﺳ ﻭ ﯽﮔﺩﺎﺳ ،ﯽﯾﺎﻧﺍﻮﺧ ﯼﺍﺮﺑ


ﺪﻨﺘﺴﻫ ﺮﯿﯿﻐﺗ ﻞﺑﺎﻗ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ءﺎﯿﺷﺍ

.ﺭﺍﺪﻘﻣ ﺎﺑ ﻪﻧ ﺪﻧﻮﺷ ﯽﻣ ﺏﺎﻄﺧ ﻊﺟﺮﻣ ﺎﺑ ﺎﻬﻧﺁ :ﺪﻨﺘﺴﻫ ﺮﯿﯿﻐﺗ ﻞﺑﺎﻗ ءﺎﯿﺷﺍ

:ﺪﻨﮐ ﯽﻤﻧ ﺩﺎﺠﯾﺍ ﺺﺨﺷ ﺯﺍ ﯽﭙﮐ ﮏﯾ ﺮﯾﺯ ﺕﺭﺎﺒﻋ ،ﺪﺷﺎﺑ ﯽﺷ ﮏﯾ ﺺﺨﺷ ﺮﮔﺍ

const x = person;  // Will not create a copy of person.

ﺖﺴﻫﻦﯾﺍ .ﺖﺴﯿﻧ ﺺﺨﺷ ﯽﭙﮐ

.ﺪﻨﺘﺴﻫ ﯽﺷ ﮏﯾ person ﻭ x ﺍﺮﯾﺯ ،ﺩﻮﺷ ﯽﻣ ﺰﯿﻧ ﺺﺨﺷ ﺮﯿﯿﻐﺗ ﺚﻋﺎﺑ x ﺭﺩ ﯼﺮﯿﯿﻐﺗ ﺮﻫ

ﻝﺎﺜﻣ

const person = {
  firstName:"John",
  lastName:"Doe",
  age:50, eyeColor:"blue"
}
 
const x = person;
x.age = 10;      // Will change both x.age and person.age

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

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Objects</h2>
<p>JavaScript objects are mutable.</p>
<p>Any changes to a copy of an object will also change the original object:</p>

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

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

const x = person;
x.age = 10;

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

</body>
</html>

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