.ES6 (2015) ﻭ ES5 (2009) :ﺪﻧﺍ ﻩﺪﺷ ﯼﺭﺍﺬﮕﻣﺎﻧ ﺩﺍﺪﻋﺍ ﺎﺑ JS ﯽﻤﯾﺪﻗ ﯼﺎﻫ ﻪﺨﺴﻧ
... ،ECMAScript 2016، 2017، 2018، 2019 :ﺪﻧﻮﺷ ﯽﻣ ﯼﺭﺍﺬﮕﻣﺎﻧ ﻝﺎﺳ ﺱﺎﺳﺍ ﺮﺑ ﺎﻫ ﻪﺨﺴﻧ ،2016 ﻝﺎ
String.trimStart()
String.trimEnd()
Object.fromEntries
ﯼﺭﺎﯿﺘﺧﺍ ﺪﯿﺻ
Array.flat()
Array.flatMap()
Array.Sort ﻩﺪﺷ ﺡﻼﺻﺍ()
JSON.stringify() ﻩﺪﺷ ﺮﻈﻧ ﺪﯾﺪﺠﺗ
ﺪﻨﺘﺴﻫ ﺯﺎﺠﻣ ﻪﺘﺷﺭ ﯼﺎﺒﻔﻟﺍ ﻑﻭﺮﺣ ﺭﺩ ﻩﺪﻨﻨﮐﺍﺪﺟ ﯼﺎﻫﺩﺎﻤﻧ
()Function.toString ﻩﺪﺷ ﯽﻨﯿﺑﺯﺎﺑ
.ﺪﻨﺘﺴﻫ ﺪﯾﺪﺟ ﺎﺘﺒﺴﻧ ﺎﻫ ﯽﮔﮋﯾﻭ ﻦﯾﺍ
(Polyfill) ﺪﻨﺷﺎﺑ ﻪﺘﺷﺍﺩ ﺯﺎﯿﻧ ﻦﯾﺰﮕﯾﺎﺟ ﺪﮐ ﮏﯾ ﻪﺑ ﺖﺳﺍ ﻦﮑﻤﻣ ﯽﻤﯾﺪﻗ ﯼﺎﻫﺮﮔﺭﻭﺮﻣ
ES2019 ﺵﻭﺭ String trimStart()
ﺩﺮﮐ ﻪﻓﺎﺿﺍ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ
let text1 = " Hello World! ";
let text2 = text1.trimStart();
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Strings</h1>
<h2>The trimStart() Method</h2>
<p id="demo"></p>
<script>
let text1 = " Hello World! ";
let text2 = text1.trimStart();
document.getElementById("demo").innerHTML =
"Length text1 = " + text1.length + "<br>Length text2 = " + text2.length;
</script>
</body>
</html>
:ﺩﻮﺷﯽﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ ﻥﺭﺪﻣ ﯼﺎﻫﺮﮔﺭﻭﺮﻣ ﻪﻤﻫ ﺭﺩ 2020 ﻪﯾﻮﻧﺍﮊ ﺯﺍ ES2019 ﺵﻭﺭ String → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺩﻮﺷ ﯽﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ ﻥﺭﺪﻣ ﯼﺎﻫﺮﮔﺭﻭﺮﻣ ﻪﻤﻫ ﺭﺩ 2020 ﻪﯾﻮﻧﺍﮊ ﺯﺍ ES2019 ﺵﻭﺭ Object → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺩﻮﺷ ﯽﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ 2020 ﻪﯾﻮﻧﺍﮊ ﺯﺍ ﻥﺭﺪﻣ ﯼﺎﻫﺮﮔﺭﻭﺮﻣ ﻪﻤﻫ ﺭﺩ .ﺪﯿﻨﮐ ﻑﺬﺣ ﺍﺭ catch ﺮﺘﻣﺍﺭﺎﭘ ﺪﯿﻧﺍﻮﺗﯽﻣ ،ﺪﯾﺭﺍﺪﻧ ﺯﺎﯿﻧ ﻥﺁ ﻪﺑ ﺮﮔﺍ ،ES2019 ﺯﺍ :2019 ﺯﺍ ﻞﺒﻗ :2019 ﺯﺍ ﺪﻌﺑ catch binding ﯽﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ ﻥﺭﺪﻣ ﯼﺎﻫﺮﮔﺭﻭﺮﻣ ﻪﻤﻫ ﺭﺩ 2020 ﻪﯾﻮﻧﺍﮊ ﺯﺍ ﯼﺭﺎﯿﺘﺧﺍﺩﻮﺷ: ES2019 ﺪﺘﻣ Array .ﺪﻨﮐ ﯽﻣ ﺩﺎﺠﯾﺍ ﺪﯾﺪﺟ ﻪﯾﺍﺭﺁ ﮏﯾ ،ﻮﺗ ﺭﺩ ﻮﺗ ﻪﯾﺍﺭﺁ ﮏﯾ ﻥﺩﺮﮐ ﻑﺎﺻ ﺎﺑ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ JavaScript Array ES2019 ﺪﺘﻣ Array .ﺪﻨﮐ ﯽﻣ ﻢﯿﺳﺮﺗ ﺍﺭ ﻪﯾﺍﺭﺁ ﮏﯾ ﺮﺻﺎﻨﻋ ﻪﻤﻫ ﺍﺪﺘﺑﺍ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ ES2019 ﺵﻭﺭ Array .ﺩﺍﺩ ﯽﻣ ﻩﺯﺎﺟﺍ QuickSort ﺪﻨﻧﺎﻣ ﺭﺍﺪﯾﺎﭘﺎﻧ ﯼﺯﺎﺳ ﺐﺗﺮﻣ ﯼﺎﻫ ﻢﺘﯾﺭﻮﮕﻟﺍ ﻪﺑ ﺕﺎﺼﺨﺸﻣ ﻦﯾﺍ ،2019 ﻝﺎﺳ :ﺪﻨﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﺭﺍﺪﯾﺎﭘ ﯼﺯﺎﺳ ﺐﺗﺮﻣ ﻢﺘﯾﺭﻮﮕﻟﺍ ﮏﯾ ﺯﺍ ﺪﯾﺎﺑ ﺎﻫﺮﮔﺭﻭﺮﻣ ،ES2019 ﺯﺍ ﺪﻌﺑ .ﺪﻨﻨﮐ ﻆﻔﺣ ﺭﺍﺪﻘﻣ ﻥﺎﻤﻫ ﺎﺑ ﺮﺻﺎﻨﻋ ﺮﯾﺎﺳ ﻪﺑ ﺖﺒﺴﻧ ﺍﺭ ﺩﻮﺧ ﯽﺒﺴﻧ ﺖﯿﻌﻗﻮﻣ ﺪﯾﺎﺑ ﺮﺻﺎﻨﻋ ،ﺭﺍﺪﻘﻣ ﮏﯾ ﯼﻭ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ ﺪﻨﻧﺎﻣ ﯼﺮﮕﯾﺩ ﯽﺒﺴﻧ ﺖﯿﻌﻗﻮﻣ ﺭﺩ ﺎﻫ ﻡﺎﻧ ﺎﺑ ﺖﺴﯿﻧ ﺯﺎﺠﻣ ﻪﺠﯿﺘﻧ ،ﺖﻤﯿﻗ ﺱﺎﺳﺍ ﺮﺑ ﯼﺯﺎﺳ ﺐﺗﺮﻣ ﻡﺎﮕﻨﻫ ،ﻻ ES2019 ﺵﻭﺭ JSON .ﺪﻨﮐ ﯼﺪﻨﺑﻪﺘﺷﺭ ﺍﺭ\ﺎﺑ ﻩﺪﺷ ﯼﺭﺍﺬﮔﺪﮐ ﯼﺎﻫﻪﺴﯾﻮﻧ ﺖﺴﻧﺍﻮﺗﯽﻤﻧ JSON ،2019 ﻝﺎﺳ ﺯﺍ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ (U+DFFF ﺎﺗ U+D800) UTF-8 ﺪﮐ ﻁﺎﻘﻧ ﺭﺩ code class="w3-codespan">JSON.stringify()J ،ﺪﻧﻮﺷﯽﻣ ﻞﯾﺪﺒﺗ :ﺪﺷﯽﻣ ﺎﻄﺧ ﺕﺎﺋﺎﻨﺜﺘﺳﺍ ﻪﺑ ﺮﺠﻨﻣ ﻭ ﺪﺷﯽﻣ ﻪﺘﻓﺮﮔ ﺮﻈﻧ ﺭﺩ ﻂﺧ ﻩﺪﻨﻫﺩﻥﺎﯾﺎﭘ ﻥﺍﻮﻨﻋu20 → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ .ﺪﻧﺭﺍﺩ ﯼﻭﺎﺴﻣ ﻦﯿﻧﺍﻮﻗ JSON ﻭ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ،ﻥﻮﻨﮐﺍ :ES2019 ﺯﺍ ﻞﺒﻗ text=JSON.parse('"\u2028"') ﺩﻮﺷ ﯽﻣ ﻪﯾﺰﺠﺗ '' ﻪﺑ. text='"\u2028"' ﻮﺤﻧ ﯼﺎﻄﺧ ﺪﻫﺩ ﯽﻣ. ES2019 ﻊﺑﺎﺗ ﺵﻭﺭ .ﺖﺳﺍ ﻊﺑﺎﺗ ﮏﯾ ﻊﺒﻨﻣ ﺪﮐ ﻩﺪﻨﻫﺩ ﻥﺎﺸﻧ ﻪﮐ ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ ﯼﺍ ﻪﺘﺷﺭ .ﺪﻧﺍﺩﺮﮔﺮﺑ ﺍﺭ ﺕﺍﺮﻈﻧ ﻞﻣﺎﺷ ﻊﺑﺎﺗ ﻊﺒﻨﻣ ﺪﮐ ﺪﯾﺎﺑ()toString ،2019 ﻝﺎﺳ ﺯﺍ .(ﻪﻠﺻﺎﻓ ﻭ ﺮﻈﻧ ﻥﻭﺪﺑ ﺪﻨﻧﺎﻣ) ﺪﻧﺪﻧﺍﺩﺮﮔﺮﺑ ﺍﺭ ﺩﺮﮑﻠﻤﻋ ﺯﺍ ﯽﻔﻠﺘﺨﻣ ﻉﺍﻮﻧﺍ ﻒﻠﺘﺨﻣ ﯼﺎﻫﺮﮔﺭﻭﺮﻣ ،2019 → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
Chrome 66
Edge 79
Firefox 61
Safari 12
Opera 50
Apr 2018
Jan 2020
Jun 2018
Sep 2018
May 2018
trimEnd() ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﺘﺷﺭ
trimEnd()
ﺩﺮﮐ ﻪﻓﺎﺿﺍ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪ ﻝﺎﺜﻣ
let text1 = " Hello World! ";
let text2 = text1.trimEnd();
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Strings</h1>
<h2>The trimEnd() Method</h2>
<p id="demo"></p>
<script>
let text1 = " Hello World! ";
let text2 = text1.trimEnd();
document.getElementById("demo").innerHTML =
"Length text1 = " + text1.length + "<br>Length text2 = " + text2.length;
</script>
</body>
</html>
trimE
Chrome 66
Edge 79
Firefox 61
Safari 12
Opera 50
Apr 2018
Jan 2020
Jun 2018
Sep 2018
May 2018
()fromEntries ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯽﺷ
fromEntries()
ﺩﺮﮐ ﻪﻓﺎﺿﺍ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭ ﻝﺎﺜﻣ
const fruits = [
["apples", 300],
["pears", 900],
["bananas", 500]
];
const myObj = Object.fromEntries(fruits);
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Objects</h1>
<h2>The fromEntries() Method</h2>
<p>The number of pears are:</p>
<p id="demo"></p>
<script>
const fruits = [
["apples", 300],
["pears", 900],
["bananas", 500]
];
const myObj = Object.fromEntries(fruits);
document.getElementById("demo").innerHTML = myObj.pears;
</script>
</body>
</html>
fromE
Chrome 73
Edge 79
Firefox 63
Safari 12.1
Opera 60
Mar 2019
Jan 2020
Oct 2018
Mar 2019
Apr 2019
ﯼﺭﺎﯿﺘﺧﺍ ﺪﯿﺻ
ﻝﺎﺜﻣ
try {
// code
} catch (err) {
// code
}
try {
// code
} catch {
// code
}
Chrome 66
Edge 79
Firefox 58
Safari 11.1
Opera 53
Apr 2018
Jan 2020
Jan 2018
Mar 2018
May 2018
()flat ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﯾﺍﺭﺁ
flat()
ﺩﺮﮐ ﻪﻓﺎﺿﺍ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﺑ ﺍﺭ ﻝﺎﺜﻣ
const myArr = [[1,2],[3,4],[5,6]];
const newArr = myArr.flat();
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The flat() Method</h2>
<p id="demo"></p>
<script>
const myArr = [[1,2],[3,4],[5,6]];
const newArr = myArr.flat();
document.getElementById("demo").innerHTML = newArr;
</script>
</body>
</html>
flat()
ﺩﻮﺷ ﯽﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ ﻥﺭﺪﻣ ﯼﺎﻫﺮﮔﺭﻭ
Chrome 69
Edge 79
Firefox 62
Safari 12
Opera 56
Sep 2018
Jan 2020
Sep 2018
Sep 2018
Sep 2018
()flatMap ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﯾﺍﺭﺁ
flatMap()
ﺩﺮﮐ ﻪﻓﺎﺿﺍ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﺑflatMap()
ﻝﺎﺜﻣ
const myArr = [1, 2, 3, 4, 5, 6];
const newArr = myArr.flatMap((x) => x * 2);
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The flatMap() Method</h2>
<p id="demo"></p>
<script>
const myArr = [1, 2, 3, 4, 5,6];
const newArr = myArr.flatMap((x) => x * 2);
document.getElementById("demo").innerHTML = newArr;
</script>
</body>
</html>
()ﺭﺍﺪﯾﺎﭘ ﻪﯾﺍﺭﺁ ﯼﺯﺎﺳ ﺐﺗﺮﻣ
sort()
ﺍﺭ ﺩﺮﮐ ﯽﻨﯿﺑﺯﺎﺑ. ﻝﺎﺜﻣ
const myArr = [
{name:"X00",price:100 },
{name:"X01",price:100 },
{name:"X02",price:100 },
{name:"X03",price:100 },
{name:"X04",price:110 },
{name:"X05",price:110 },
{name:"X06",price:110 },
{name:"X07",price:110 }
];
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Stable Sort</h1>
<p>From ES2019, browsers must use a stable sorting algorithm.</p>
<p>When sorting elements on a key, the elements must keep their relative position to other objects with the same key.</p>
<p id="demo"></p>
<script>
const myArr = [
{name:"X00",price:100 },
{name:"X01",price:100 },
{name:"X02",price:100 },
{name:"X03",price:100 },
{name:"X04",price:110 },
{name:"X05",price:110 },
{name:"X06",price:110 },
{name:"X07",price:110 },
{name:"X08",price:120 },
{name:"X09",price:120 },
{name:"X10",price:120 },
{name:"X11",price:120 },
{name:"X12",price:130 },
{name:"X13",price:130 },
{name:"X14",price:130 },
{name:"X15",price:130 },
{name:"X16",price:140 },
{name:"X17",price:140 },
{name:"X18",price:140 },
{name:"X19",price:140 }
];
myArr.sort( (p1, p2) => {
if (p1.price < p2.price) return -1;
if (p1.price > p2.price) return 1;
return 0;
});
let txt = "";
myArr.forEach(myFunction);
function myFunction(value) {
txt += value.name + " " + value.price + "<br>";
}
document.getElementById("demo").innerHTML = txt;
</script>
</body>
</html>
X01 100
X03 100
X00 100
X03 100
X05 110
X04 110
X06 110
X07 110
JSON.stringify() ﻩﺪﺷ ﺮﻈﻧ ﺪﯾﺪﺠﺗ
stringify()
ﺍﺭ ﺩﺮﮐ ﯽﻨﯿﺑﺯﺎﺑ. ﻝﺎﺜﻣ
let text = JSON.stringify("\u26D4");
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript JSON</h1>
<h2>Revised stringify()</h2>
<p id="demo"></p>
<script>
let text = JSON.stringify("\u26D4");
document.getElementById("demo").innerHTML = JSON.parse(text);
</script>
</body>
</html>
JSON.stringify()
ﺎﺑ ﻦﻤﯾﺍ ﺭﻮﻃ ﻝﺎﺜﻣ
// This is valid in ES2019:
let text = "\u2028";
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Strings</h1>
<p>From ES2019, line and paragraph separator symbols (\u2028 and \u2029) are allowed in string literals:</p>
<p id="demo"></p>
<script>
let text = "\u2028";
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>
ﺪﯿﺷﺎﺑ ﻪﺘﺷﺍﺩ ﻪﺟﻮﺗ
()toString ﻩﺪﺷ ﺡﻼﺻﺍ ﻊﺑﺎﺗ
toString()
ﺍﺭ ﺩﺮﮐ ﯽﻨﯿﺑﺯﺎﺑ.t
ﻝﺎﺜﻣ
function myFunction(p1, p2) {
return p1 * p2;
}
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Functions</h1>
<h2>The toString() Method</h2>
<p>The toString() method returns the function as a string:</p>
<p id="demo"></p>
<script>
function myFunction(a, b) {
return a * b;
}
document.getElementById("demo").innerHTML = myFunction.toString();
</script>
</body>
</html>