“formato de cadena javascript” Código de respuesta

Declaración printf en JavaScript

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

f string javascript

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

formato de cadena de JavaScript

//

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

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

formato de cadena javascript

const string = 'This is a string.';
const message = `${string} This is also a string.`;
elyiscool

Formato de cadena de 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

Formato de cadena JavaScript

const firstString = '2 + 2'; // Creates a string literal value
const secondString = new String('2 + 2'); // Creates a String object
eval(firstString); // Returns the number 4
eval(secondString); // Returns a String object containing "2 + 2"
Relieved Raccoon

Respuestas similares a “formato de cadena javascript”

Preguntas similares a “formato de cadena javascript”

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código