“JavaScript -Vorlage Literale” Code-Antworten

String buchstäblicher JavaScript

`string text`

`string text line 1
 string text line 2`

`string text ${expression} string text`

tag`string text ${expression} string text`
Happy Heron

Template -Literale 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
Chetan Nada

JavaScript -Vorlage Literale

//Must use backticks, `, in order to work.

let a = 5;
let b = 10;
console.log(`Fifteen is ${a + b} and
not ${2 * a + b}.`);

//Output:
//Fifteen is 15 and not 20.
Blue-eyed Bee

Template Literal Syntax

`half of 100 is ${100 / 2}`
Crazy Cobra

JavaScript -Vorlage Literale

const first_name = "Jack";
const last_name = "Sparrow";

console.log('Hello ' + first_name + ' ' + last_name);
SAMER SAEID

Ähnliche Antworten wie “JavaScript -Vorlage Literale”

Fragen ähnlich wie “JavaScript -Vorlage Literale”

Weitere verwandte Antworten zu “JavaScript -Vorlage Literale” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen