Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

template literal syntax

`half of 100 is ${100 / 2}`
Comment

Template literals

If you are gonna copy and paste answers from MDN... you should AT LEAST
check the page hedaer to see what topic you are copying. That way you don't 
post a porno graphic where a 3-D graphic belongs.

`string text`

`string text line 1
 string text line 2`

`string text ${expression} string text`

tag`string text ${expression} string text`
Comment

Template literals (Template strings)

// Untagged, these create strings:
`string text`

`string text line 1
 string text line 2`

`string text ${expression} string text`

// Tagged, this calls the function "tagFunction" with the template as the
// first argument and substitution values as subsequent arguments:
tagFunction`string text ${expression} string text`
Comment

Template Literals

let fourthItem = 'Item 4';
let myHtml = `
  <ol class="item-list">
    <li>Item 1</li>
    <li>Item 2</li>
    <li>Item 3</li>
    <li>${fourthItem}</li>
  </ol>
`;
Comment

Template Literals for Strings

const str1 = 'This is a string';

// cannot use the same quotes
const str2 = 'A "quote" inside a string';  // valid code
const str3 = 'A 'quote' inside a string';  // Error

const str4 = "Another 'quote' inside a string"; // valid code
const str5 = "Another "quote" inside a string"; // Error
Comment

PREVIOUS NEXT
Code Example
Javascript :: useeffect cleanup function 
Javascript :: instanceof 
Javascript :: how to make an if statement in javascript 
Javascript :: array count in mongoose query 
Javascript :: pm2 change log timestamp 
Javascript :: polymer js tutorial 
Javascript :: html css js interview questions 
Javascript :: req.header express.js 
Javascript :: Return with an "IF" Statement 
Javascript :: how to upgrade nodejs version 
Javascript :: how to make and add to an array in javascript 
Javascript :: javascript loop object key value 
Javascript :: discord bot not responding to commands 
Javascript :: node js file extension 
Javascript :: array of objects in js 
Javascript :: .has js 
Javascript :: build angular project 
Javascript :: context api in react 
Javascript :: npm windows registry 
Javascript :: passing ref to child component 
Javascript :: React passing data fom child to parent component 
Javascript :: last element from list javascript 
Javascript :: jquery dynamic row number not working properly 
Javascript :: rxjs sequence of api calls 
Javascript :: convert binary to string javascript 
Javascript :: javascript check if json object is valid 
Javascript :: how to console.log while using a prompt in javascript 
Javascript :: array of alphabets 
Javascript :: scratch addons 
Javascript :: what is mdoe in math 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =