Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript template strings

//Template strings allow you to inject values into a string while 
//preserving the format. Your code becomes more reader friendly.
//Use it instead of 'string arithmetic'.

let userName = 'John Doe';
let finalResult = 234;

//template string
console.log(`Hello ${userName} your final result is ${finalResult}`);

//'string arithmetic'
console.log("Hello " + userName + " your final result is " + finalResult);
Comment

es6 string templates

const subject = 'world';
console.log(`hello ${subject}`);
// output = 'hello world'
Comment

Template strings in ES6

function hello(firstName, lastName) {
  return `Good morning ${firstName} ${lastName}! 
How are you?`
}

console.log(hello('Ranjeet', 'Andani'))
Comment

template strings in js

const name = 'JavaScript';
console.log(`I love ${name}`); // I Love JavaScript
Comment

PREVIOUS NEXT
Code Example
Javascript :: script refresh js 
Javascript :: loop into array javascript 
Javascript :: new js 
Javascript :: javascript closest parent 
Javascript :: swagger on expres node app 
Javascript :: storybook global decorator 
Javascript :: read dictionary values 
Javascript :: shopify template routes 
Javascript :: js to find min value in an array 
Javascript :: progress bar loading ajax 
Javascript :: sequelize migration enum 
Javascript :: update html text 
Javascript :: map function in js 
Javascript :: angular how to use service in class 
Javascript :: stringy 
Javascript :: json in python 
Javascript :: inch to cm 
Javascript :: js data types 
Javascript :: run function after another function javascript 
Javascript :: linked list algorithm javascript 
Javascript :: class 
Javascript :: add new html from javascript 
Javascript :: npm module 
Javascript :: button clicker code 
Javascript :: try without catch 
Javascript :: multiple images on cloudinary 
Javascript :: pass a variable by reference to arrow function 
Javascript :: read and save excel with react 
Javascript :: simple chat app 
Javascript :: template literals in js 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =