ECMAScript 2020 ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ


فهرست مطالب

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

ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﺨﺴﻧ ﻩﺭﺎﻤﺷ

.ES6 (2015) ﻭ ES5 (2009) :ﺪﻧﺍ ﻩﺪﺷ ﯼﺭﺍﺬﮕﻣﺎﻧ ﺩﺍﺪﻋﺍ ﺎﺑ JS ﯽﻤﯾﺪﻗ ﯼﺎﻫ ﻪﺨﺴﻧ

... ،ECMAScript 2016، 2017، 2018، 2019 :ﺪﻧﻮﺷ ﯽﻣ ﯼﺭﺍﺬﮕﻣﺎﻧ ﻝﺎﺳ ﺱﺎﺳﺍ ﺮﺑ ﺎﻫ ﻪﺨﺴﻧ ،2016 ﻝﺎ

ES2020 ﺭﺩ ﺪﯾﺪﺟ ﯼﺎﻫ ﯽﮔﮋﯾﻭ

  • BigInt

  • ()matchAll ﻪﺘﺷﺭ

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

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

  • (=&&) ﯼﺭﺍﺬﮔﺍﻭ ﻭ ﯽﻘﻄﻨﻣ ﺮﮕﻠﻤﻋ

  • (=||) OR ﯽﻘﻄﻨﻣ ﺺﯿﺼﺨﺗ

  • (=??) ﺮﺛﺍ ﯽﺑ ﻡﺎﻏﺩﺍ ﻒﯿﻠﮑﺗ

  • Promise allSettled():
    style="word-wrap: break-word;">Pro

  • ﮏﯿﻣﺎﻨﯾﺩ ﺕﺍﺩﺭﺍﻭ

ﺭﺍﺪﺸﻫ

.ﺪﻨﺘﺴﻫ ﺪﯾﺪﺟ ﺎﺘﺒﺴﻧ ﺎﻫ ﯽﮔﮋﯾﻭ ﻦﯾﺍ

(Polyfill) ﺪﻨﺷﺎﺑ ﻪﺘﺷﺍﺩ ﺯﺎﯿﻧ ﻦﯾﺰﮕﯾﺎﺟ ﺪﮐ ﮏﯾ ﻪﺑ ﺖﺳﺍ ﻦﮑﻤﻣ ﯽﻤﯾﺪﻗ ﯼﺎﻫﺮﮔﺭﻭﺮﻣ

BigInt ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ

.ﺩﻮﺷ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﺢﯿﺤﺻ ﺩﺪﻋ ﮒﺭﺰﺑ ﺮﯾﺩﺎﻘﻣ ﻩﺮﯿﺧﺫ ﯼﺍﺮﺑ BigInt

.ﺪﻨﺘﺴﻫ ﻖﯿﻗﺩ ﻢﻗﺭ 15 ﺩﻭﺪﺣ ﺎﺗ ﻂﻘﻓ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺢﯿﺤﺻ ﺩﺍﺪﻋﺍ

ﺢﯿﺤﺻ ﺩﺪﻋ ﻝﺎﺜﻣ

let x = 999999999999999;
let y = 9999999999999999; // too big

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Numbers</h1>
<h2>Integer Precision</h2>

<p>Integers (numbers without a period or exponent notation) are accurate up to 15 digits:</p>

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

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

</body>
</html>


BigInt ﻝﺎﺜﻣ

let x = 9999999999999999;
let y = 9999999999999999n;

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Numbers</h1>
<h2>Integer and BigInt</h2>

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

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

</body>
</html>


.ﺪﯿﻨﮐ ﻪﻓﺎﺿﺍ ﯽﻧﺍﻮﺧﺍﺮﻓ ﺎﯾ ﺢﯿﺤﺻ ﺩﺪﻋ ﮏﯾ ﯼﺎﻬﺘﻧﺍ ﻪﺑ ﺍﺭ code class="w3-codespan">BigInt

ﻝﺎﺜﻣ

let x = 1234567890123456789012345n;
let y = BigInt(1234567890123456789012345)

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Numbers</h1>
<h2>Create a BigInt</h2>

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

<script>
let x = 123456789012345678901234567890n;
let y = BigInt("123456789012345678901234567890");
document.getElementById("demo").innerHTML = x + "<br>" + y;
</script>

</body>
</html>


ﻉﻮﻧ a BigInt ﺖﭙﯾﺮﮑﺳ

ﻝﺎﺜﻣ

