ECMAScript 2015 ﺩﻮﺑ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻩﺪﻤﻋ ﺶﯾﺍﺮﯾﻭ ﻦﯿﻣﻭﺩ.
ECMAScript 2015 ﯼﺎﻫ ﻡﺎﻧ ﺎﺑ ES6 ﻭ ECMAScript 6 ﺩﻮﺷ ﯽﻣ ﻪﺘﺧﺎﻨﺷ ﺰﯿﻧ.
.ﺪﻫﺩ ﯽﻣ ﺢﯿﺿﻮﺗ ﺍﺭ ES6 ﯼﺎﻫ ﯽﮔﮋﯾﻭ ﻦﯾﺮﺘﻤﻬﻣ ﻞﺼﻓ ﻦﯾﺍ
let ﯼﺪﯿﻠﮐ ﻪﻤﻠﮐ
const ﯼﺪﯿﻠﮐ ﻪﻤﻠﮐ
ﻥﺎﮑﯿﭘ ﻊﺑﺍﻮﺗ
ﺭﻮﺗﺍﺮﭘﺍ
ﺯﺍ/ﯼﺍﺮﺑ
ﻪﺸﻘﻧ ءﺎﯿﺷﺍ
ءﺎﯿﺷﺍ ﻢﯿﻈﻨﺗ
ﺎﻫ ﺱﻼﮐ
ﺎﻫ ﻩﺪﻋﻭ
ﻞﺒﻤﺳ
ﺽﺮﻓ ﺶﯿﭘ ﯼﺎﻫﺮﺘﻣﺍﺭﺎﭘ
ﻊﺑﺎﺗ ﺖﺣﺍﺮﺘﺳﺍ ﺮﺘﻣﺍﺭﺎﭘ
String.includes()
String.startsWith()
String.endsWith()
Array.from()
() ﻪﯾﺍﺭﺁ ﯼﺎﻫﺪﯿﻠﮐ
() ﻪﯾﺍﺭﺁ ﻦﺘﻓﺎﯾ
()findIndex ﻪﯾﺍﺭﺁ
ﯽﺿﺎﯾﺭ ﺪﯾﺪﺟ ﯼﺎﻫ ﺵﻭﺭ
ﺪﯾﺪﺟ ﻩﺭﺎﻤﺷ ﯼﺎﻫ ﯽﮔﮋﯾﻭ
ﺩﺍﺪﻋﺍ ﺪﯾﺪﺟ ﯼﺎﻫ ﺵﻭﺭ
ﯽﻧﺎﻬﺟ ﺪﯾﺪﺟ ﯼﺎﻫ ﺵﻭﺭ
ﯽﺷ ﯼﺎﻫ ﯼﺩﻭﺭﻭ
ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫ ﻝﻭﮊﺎﻣ
Safari 10 ﻭ Edge 14 ﺯﺍ ﻞﻣﺎﮐ ﺭﻮﻃ ﻪﺑ ﻪﮐ ﺪﻧﺩﻮﺑ ﯽﯾﺎﻫﺮﮔﺭﻭﺮﻣ ﻦﯿﻟﻭﺍ ES6 ﺪﻧﺩﺮﮐ ﯽﻧﺎﺒﯿﺘﺸﭘ:
Chrome 58 | Edge 14 | Firefox 54 | Safari 10 | Opera 55 |
Jan 2017 | Aug 2016 | Mar 2017 | Jul 2016 | Aug 2018 |
ﺎﺑ ﺍﺭ ﺮﯿﻐﺘﻣ ﮏﯾ ﺪﻫﺩ ﯽﻣ ﻥﺎﮑﻣﺍ ﺎﻤﺷ ﻪﺑ let
ﯼﺪﯿﻠﮐ ﻪﻤﻠﮐ
var x = 10;
// Here x is 10
{
let x = 2;
// Here x is 2
}
// Here x is 10
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>Redeclaring a Variable Using let</h2>
<p id="demo"></p>
<script>
let x = 10;
// Here x is 10
{
let x = 2;
// Here x is 2
}
// Here x is 10
document.getElementById("demo").innerHTML = x;
</script>
</body>
</html>
.JavaScript Let :ﺶﺨﺑ ﺭﺩ let
ﺩﺭﻮﻣ ﺭﺩ ﺮﺘﺸﯿﺑ ﺕﺎﻋﻼﻃﺍ
ﮏﯾ) ﺖﺑﺎﺛ ﮏﯾ ﺪﻫﺩ ﯽﻣ ﻥﺎﮑﻣﺍ ﺎﻤﺷ ﻪﺑ const
ﯼﺪﯿﻠﮐ ﻪﻤﻠﮐ
.ﺩﺍﺩ ﺮﯿﯿﻐﺗ ﻥﺍﻮﺗ ﯽﻤﻧ ﺍﺭ ﺭﺍﺪﻘﻣ ﻪﮐ ﺕﻭﺎﻔﺗ ﻦﯾﺍ ﺎﺑ ،ﺪﻨﺘﺴﻫ let ﯼﺎﻫﺮﯿﻐﺘﻣ ﻪﺑ ﻪﯿﺒﺷ ﺎﻫ ﺖﺑﺎﺛ
var x = 10;
// Here x is 10
{
const x = 2;
// Here x is 2
}
// Here x is 10
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>Declaring a Variable Using const</h2>
<p id="demo"></p>
<script>
var x = 10;
// Here x is 10
{
const x = 2;
// Here x is 2
}
// Here x is 10
document.getElementById("demo").innerHTML = x;
</script>
</body>
</html>
.ﺪﯿﻧﺍﻮﺨﺑ ﺮﺘﺸﯿﺑ JavaScript Const :ﺶﺨﺑ ﺭﺩ const
ﻩﺭﺎﺑﺭﺩ
.ﺪﻫﺩ ﯽﻣ ﻩﺯﺎﺟﺍ ﻊﺑﺎﺗ ﺕﺍﺭﺎﺒﻋ ﻦﺘﺷﻮﻧ ﯼﺍﺮﺑ ﻩﺎﺗﻮﮐ ﻮﺤﻧ ﮏﯾ ﻥﺎﮑﯿﭘ ﻊﺑﺍﻮﺗ
ﻭ return
ﯼﺪﯿﻠﮐ ﻪﻤﻠﮐ ،funct
// ES5
var x = function(x, y) {
return x * y;
}
// ES6
const x = (x, y) => x * y;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Arrow Functions</h2>
<p>With arrow functions, you don't have to type the function keyword, the return keyword, and the curly brackets.</p>
<p>Arrow functions are not supported in IE11 or earlier.</p>
<p id="demo"></p>
<script>
const x = (x, y) => x * y;
document.getElementById("demo").innerHTML = x(5, 5);
</script>
</body>
</html>
.ﺪﻧﺭﺍﺪﻧ ﺍﺭ ﺩﻮﺧ ﻦﯾﺍ<"code class="w3-codespan> ﻥﺎﮑﯿﭘ ﻊﺑﺍﻮﺗ
.ﺪﻧﻮﺷ ﻒﯾﺮﻌﺗ ﻩﺩﺎﻔﺘﺳﺍ ﺯﺍ ﻞﺒﻗ ﺪﯾﺎﺑ ﺎﻬﻧﺁ .ﺪﻧﻮﺷ ﯽﻤﻧ ﺪﻨﻠﺑ ﻥﺎﮑﯿﭘ ﻊﺑﺍﻮﺗ
const
ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ ﺎﺑ
.ﺪﺷﺎﺑ ﺪﺣﺍﻭ ﺕﺭﺎﺒﻋ ﮏﯾ ﻊﺑﺎﺗ ﻪﮐ ﺪﯿﻨﮐ ﻑﺬﺣ ﺍﺭ ﯼﺮﻓﺮﻓ ﯼﺎﻫﺖﮐﺍﺮﺑ ﻭ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ ﻝﺎﺜﻣ
const x = (x, y) => { return x * y };
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Arrow Functions</h2>
<p>Arrow functions are not supported in IE11 or earlier.</p>
<p id="demo"></p>
<script>
const x = (x, y) => { return x * y };
document.getElementById("demo").innerHTML = x(5, 5);
</script>
</body>
</html>
.ﺪﯾﺯﻮﻣﺎﯿﺑ ﺮﺘﺸﯿﺑ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻥﺎﮑﯿﭘ ﻊﺑﺎﺗ :ﻞﺼﻓ ﺭﺩ ﻥﺎﮑﯿﭘ ﻊﺑﺍﻮﺗ ﻩﺭﺎﺑﺭﺩ
:ﺪﻫﺩ ﯽﻣ ﺵﺮﺘﺴﮔ ﯼﺮﺘﺸﯿﺑ ﺮﺻﺎﻨﻋ ﻪﺑ ﺍﺭ (ﻪﯾﺍﺭﺁ ﮏﯾ ﺪﻨﻧﺎﻣ) ﺮﯾﺬﭘ ﺭﺍﺮﮑﺗ ﮏﯾ ... ﺮﮕﻠﻤﻋ
const q1 = ["Jan", "Feb", "Mar"];
const q2 = ["Apr", "May", "Jun"];
const q3 = ["Jul", "Aug", "Sep"];
const q4 = ["Oct", "Nov", "May"];
const year = [...q1, ...q2, ...q3, ...q4];
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Operators</h1>
<h2>The ... Operator</h2>
<p>The "spread" operator spreads elements of iterable objects:</p>
<p id="demo"></p>
<script>
const q1 = ["Jan", "Feb", "Mar"];
const q2 = ["Apr", "May", "Jun"];
const q3 = ["Jul", "Aug", "Sep"];
const q4 = ["Oct", "Nov", "May"];
const year = [...q1, ...q2, ...q3, ...q4];
document.getElementById("demo").innerHTML = year;
</script>
</body>
</html>
:ﺩﺮﮐ ﻩﺩﺎﻔﺘﺳﺍ ﻊﺑﺎﺗ ﯽﻧﺍﻮﺧﺍﺮﻓ ﯼﺍﺮﺑ ﺮﺘﺸﯿﺑ ﯼﺎﻫ ﻥﺎﻣﻮﮔﺭﺁ ﻪﺑ ﺮﯾﺬﭘ ﺭﺍﺮﮑﺗ ﮏﯾ ﺵﺮﺘﺴﮔ ﯼﺍﺮﺑ ﻥﺍﻮﺗ ﯽﻣ
const numbers = [23,55,21,87,56];
let maxValue = Math.max(...numbers);
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Operators</h1>
<h2>The ... Operator</h2>
<p>The "Spread" operator can be used to expand an iterable into more arguments for function calls:</p>
<p id="demo"></p>
<script>
const numbers = [23,55,21,87,56];
let maxValue = Math.max(...numbers);
document.getElementById("demo").innerHTML = maxValue;
</script>
</body>
</html>
ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ for/of
ﺕﺭﺎﺒﻋ ﯼﺎﻫ ﻪﻘﻠﺣ
for/of
ﺪﯿﻧﺰﺑ ﻪﻘﻠﺣ ﻩﺩﺍﺩ ﯼﺎﻫﺭﺎﺘﺧﺎﺳ ﯼﻭﺭ ﻪﮐ ﺪﻫﺩ ﯽﻣ ﺍﺭ ﻥﺎ
:ﺖﺳﺍ ﺮﯾﺯ ﻮﺤﻧ ﯼﺍﺭﺍﺩ for/of
ﻪﻘﻠﺣ
for (variable of iterable) {
// code block to be executed
}
ﺮﯿﻐﺘﻣ - ﺖﺳﺍ ﯼﺪﻌﺑ ﯽﮔﮋﯾﻭ ﺭﺍﺪﻘﻣ ﺭﺍﺮﮑﺗ ﺮﻫ ﯼﺍﺮﺑ
iterable - ﺖﺳﺍ ﺮﯾﺬﭘﺭﺍﺮﮑﺗ ﯼﺎﻬﯿﮔﮋﯾﻭ ﯼﺍﺭﺍﺩ ﻪﮐ ﯽﺌﯿﺷ.
const cars = ["BMW", "Volvo", "Mini"];
let text = "";
for (let x of cars) {
text += x + " ";
}
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript For Of Loop</h2>
<p>The for of statement loops through the values of any iterable object:</p>
<p id="demo"></p>
<script>
const cars = ["BMW", "Volvo", "Mini"];
let text = "";
for (let x of cars) {
text += x + "<br>";
}
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>
let language = "JavaScript";
let text = "";
for (let x of language) {
text += x + " ";
}
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript For Of Loop</h2>
<p>The for of statement loops through the values of an iterable object.</p>
<p id="demo"></p>
<script>
let language = "JavaScript";
let text = "";
for (let x of language) {
text += x + "<br>";
}
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>
.ﺪﯾﺯﻮﻣﺎﯿﺑ ﺮﺘﺸﯿﺑ For/In/Of ﻪﻘﻠﺣ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻞﺼﻓ ﺭﺩ
.ﺖﺳﺍ ﻪﺸﻘﻧ ﻢﻬﻣ ﯼﺎﻫ ﯽﮔﮋﯾﻭ ﺯﺍ ﯽﮑﯾ ﺪﯿﻠﮐ ﮏﯾ ﻥﺍﻮﻨﻋ ﻪﺑ ﯽﺷ ﮏﯾ ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ ﯽﯾﺎﻧﺍﻮﺗ
const fruits = new Map([
["apples", 500],
["bananas", 300],
["oranges", 200]
]);
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Map Objects</h2>
<p>Creating a Map from an Array:</p>
<p id="demo"></p>
<script>
// Create a Map
const fruits = new Map([
["apples", 500],
["bananas", 300],
["oranges", 200]
]);
document.getElementById("demo").innerHTML = fruits.get("apples");
</script>
</body>
</html>
.ﺪﯿﻧﺍﺪﺑ ﺮﺘﺸﯿﺑ ﻪﯾﺍﺭﺁ ﻭ ﻪﺸﻘﻧ ﻦﯿﺑ ﺕﻭﺎﻔﺗ ﻭ ﻪﺸﻘﻧ ءﺎﯿﺷﺍ ﻩﺭﺎﺑﺭﺩ ،ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫ ﻪﺸﻘﻧ :ﺶﺨﺑ
// Create a Set
const letters = new Set();
// Add some values to the Set
letters.add("a");
letters.add("b");
letters.add("c");
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Sets</h2>
<p>Add values to a Set:</p>
<p id="demo"></p>
<script>
// Create a Set
const letters = new Set();
// Add Values to the Set
letters.add("a");
letters.add("b");
letters.add("c");
// Display set.size
document.getElementById("demo").innerHTML = letters.size;
</script>
</body>
</html>
.ﺪﯾﺯﻮﻣﺎﯿﺑ ﺮﺘﺸﯿﺑ ﻢﯿﻈﻨﺗ ءﺎﯿﺷﺍ ﻩﺭﺎﺑﺭﺩ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫ ﻪﻋﻮﻤﺠﻣ ﺶﺨﺑ ﺭﺩ
.ﺪﻨﺘﺴﻫ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ءﺎﯿﺷﺍ ﯼﺍﺮﺑ ﯽﯾﺎﻫ ﺐﻟﺎﻗ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫ ﺱﻼﮐ
.ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ class
ﯼﺪﯿﻠﮐ ﻪﻤﻠﮐ ﺯﺍ ﺱﻼﮐ ﺩﺎﺠﯾﺍ ﯼﺍﺮﺑ
:ﺪﯿﻨﮐ ﻪﻓﺎﺿﺍ constructor()
ﻡﺎﻧ ﻪﺑ ﯽﺷﻭﺭ ﻪﺸﯿﻤﻫ
class ClassName {
constructor() { ... }
}
class Car {
constructor(name, year) {
this.name = name;
this.year = year;
}
}
.ﺪﻨﮐ ﯽﻣ ﺩﺎﺠﯾﺍ "Car" ﻡﺎﻧ ﻪﺑ ﯽﺳﻼﮐ ﻻﺎﺑ ﻝﺎﺜﻣ
."year" ﻭ "name" :ﺖﺳﺍ ﻪﯿﻟﻭﺍ ﯽﮔﮋﯾﻭ ﻭﺩ ﯼﺍﺭﺍﺩ ﺱﻼﮐ
.ﺖﺳﺍ ﺖﺴﯿﻧ ﯽﺷ ﮏﯾ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺱﻼﮐ
.ﺖﺳﺍ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ءﺎﯿﺷﺍ ﯼﺍﺮﺑ ﻮﮕﻟﺍ ﮏﯾ ﻦﯾﺍ
:ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ءﺎﯿﺷﺍ ﺩﺎﺠﯾﺍ ﯼﺍﺮﺑ ﺱﻼﮐ ﺯﺍ ﺪﯿﻧﺍﻮﺗ ﯽﻣ ،ﺪﯾﺭﺍﺩ ﺱﻼﮐ ﮏﯾ ﻪﮐ ﯽﻣﺎﮕﻨﻫ
const myCar1 = new Car("Ford", 2014);
const myCar2 = new Car("Audi", 2019);
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Classes</h1>
<p>Creating two car objects from a car class:</p>
<p id="demo"></p>
<script>
class Car {
constructor(name, year) {
this.name = name;
this.year = year;
}
}
const myCar1 = new Car("Ford", 2014);
const myCar2 = new Car("Audi", 2019);
document.getElementById("demo").innerHTML =
myCar1.name + " " + myCar2.name;
</script>
</body>
</html>
.ﺪﯾﺯﻮﻣﺎﯿﺑ ﺮﺘﺸﯿﺑ ﺎﻫ ﺱﻼﮐ ﻩﺭﺎﺑﺭﺩ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫ ﺱﻼﮐ :ﺶﺨﺑ ﺭﺩ
Promise ﺪﻫﺩ ﯽﻣ ﺪﻧﻮﯿﭘ ﺍﺭ "ﯽﻓﺮﺼﻣ ﺪﮐ" ﻭ "ﺪﮐ ﺪﯿﻟﻮﺗ" ﻪﮐ ﺖﺳﺍ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯽﺷ ﮏﯾ.
.ﺪﺷﺎﺑ ﻪﺠﯿﺘﻧ ﺮﻈﺘﻨﻣ ﺪﯾﺎﺑ "ﻩﺪﻨﻨﮐ ﻑﺮﺼﻣ ﺪﮐ" ﻭ ﺪﺸﮑﺑ ﻝﻮﻃ ﯽﻤﮐ ﺖﺳﺍ ﻦﮑﻤﻣ "ﺪﮐ ﺪﯿﻟﻮﺗ"
const myPromise = new Promise(function(myResolve, myReject) {
// "Producing Code" (May take some time)
myResolve(); // when successful
myReject(); // when error
});
// "Consuming Code" (Must wait for a fulfilled Promise).
myPromise.then(
function(value) { /* code if successful */ },
function(error) { /* code if some error */ }
);
const myPromise = new Promise(function(myResolve, myReject) {
setTimeout(function() { myResolve("I love You !!"); }, 3000);
});
myPromise.then(function(value) {
document.getElementById("demo").innerHTML = value;
});
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Promise</h2>
<p>Wait 3 seconds (3000 milliseconds) for this page to change.</p>
<h1 id="demo"></h1>
<script>
const myPromise = new Promise(function(myResolve, myReject) {
setTimeout(function(){ myResolve("I love You !!"); }, 3000);
});
myPromise.then(function(value) {
document.getElementById("demo").innerHTML = value;
});
</script>
</body>
</html>
.ﺪﯾﺯﻮﻣﺎﯿﺑ ﺮﺘﺸﯿﺑ Promises ﻩﺭﺎﺑﺭﺩ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫ ﻩﺪﻋﻭ ﺶﺨﺑ ﺭﺩ
.Boolean ﺎﯾ Number، String ﺪﻨﻧﺎﻣ ﺖﺳﺭﺩ ﺖﺳﺍ ﻪﯿﻟﻭﺍ ﻩﺩﺍﺩ ﻉﻮﻧ ﮏﯾ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺩﺎﻤﻧ
.ﺪﻨﮐ ﺍﺪﯿﭘ ﯽﺳﺮﺘﺳﺩ ﻥﺁ ﻪﺑ ﯽﻓﺩﺎﺼﺗ ﺭﻮﻃ ﻪﺑ ﺪﻧﺍﻮﺗ ﯽﻤﻧ ﯼﺮﮕﯾﺩ ﺪﮐ ﭻﯿﻫ ﻪﮐ ﺪﻫﺩ ﯽﻣ ﻥﺎﺸﻧ ﺍﺭ ﺩﺮﻓ ﻪﺑ
،ﺪﻨﻨﮐ ﻪﻓﺎﺿﺍ ﺚﻟﺎﺛ ﺺﺨﺷ ﺪﮐ ﮏﯾ ﻪﺑ ﻖﻠﻌﺘﻣ ﺺﺨﺷ ﯽﺷ ﮏﯾ ﻪﺑ ﺍﺭ person.id ﯽﮔﮋﯾﻭ ﮏﯾ ﺪﻨﻫﺍﻮﺨﺑ ﻒﻠﺘﺨﻣ
:ﺪﻨﮐ ﯽﻣ ﻞﺣ ﺍﺭ ﻞﮑﺸﻣ ﻦﯾﺍ ،ﺩﺮﻓ ﻪﺑ ﺮﺼﺤﻨﻣ ﻪﺳﺎﻨﺷ ﮏﯾ ﺩﺎﺠﯾﺍ ﯼﺍﺮﺑ()Symbol ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ ﺎﺑ
const person = {
firstName: "John",
lastName: "Doe",
age: 50,
eyeColor: "blue"
};
let id = Symbol('id');
person[id] = 140353;
// Now person[id] = 140353
// but person.id is still undefined
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>Using JavaScript Symbol()</h2>
<p id="demo"></p>
<script>
const person = {
firstName: "John",
lastName: "Doe",
age: 50,
eyeColor: "blue"
};
let id = Symbol('id');
person[id] = 140353;
document.getElementById("demo").innerHTML = person[id] + " " + person.id;
</script>
</body>
</html>
.ﺪﻨﺘﺴﻫ ﺩﺮﻓ ﻪﺑ ﺮﺼﺤﻨﻣ ﻪﺸﯿﻤﻫ ﺎﻫﺩﺎﻤﻧ
:ﺖﺷﺍﺩ ﺪﻨﻫﺍﻮﺧ ﯽﺗﻭﺎﻔﺘﻣ ﺮﯾﺩﺎﻘﻣ ،ﺪﯿﻨﮐ ﺩﺎﺠﯾﺍ ﻥﺎﺴﮑﯾ ﺕﺎﺤﯿﺿﻮﺗ ﺎﺑ ﺩﺎﻤﻧ ﻭﺩ ﺮﮔﺍ
Symbol("id") == Symbol("id"); // false
ES6 ﺪﻨﺷﺎﺑ ﻪﺘﺷﺍﺩ ﺽﺮﻓ ﺶﯿﭘ ﺮﯾﺩﺎﻘﻣ ﺎﺗ ﺪﻫﺩ ﯽﻣ ﻩﺯﺎﺟﺍ ﻊﺑﺎﺗ ﯼﺎﻫﺮﺘﻣﺍﺭﺎﭘ ﻪﺑ.
function myFunction(x, y = 10) { // y is 10 if not passed or undefined return x + y;
}
myFunction(5); // will return 15
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Functions</h1>
<h2>Default Parameter Values</h2>
<p>If y is not passed or undefined, then y = 10:</p>
<p id="demo"></p>
<script>
function myFunction(x, y = 10) {
return x + y;
}
document.getElementById("demo").innerHTML = myFunction(5);
</script>
</body>
</html>
:ﺩﺮﯿﮕﺑ ﺮﻈﻧ ﺭﺩ ﻪﯾﺍﺭﺁ ﮏﯾ ﻥﺍﻮﻨﻋ ﻪﺑ ﺍﺭ ﺎﻫ ﻥﺎﻣﻮﮔﺭﺁ ﺯﺍ ﯼﺩﻭﺪﺤﻣﺎﻧ ﺩﺍﺪﻌﺗ ﺎﺗ ﺪﻫﺩ ﯽﻣ ﻩﺯﺎﺟﺍ ﻊﺑﺎﺗ
function sum(...args) {
let sum = 0;
for (let arg of args) sum += arg;
return sum;
}
let x = sum(4, 9, 16, 25, 29, 100, 66, 77);
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Functions</h1>
<h2>The Rest Parameter</h2>
<p>The rest parameter (...) allows a function to treat an indefinite number of arguments as an array:</p>
<p id="demo"></p>
<script>
function sum(...args) {
let sum = 0;
for (let arg of args) sum += arg;
return sum;
}
let x = sum(4, 9, 16, 25, 29, 100, 66, 77);
document.getElementById("demo").innerHTML = x;
</script>
</body>
</html>
.ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧincludes()
ﻝﺎﺜﻣ
let text = "Hello world, welcome to the universe.";
text.includes("world") // Returns true
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Strings</h1>
<h2>The includes() Method</h2>
<p>Check if a string includes "world":</p>
<p id="demo"></p>
<p>The includes() method is not supported in Internet Explorer.</p>
<script>
let text = "Hello world, welcome to the universe.";
document.getElementById("demo").innerHTML = text.includes("world");
</script>
</body>
</html>
ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧstartsWith()
ﻝﺎﺜﻣ
let text = "Hello world, welcome to the universe.";
text.startsWith("Hello") // Returns true
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Strings</h1>
<h2>The startsWith() Method</h2>
<p>Check if a string starts with "Hello":</p>
<p id="demo"></p>
<p>The startsWith() method is not supported in Internet Explorer.</p>
<script>
let text = "Hello world, welcome to the universe.";
document.getElementById("demo").innerHTML = text.startsWith("Hello");
</script>
</body>
</html>
ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ .ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﻝﻮﻃ ﺎﺑ ﯽﺷ ﺮﻫ ﺯﺍ ﺍﺭ ﻪﯾﺍﺭﺁ ﯽﺷ ﮏﯾ :ﻪﺘﺷﺭ ﮏﯾ ﺯﺍ ﻪﯾﺍﺭﺁ ﮏﯾ ﺩﺎﺠﯾﺍ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ .ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﻪﯾﺍﺭﺁ ﮏﯾ ﯼﺎﻫﺪﯿﻠﮐ ﺎﺑ ﺍﺭ Array Iterator ﯽﺷ ﮏﯾ :ﺖﺳﺍ ﻪﯾﺍﺭﺁ ﯼﺎﻫﺪﯿﻠﮐ ﯼﻭﺎﺣ ﻪﮐ ﺪﯿﻨﮐ ﺩﺎﺠﯾﺍ Array Iterator ﯽﺷ ﮏﯾ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ .ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ ﯼﺍ ﻪﯾﺍﺭﺁ ﺮﺼﻨﻋ ﻦﯿﻟﻭﺍ ﺭﺍﺪﻘﻣ ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ ( ﺭﺍﺪﻘﻣ) ﺪﻨﮐ ﯽﻣ ﺍﺪﯿﭘ ﺍﺭ ﺮﺘﮔﺭﺰﺑ ﺮﺼﻨﻋ ﻦﯿﻟﻭﺍ ﻝﺎﺜﻣ ﻦﯾﺍ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺩﺮﯿﮔ ﯽﻣ ﻥﺎﻣﻮﮔﺭﺁ 3 ﻊﺑﺎﺗ ﻪﮐ ﺪﯿﺷﺎﺑ ﻪﺘﺷﺍﺩ ﻪﺟﻮﺗ ﺩﺭﻮﻣ ﺵﺯﺭﺍ ﻢﺘﯾﺁ ﺺﺧﺎﺷ ﻪﯾﺍﺭﺁ ﺩﻮﺧ .ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ ﻪﯾﺍﺭﺁ ﺮﺼﻨﻋ ﻦﯿﻟﻭﺍ ﺲﮐﺪﻨﯾﺍ :ﺪﻨﮐ ﯽﻣ ﺍﺪﯿﭘ ﺖﺳﺍ 18 ﺯﺍ ﺮﺘﮔﺭﺰﺑ ﻪﮐ ﺍﺭ ﺮﺼﻨﻋ ﻦﯿﻟﻭﺍ ﺺﺧﺎﺷ ﻝﺎﺜﻣ ﻦﯾﺍ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺩﺮﯿﮔ ﯽﻣ ﻥﺎﻣﻮﮔﺭﺁ 3 ﻊﺑﺎﺗ ﻪﮐ ﺪﯿﺷﺎﺑ ﻪﺘﺷﺍﺩ ﻪﺟﻮﺗ ﺩﺭﻮﻣ ﺵﺯﺭﺍ ﻢﺘﯾﺁ ﺺﺧﺎﺷ ﻪﯾﺍﺭﺁ ﺩﻮﺧ ES6 ﯽﺷ ﻪﺑ ﺍﺭ ﺮﯾﺯ ﯼﺎﻫﺪﺘﻣ Math ﺩﺮﮐ ﻪﻓﺎﺿﺍ: → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ ES6 ﯽﺷ ﻪﺑ ﺍﺭ ﺮﯾﺯ ﯼﺎﻫ ﯽﮔﮋﯾﻭ Number ﺩﺮﮐ ﻪﻓﺎﺿﺍ: → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ ES6 2 ﯽﺷ ﻪﺑ ﺍﺭ ﺪﯾﺪﺟ ﺵﻭﺭ Number ﺩﺮﮐ ﻪﻓﺎﺿﺍ: .ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ .ﺩﻮﺷ ﻩﺩﺍﺩ ﺶﯾﺎﻤﻧ ﺮﺑﺍﺮﺑ ﻭﺩ ﻖﯿﻗﺩ ﺩﺪﻋ ﮏﯾ ﻥﺍﻮﻨﻋ ﻪﺑ ﺪﻧﺍﻮﺗ ﯽﻣ ﺎﻘﯿﻗﺩ ﻪﮐ ﺖﺳﺍ ﺢﯿﺤﺻ ﺩﺪﻋ ﮏﯾ ﻦﻤﯾﺍ .ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ ES6 2 ﺩﺮﮐ ﻪﻓﺎﺿﺍ ﺪﯾﺪﺟ ﯽﻧﺎﻬﺟ ﺩﺍﺪﻋﺍ ﺵﻭﺭ: . :ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺪﯿﻨﮐ ﺭﺍﺮﮑﺗ ﺭﺍﺪﻘﻣ/ﺪﯿﻠﮐ ﯼﺎﻫ ﺖﻔﺟ ﯼﻭﺭ ﺲﭙﺳ ﻭ ﺪﯿﻨﮐ ﺩﺎﺠﯾﺍ Array Iterator ﮏﯾ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺭﺍﺪﻘﻣ/ﺪﯿﻠﮐ ﯼﺎﻫﺖﻔﺟ ﺎﺑ ﺍﺭ Array Iterator ءﯽﺷ ﮏﯾ .ﺪﻫﺩ ﯽﻤﻧ ﺮﯿﯿﻐﺗ ﺍﺭ ﯽﻠﺻﺍ ﻪﯾﺍﺭﺁ :ﺪﻧﻮﺷ ﯽﻣ ﺩﺭﺍﻭ ﻒﻠﺘﺨﻣ ﺵﻭﺭ ﻭﺩ ﻪﺑ ﺎﻫ ﻝﻭﮊﺎﻣ :ﺪﯿﻨﮐ ﺩﺭﺍﻭ person.js ﻞﯾﺎﻓ ﺯﺍ ﺍﺭ ﻡﺎﻧ ﺎﺑ ﺕﺍﺭﺩﺎﺻ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺪﯿﻨﮐ ﺩﺭﺍﻭ message.js ﻞﯾﺎﻓ ﺯﺍ ﺍﺭ ﺽﺮﻓ ﺶﯿﭘ ﺕﺍﺭﺩﺎﺻ ﮏﯾ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ .ﺪﯾﺯﻮﻣﺎﯿﺑ ﺮﺘﺸﯿﺑ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫ ﻝﻭﮊﺎﻣ :ﺭﺩ ﺎﻫ ﻝﻭﮊﺎﻣ ﻩﺭﺎﺑﺭﺩendsWith()
ﻝﺎﺜﻣ
var text = "John Doe";
text.endsWith("Doe") // Returns true
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Strings</h2>
<p>Check if a string ends with "Doe":</p>
<p id="demo"></p>
<p>The endsWith() method is not supported in Internet Explorer.</p>
<script>
let text = "John Doe";
document.getElementById("demo").innerHTML = text.endsWith("Doe");
</script>
</body>
</html>
Array.from()
Array.from()
ﻝﺎﺜﻣ
Array.from("ABCDEFG") // Returns [A,B,C,D,E,F,G]
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The from() Method</h2>
<p>Return an array object from any object with a length property or any iterable object.</p>
<p id="demo"></p>
<script>
const myArr = Array.from("ABCDEFG");
document.getElementById("demo").innerHTML = myArr;
</script>
<p>The Array.from() method is not supported in Internet Explorer.</p>
</body>
</html>
() ﻪﯾﺍﺭﺁ ﯼﺎﻫﺪﯿﻠﮐ
ke
ﻝﺎﺜﻣ
const fruits = ["Banana", "Orange", "Apple", "Mango"];
const keys = fruits.keys();
let text = "";
for (let x of keys) {
text += x + "<br>";
}
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The keys() Method</h2>
<p>Return an Array Iterator object with the keys of the array:</p>
<p id="demo"></p>
<script>
const fruits = ["Banana", "Orange", "Apple", "Mango"];
const keys = fruits.keys();
let text = "";
for (let x of keys) {
text += x + "<br>";
}
document.getElementById("demo").innerHTML = text;
</script>
<p>Array.keys() is not supported in Internet Explorer.</p>
</body>
</html>
() ﻪﯾﺍﺭﺁ ﻦﺘﻓﺎﯾ
find()
ﺪﺘﻣ ﻝﺎﺜﻣ
const numbers = [4, 9, 16, 25, 29];
let first =
numbers.find(myFunction);
function myFunction(value, index, array) {
return
value > 18;
}
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The find() Method</h2>
<p id="demo"></p>
<script>
const numbers = [4, 9, 16, 25, 29];
let first = numbers.find(myFunction);
document.getElementById("demo").innerHTML = "First number over 18 is " + first;
function myFunction(value, index, array) {
return value > 18;
}
</script>
</body>
</html>
()findIndex ﻪﯾﺍﺭﺁ
findIndex()
ﻝﺎﺜﻣ
const numbers = [4, 9, 16, 25, 29];
let first =
numbers.findIndex(myFunction);
function myFunction(value, index, array) {
return
value > 18;
}
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The findIndex() Method</h2>
<p id="demo"></p>
<script>
const numbers = [4, 9, 16, 25, 29];
document.getElementById("demo").innerHTML = "First number over 18 has index " + numbers.findIndex(myFunction);
function myFunction(value, index, array) {
return value > 18;
}
</script>
</body>
</html>
ﯽﺿﺎﯾﺭ ﺪﯾﺪﺟ ﯼﺎﻫ ﺵﻭﺭ
Math.trunc()
Math.sign()
Math.cbrt()
Math.log2()
Math.log10()
.()Math.trunc ﺪﺘﻣ
Math.trunc(x)
ﺢﯿﺤﺻ ﺖﻤﺴﻗ x ﯽﻣﺮﺑ ﺍﺭﺪﻧﺍﺩﺮﮔ: ﻝﺎﺜﻣ
Math.trunc(4.9); // returns 4
Math.trunc(4.7); // returns 4
Math.trunc(4.4); // returns 4
Math.trunc(4.2); // returns 4
Math.trunc(-4.2); // returns -4
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Math.trunc()</h2>
<p>Math.trunc(x) returns the integer part of x:</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = Math.trunc(4.7);
</script>
</body>
</html>
.()Math.sign ﺪﺘﻣ
Math.sign(x)
،ﺪﺷﺎﺑ ﺖﺒﺜﻣ ﺎﯾ ﯽﻬﺗ ،ﯽﻔﻨ ﻝﺎﺜﻣ
Math.sign(-4); // returns -1
Math.sign(0); // returns 0
Math.sign(4); // returns 1
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Math.sign()</h2>
<p>Math.sign(x) returns if x is negative, null or positive:</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = Math.sign(4);
</script>
</body>
</html>
.()Math.cbrt ﺪﺘﻣ
Math.cbrt(x)
ﺐﻌﮑﻣ ﻪﺸﯾﺭ x ﯽﻣﺮﺑ ﺍﺭﺪﻧﺍﺩﺮﮔ: ﻝﺎﺜﻣ
Math.cbrt(8); // returns 2
Math.cbrt(64); // returns 4
Math.cbrt(125); // returns 5
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Math.cbrt()</h2>
<p>Math.cbrt(x) returns the cube root of x:</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = Math.cbrt(8);
</script>
</body>
</html>
.()Math.log2 ﺪﺘﻣ
Math.log2(x)
2 ﻪﯾﺎﭘ ﻢﺘﯾﺭﺎﮕﻟ x ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ: ﻝﺎﺜﻣ
Math.log2(2); // returns 1
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Math.log2()</h2>
<p>Math.log2() returns the base 2 logarithm of a number.</p>
<p>How many times must we multiply 2 to get 8?</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = Math.log2(8);
</script>
</body>
</html>
.()Math.log10 ﺵﻭﺭ
Math.log10(x)
10 ﻪﯾﺎﭘ ﻢﺘﯾﺭﺎﮕﻟ x ﯽﻣﺮﺑ ﺍﺭﺪﻧﺍﺩﺮﮔ: ﻝﺎﺜﻣ
Math.log10(10); // returns 1
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Math.log10()</h2>
<p>Math.log10() returns the base 10 logarithm of a number.</p>
<p>How many times must we multiply 10 to get 1000?</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = Math.log10(1000);
</script>
</body>
</html>
ﺪﯾﺪﺟ ﻩﺭﺎﻤﺷ ﯼﺎﻫ ﯽﮔﮋﯾﻭ
EPSILON
MIN_SAFE_INTEGER
MAX_SAFE_INTEGER
ﻝﺎﺜﻣ ﻥﻮﻠﯿﺴﭘﺍ
let x = Number.EPSILON;
<!DOCTYPE html>
<html>
<body>
<h2>Number Object Properties</h2>
<p>EPSILON</p>
<p id="demo"></p>
<script>
let x = Number.EPSILON;
document.getElementById("demo").innerHTML = x;
</script>
</body>
</html>
MIN_SAFE_INTEGER ﻝﺎﺜﻣ
let x = Number.MIN_SAFE_INTEGER;
<!DOCTYPE html>
<html>
<body>
<h2>Number Object Properties</h2>
<p>MIN_SAFE_INTEGER</p>
<p id="demo"></p>
<script>
let x = Number.MIN_SAFE_INTEGER;
document.getElementById("demo").innerHTML = x;
</script>
</body>
</html>
MAX_SAFE_INTEGER ﻝﺎﺜﻣ
let x = Number.MAX_SAFE_INTEGER;
<!DOCTYPE html>
<html>
<body>
<h2>Number Object Properties</h2>
<p>MAX_SAFE_INTEGER</p>
<p id="demo"></p>
<script>
let x = Number.MAX_SAFE_INTEGER;
document.getElementById("demo").innerHTML = x;
</script>
</body>
</html>
ﺩﺍﺪﻋﺍ ﺪﯾﺪﺟ ﯼﺎﻫ ﺵﻭﺭ
Number.isInteger()
Number.isSafeInteger()
()Number.isInteger ﺵﻭﺭ
Number.isInteger()
ﻝﺎﺜﻣ
Number.isInteger(10); // returns true
Number.isInteger(10.5); // returns false
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Numbers</h1>
<h2>The isInteger() Method</h2>
<p>The isInteger() method returns true if the argument is an integer.</p>
<p>Otherwise it returns false.</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML =
Number.isInteger(10) + "<br>" + Number.isInteger(10.5);
</script>
</body>
</html>
Number.isSafeInteger() ﺵﻭﺭ
Number.isSafeInteger()
ﻝﺎﺜﻣ
Number.isSafeInteger(10); // returns true
Number.isSafeInteger(12345678901234567890); // returns false
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Numbers</h1>
<h2>The isSafeInteger() Method</h2>
<p>The isSafeInteger() method returns true if the argument is a safe integer.</p>
<p>Otherwise it returns false.</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML =
Number.isSafeInteger(10) + "<br>" + Number.isSafeInteger(12345678901234567890);
</script>
</body>
</html>
.ﺪﻨﺘﺴﻫ (sup>53 - 1>2)+ ﺎﺗ (sup>53 - 1>2)- ﺯﺍ ﺢﯿﺤﺻ ﺩﺍﺪﻋﺍ ﻪﻤﻫ ﻦﻣﺍ ﺢﯿﺤﺻ ﯽﻧﺎﻬﺟ ﺪﯾﺪﺟ ﯼﺎﻫ ﺵﻭﺭ
isFinite()
isNaN()
()isFinite ﺵﻭﺭ
NaN
ﺎﯾ ﺖﯾﺎﻬﻧ ﯽﺑ .ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ
true
ﺕﺭﻮﺻ ﻦﯾﺍ ﺮﯿﻏ ﺭﺩ ﻝﺎﺜﻣ
isFinite(10/0); // returns false
isFinite(10/1); // returns true
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Numbers</h1>
<h2>The isFinite() Method</h2>
<p>The isFinite() method returns false if the argument is Infinity or NaN.</p>
<p>Otherwise it returns true.</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML =
isFinite(10 / 0) + "<br>" + isFinite(10 / 1);
</script>
</body>
</html>
.()isNaN ﺵﻭﺭ
false
ﺕﺭﻮﺻ ﻦﯾﺍ ﺮﯿﻏ ﺭﺩ . ﻝﺎﺜﻣ
isNaN("Hello"); // returns true
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Numbers</h1>
<h2>The isNaN() Method</h2>
<p>The isNan() method returns true if the argument is NaN. Otherwise it returns false.</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML =
isNaN("Hello") + "<br>" + isNaN("10");
</script>
</body>
</html>
() ﯽﺷ ﯼﺎﻫ ﯼﺩﻭﺭﻭ
ﻝﺎﺜﻣ
const fruits = ["Banana", "Orange", "Apple", "Mango"];
const f = fruits.entries();
for (let x of f) {
document.getElementById("demo").innerHTML += x;
}
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The entries() method</h2>
<p>entries() returns an Array Iterator object with key/value pairs:</p>
<p id="demo"></p>
<script>
const fruits = ["Banana", "Orange", "Apple", "Mango"];
const f = fruits.entries();
for (let x of f) {
document.getElementById("demo").innerHTML += x + "<br>";
}
</script>
<p>The entries() method is not supported in Internet Explorer 11 (or earlier).</p>
</body>
</html>
["ﺐﯿﺳ" ،2]
["ﯽﺠﻧﺭﺎﻧ" ،1]
["ﺯﻮﻣ" ،0]entries()
ﺵﻭﺭ ﺎﻫ ﻝﻭﮊﺎﻣ
ﻩﺪﺷ ﯼﺭﺍﺬﮕﻣﺎﻧ ﺕﺍﺭﺩﺎﺻ ﺯﺍ ﺕﺍﺩﺭﺍﻭ
import { name, age } from "./person.js";
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Modules</h1>
<p id="demo"></p>
<script type="module">
import { name, age } from "./person.js";
let text = "My name is " + name + ", I am " + age + ".";
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>
ﺽﺮﻓ ﺶﯿﭘ ﺕﺍﺭﺩﺎﺻ ﺯﺍ ﺕﺍﺩﺭﺍﻭ
import message from "./message.js";
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Modules</h1>
<p id="demo"></p>
<script type="module">
import message from "./message.js";
document.getElementById("demo").innerHTML = message();
</script>
</body>
</html>