“Format de chaîne JavaScript” Réponses codées

f String javascript

`string text ${expression} string text`
Nervous Nightingale

Instruction printf en javascript

let soMany = 10;
console.log(`This is ${soMany} times easier!`);
// "This is 10 times easier!
Hilarious Hare

Format de chaîne JavaScript

//

const firstName = 'john';
const lastName = 'smith';

const output = `name: ${firstName}, surname: ${lastName}`;
// name: john, surname: smith
Beautiful Bear

Texte de format Nodejs

var my_name = 'John';
var s = `hello ${my_name}, how are you doing`;
console.log(s); // prints hello John, how are you doing
Foolish Frog

Format de chaîne JavaScript

let name = "John";
let age = 30;
let food = "pizza";

// String formating using backticks
let sentence = `${name} is ${age} years old and likes ${food}`;

console.log(sentence);
// John is 30 years old and likes pizza

// String formating using plus operator
let sentence = name + ' is ' + age + ' years old and likes ' + food;

console.log(sentence); // John is 30 years old and likes pizza
Clumsy Caiman

Format de chaîne JavaScript

let name = "John";
let age = 30;
let food = "pizza";

// String formating using backticks
let sentence = `${name} is ${age} years old and likes ${food}`;

console.log(sentence); // John is 30 years old and likes pizza
Wicked Wryneck

Réponses similaires à “Format de chaîne JavaScript”

Questions similaires à “Format de chaîne JavaScript”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code