let x = BigInt(999999999999999);
let type = typeof x;

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Numbers</h1>
<h2>BigInt typeof</h2>

<p>The typeof a BigInt is:</p>
<p id="demo"></p>

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

</body>
</html>


BigInt ﯽﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ ﻥﺭﺪﻣ ﯼﺎﻫﺮﮔﺭﻭﺮﻣ ﻪﻤﻫ ﺭﺩ 2020 ﺮﺒﻣﺎﺘﭙ

Chrome 67 Edge 79 Firefox 68 Safari 14 Opera 54
May 2018 Jan 2020 Jul 2019 Sep 2020 Jun 2018

()matchAll ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﺘﺷﺭ

ﺩﺮﮐ ﻩﺩﺎﻔﺘﺳﺍ ﺎﻫﺩﺍﺪﺧﺭ ﻪﻤﻫ ﯼﻮﺠﺘﺴﺟ ﯼﺍﺮﺑ ﻥﺁ ﺯﺍ ﻥﺍﻮﺘﺑ ﻪﮐ ﺖﺷﺍﺪﻧ ﺩﻮﺟﻭ ﯼﺍ ﻪﺘﺷﺭ ﺵﻭﺭ ﭻﯿﻫ ES2020

ﻝﺎﺜﻣ

const iterator = text.matchAll("Cats");

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Strings</h1>
<h2>The matchAll() Method</h2>

<p>ES2020 intoduced the string method matchAll().</p>

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

<script>
let text = "I love cats. Cats are very easy to love. Cats are very popular."
const iterator = text.matchAll("Cats");

document.getElementById("demo").innerHTML = Array.from(iterator);
</script>

</body>
</html>

ﺕﺭﻮﺻ ﻦﯾﺍ ﺮﯿﻏ ﺭﺩ ،ﺩﻮﺷ ﻢﯿﻈﻨﺗ ﺪﯾﺎﺑ (g) ﯽﻧﺎﻬﺟ ﻢﭼﺮﭘ ،ﺖﺳﺍ ﻢﻈﻨﻣ ﺕﺭﺎﺒﻋ ﮏﯾ ﺮﺘﻣﺍﺭﺎﭘ ﺮﮔﺍ

ﻝﺎﺜﻣ

const iterator = text.matchAll(/Cats/g);

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Strings</h1>
<h2>The matchAll() Method</h2>

<p>ES2020 intoduced the string method matchAll().</p>

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

<script>
let text = "I love cats. Cats are very easy to love. Cats are very popular."
const iterator = text.matchAll(/Cats/g);

document.getElementById("demo").innerHTML = Array.from(iterator);
</script>

</body>
</html>

:ﺩﻮﺷ ﻢﯿﻈﻨﺗ ﺪﯾﺎﺑ (i) ﺱﺎﺴﺣ ﺮﯿﻏ ﻢﭼﺮﭘ ،ﺪﯿﻨﮐ ﻮﺠﺘﺴﺟ ﺱﺎﺴﺣ ﺮﯿﻏ ﻑﻭﺮﺣ ﺎﺑ ﺪﯿﻫﺍﻮﺧﯽﻣ ﺮﮔﺍ

ﻝﺎﺜﻣ

const iterator = text.matchAll(/Cats/gi);

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Strings</h1>
<h2>The matchAll() Method</h2>

<p>ES2020 intoduced the string method matchAll().</p>

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

<script>
let text = "I love cats. Cats are very easy to love. Cats are very popular."
const iterator = text.matchAll(/Cats/gi);

document.getElementById("demo").innerHTML = Array.from(iterator);
</script>

</body>
</html>

ﺪﯿﺷﺎﺑ ﻪﺘﺷﺍﺩ ﻪﺟﻮﺗ

ES2021 ﻪﺘﺷﺭ ﺪﺘﻣ()replaceAll ﺩﺮﮐ ﯽﻓﺮﻌﻣ ﺍﺭ.



(??) 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

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

ﻩﺮﯿﺠﻧﺯ ﺭﻮﺗﺍﺮﭘﺍﯼﺭﺎﯿﺘﺧﺍ ﯼﺍ ﻩﺪﺸﻧ ﻒﯾﺮﻌﺗ ﯽﻣﺮﺑ

ﻝﺎﺜﻣ

const car = {type:"Fiat", model:"500", color:"white"};
let name = 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 74 Safari 13.1 Opera 67
Feb 2020 Feb 2020 Mar 2020 Mar 2020 Mar 2020

=&& ﺭﻮﺗﺍﺮﭘﺍ

