:ﺎﻫ ﻑﺩﺍﺮﺘﻣ
ﺐﻟﺎﻗ ﻅﺎﻔﻟﺍ
ﻮﮕﻟﺍ ﯼﺎﻫ ﻪﺘﺷﺭ
ﯼﺍ ﻪﺘﺷﺭ ﯼﺎﻫ ﺐﻟﺎﻗ
Back-Tics ﺲﮑﺘﻨﯿﺳ
Template Literals ﺪﻨﮐ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﻪﺘﺷﺭ ﻒﯾﺮﻌﺗ ﯼﺍﺮﺑ ("") ﻝﻮﻗ ﻞﻘﻧ ﯼﺎﺟ ﻪﺑ (``) ﯽﺘﺸﮔﺮﺑ ﯼﺎﻫ ﮏﯿﺗ ﺯﺍ:
let text = `Hello World!`;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Template Literals</h2>
<p>Template literals use back-ticks (``) to define a string:</p>
<p id="demo"></p>
<p>Template literals are not supported in Internet Explorer.</p>
<script>
let text = `Hello world!`;
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>
:ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﻪﺘﺷﺭ ﮏﯾ ﻞﺧﺍﺩ ﺭﺩ ﻪﻧﺎﮔﻭﺩ ﻭ ﯽﮑﺗ ﻝﻮﻗ ﻞﻘﻧ ﻭﺩ ﺮﻫ ﺯﺍ ﺪﯿﻧﺍﻮﺗ ﯽﻣ ،ﺎﺒﻔﻟﺍ ﯼﻮﮕﻟﺍ ﺎﺑ
let text = `He's often called "Johnny"`;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Template Literals</h2>
<p>With back-ticks, you can use both single and double quotes inside a string:</p>
<p id="demo"></p>
<p>Template literals are not supported in Internet Explorer.</p>
<script>
let text = `He's often called "Johnny"`;
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>
ﻮﮕﻟﺍ ﯼﺎﻫ ﻝﺍﺮﺘﯿﻟ ﺪﻨﮐ ﯽﻣ ﺯﺎﺠﻣ ﺍﺭ ﯽﻄﺧ ﺪﻨﭼ ﯼﺎﻫ ﻪﺘﺷﺭ:
let text =
`The quick
brown fox
jumps over
the lazy dog`;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Template Literals</h2>
<p>Template literals allows multiline strings:</p>
<p id="demo"></p>
<p>Template literals are not supported in Internet Explorer.</p>
<script>
let text =
`The quick
brown fox
jumps over
the lazy dog`;
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>
ﺐﻟﺎﻗ ﺕﺎﺣﻼﻄﺻﺍ ﺪﻨﮐ ﯽﻣ ﻢﻫﺍﺮﻓ ﺎﻫ ﻪﺘﺷﺭ ﺭﺩ ﺕﺍﺭﺎﺒﻋ ﻭ ﺎﻫﺮﯿﻐﺘﻣ ﯽﺑﺎﯾ ﻥﻭﺭﺩ ﯼﺍﺮﺑ ﯽﻧﺎﺳﺁ ﻩﺍﺭ.
.ﺩﻮﺷ ﯽﻣ ﻩﺪﯿﻣﺎﻧ ﯼﺍ ﻪﺘﺷﺭ ﯽﺑﺎﯾ ﻥﻭﺭﺩ ﺵﻭﺭ ﻦﯾﺍ
:ﺯﺍ ﺖﺳﺍ ﺕﺭﺎﺒﻋ ﻮﺤﻧ
${...}
ﺐﻟﺎﻗ ﺕﺎﺣﻼﻄﺻﺍ ﺪﻫﺩ ﯽﻣ ﻩﺯﺎﺟﺍ ﻪﺘﺷﺭ ﺭﺩ ﺎﻫﺮﯿﻐﺘﻣ ﻪﺑ:
let firstName = "John";
let lastName = "Doe";
let text = `Welcome ${firstName}, ${lastName}!`;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Template Literals</h2>
<p>Template literals allows variables in strings:</p>
<p id="demo"></p>
<p>Template literals are not supported in Internet Explorer.</p>
<script>
let firstName = "John";
let lastName = "Doe";
let text = `Welcome ${firstName}, ${lastName}!`;
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>
.ﺩﻮﺷ ﯽﻣ ﻩﺪﯿﻣﺎﻧ ﯼﺍ ﻪﺘﺷﺭ ﯽﺑﺎﯾ ﻥﻭﺭﺩ ﯽﻌﻗﺍﻭ ﺮﯾﺩﺎﻘﻣ ﺎﺑ ﺎﻫﺮﯿﻐﺘﻣ ﺭﺎﮐﺩﻮﺧ ﯽﻨﯾﺰﮕﯾﺎﺟ
ﺐﻟﺎﻗ ﺕﺎﺣﻼﻄﺻﺍ ﺪﻫﺩ ﯽﻣ ﺍﺭ ﺎﻫ ﻪﺘﺷﺭ ﺭﺩ ﺕﺍﺭﺎﺒﻋ ﻩﺯﺎﺟﺍ:
let price = 10;
let VAT = 0.25;
let total = `Total: ${(price * (1 + VAT)).toFixed(2)}`;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Template Literals</h2>
<p>Template literals allows variables in strings:</p>
<p id="demo"></p>
<p>Template literals are not supported in Internet Explorer.</p>
<script>
let price = 10;
let VAT = 0.25;
let total = `Total: ${(price * (1 + VAT)).toFixed(2)}`;
document.getElementById("demo").innerHTML = total;
</script>
</body>
</html>
.ﺩﻮﺷ ﯽﻣ ﻩﺪﯿﻣﺎﻧ ﯼﺍ ﻪﺘﺷﺭ ﯽﺑﺎﯾ ﻥﻭﺭﺩ ﯽﻌﻗﺍﻭ ﺮﯾﺩﺎﻘﻣ ﺎﺑ ﺕﺍﺭﺎﺒﻋ ﺭﺎﮐﺩﻮﺧ ﯽﻨﯾﺰﮕﯾﺎﺟ
let header = "Templates Literals";
let tags = ["template literals", "javascript", "es6"];
let html = `<h2>${header}</h2><ul>`;
for (const x of tags) {
html += `<li>${x}</li>`;
}
html += `</ul>`;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Template Literals</h2>
<p>Template literals allows variables in strings:</p>
<p id="demo"></p>
<p>Template literals are not supported in Internet Explorer.</p>
<script>
let header = "Templates Literals";
let tags = ["template literals", "javascript", "es6"];
let html = `<h2>${header}</h2><ul>`;
for (const x of tags) {
html += `<li>${x}</li>`;
}
html += `</ul>`;
document.getElementById("demo").innerHTML = html;
</script>
</body>
</html>
Template Literals
ﯽﮔﮋﯾﻭ ﮏﯾ ES6 (2015 ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ) ﺖﺳﺍ.
:ﺩﻮﺷ ﯽﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ ﻥﺭﺪﻣ ﯼﺎﻫﺮﮔﺭﻭﺮﻣ ﻡﺎﻤﺗ ﺭﺩ
Chrome | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes |
Template Literals
ﺭﺩ Internet Explorer ﺩﻮﺷ ﯽﻤﻧ ﯽﻧﺎﺒﯿﺘﺸﭘ.
:ﺪﯾﻭﺮﺑ ﺎﻣ ﺱﺭﺩﺁ ﻪﺑ ،ﻪﺘﺷﺭ ﻞﻣﺎﮐ ﻊﺟﺮﻣ ﮏﯾ ﯼﺍﺮﺑ
.ﺪﯿﻨﮐ ﻞﻣﺎﮐ ﺍﺭ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﺘﺷﺭ ﻊﺟﺮﻣ
.ﺖﺳﺍ ﻪﺘﺷﺭ ﯼﺎﻫ ﺵﻭﺭ ﻭ ﺎﻫ ﯽﮔﮋﯾﻭ ﻡﺎﻤﺗ ﺯﺍ ﯽﯾﺎﻫ ﻪﻧﻮﻤﻧ ﻭ ﺕﺎﺤﯿﺿﻮﺗ ﯼﻭﺎﺣ ﻊﺟﺮﻣ