Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Template Literals in javascript

// Template Literals in javascript
// Longhand:
let firstName = "Chetan", lastName = "Nada";
const welcome = 'Hello my name is ' + firstName + ' ' + lastName;
console.log(welcome); //Hello my name is Chetan Nada

// Shorthand:
const welcome_ = `Hello my name is ${firstName} ${lastName}`;
console.log(welcome_); //Hello my name is Chetan Nada
 
PREVIOUS NEXT
Tagged: #Template #Literals #javascript
ADD COMMENT
Topic
Name
2+5 =