ﺮﮕﻠﻤﻋ Logical AND Assignment ﺩﻮﺷ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﺭﺍﺪﻘﻣ ﻭﺩ ﻦﯿﺑ.

.ﺩﻮﺷ ﯽﻣ ﻩﺩﺍﺩ ﺺﯿﺼﺨﺗ ﻡﻭﺩ ﺭﺍﺪﻘﻣ ،ﺪﺷﺎﺑ true ﻝﻭﺍ ﺭﺍﺪﻘﻣ ﺮﮔ

ﻒﯿﻠﮑﺗ ﻭ ﯽﻘﻄﻨﻣ ﻝﺎﺜﻣ

let x = 10;
x &&= 5;

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Assignments</h1>
<h2>Logical AND Assignment</h2>
<h3>The &amp;&amp;= Operator</h3>
<p>If the first value is true, the second value is assigned.</p>

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

<script>
let x = 100;
x &&= 5;
document.getElementById("demo").innerHTML = "Value of x is: " + x;
</script>

</body>
</html>

:ﺩﻮﺷﯽﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ ﻥﺭﺪﻣ ﯼﺎﻫﺮﮔﺭﻭﺮﻣ ﻪﻤﻫ ﺭﺩ 2020 ﺮﺒﻣﺎﺘﭙﺳ ﺯﺍ

Chrome 85 Edge 85 Firefox 79 Safari 14 Opera 71
Aug 2020 Aug 2020 Mar 2020 Sep 2020 Sep 2020

=|| ﺭﻮﺗﺍﺮﭘﺍ

ﺺﯿﺼﺨﺗ ﺎﯾ ﯽﻘﻄﻨﻣ ﺭﻮﺗﺍﺮﭘﺍ ﺩﻮﺷ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﺭﺍﺪﻘﻣ ﻭﺩ ﻦﯿﺑ.

.ﺩﻮﺷ ﯽﻣ ﻩﺩﺍﺩ ﺺﯿﺼﺨﺗ ﻡﻭﺩ ﺭﺍﺪﻘﻣ ،ﺪﺷﺎﺑ false ﻝﻭﺍ ﺭﺍﺪﻘﻣ ﺮ

OR ﯽﻘﻄﻨﻣ ﻝﺎﺜﻣ

let x = 10;
x ||= 5;

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Assignments</h1>
<h2>Logical OR Assignment</h2>
<h3>The ||= Operator</h3>

<p>If the first value is false, the second value is assigned:</p>
<p id="demo"></p>

<script>
let x = undefined;
x ||= 5;
document.getElementById("demo").innerHTML = "Value of x is: " + x;
</script>

</body>
</html>

:ﺩﻮﺷ ﯽﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ ﻥﺭﺪﻣ ﯼﺎﻫﺮﮔﺭﻭﺮﻣ ﻪﻤﻫ ﺭﺩ 2020 ﺮﺒﻣﺎﺘﭙﺳ ﺯﺍ ||=<

Chrome 85 Edge 85 Firefox 79 Safari 14 Opera 71
Aug 2020 Aug 2020 Mar 2020 Sep 2020 Sep 2020

ﺭﻮﺗﺍﺮﭘﺍ =??

Nullish Coalescing Assignment Operator ﺩﻮﺷ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﺭﺍﺪﻘﻣ ﻭﺩ ﻦﯿﺑ.

.ﺩﻮﺷ ﯽﻣ ﻩﺩﺍﺩ ﺺﯿﺼﺨﺗ ﻡﻭﺩ ﺭﺍﺪﻘﻣ ،ﺪﺷﺎﺑ null ﺎﯾ ﻩﺪ

ﻞﻃﺎﺑ ﻡﺎﻏﺩﺍ ﺺﯿﺼﺨﺗ ﻝﺎﺜﻣ

let x;
x ??= 5;

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Assignments</h1>
<h2>The ??= Operator</h2>
<p>The ??= operator is used between two values. If the first value is undefined or null, the second value is assigned.</p>

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

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

</body>
</html>

:ﺩﻮﺷ ﯽﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ ﻥﺭﺪﻣ ﯼﺎﻫﺮﮔﺭﻭﺮﻣ ﻪﻤﻫ ﺭﺩ 2020 ﺮﺒﻣﺎﺘﭙﺳ ﺯﺍ ??=<

Chrome 85 Edge 85 Firefox 79 Safari 14 Opera 71
Aug 2020 Aug 2020 Mar 2020 Sep 2020 Sep 2020

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