Saltar al contenido

cómo agregar comillas dobles dentro de comillas dobles en el ejemplo de código javascript

Te sugerimos que pruebes esta respuesta en un ambiente controlado antes de pasarlo a producción, saludos.

Ejemplo: javascript string comillas simples o dobles

/*
	You can use either.
    Double quotes are the only allowed character for
    strings in JSON, and HTML conventions suggest using it.
    However, single quotes are far more popular in JS and CSS.
    Most JS learning programs use the single quote, but most development
    environments mainly link to or even have all of their templates in
    double quotes, as well. Although I've learned JS with
    single quotes and it seems archaic in some places, I discourage,
    denounce, and despise not using single quotes in programs
    that don't have all of their templates mostly in double
    quotes. They've become a popular choice, although not widespread.
    Also, if you have access to ES6, you can also use a backtick.
    Although it is scarcely used other than using it for its actual
    purpose, which is a template literal, it'll also save you from
    typing some backslashes, and it only requires a tiny bit
    of practice to type easily.
*/// Example 1'Please don't try this at home. We're professionally trained to do this.'"Please don't try this at home. We're professionally trained to do this."`Please don't try this at home. We're professionally trained to do this.`// Example 2'"To live is to struggle. To survive is to find meaning in the struggle."'""To live is to struggle. To survive is to find meaning in the struggle.""`"To live is to struggle. To survive is to find meaning in the struggle."`// Example 3'`const meaningOfLife = 42;`'"`const meaningOfLife = 42;`"``const meaningOfLife = 42;``// Example 4'"We're no strangers to love."'""We're no strangers to love.""`"We're no strangers to love."`// Example 5'`console.log("Hello World!");`'"`console.log("Hello World!");`"``console.log("Hello World!");``// Example 6'`console.log('Hello World!');`'"`console.log('Hello World!');`"``console.log('Hello World!');``// Example 7'Which? `console.log("Hello World!");`n`console.log('Hello World!');`'"Which? `console.log("Hello World!");`n`console.log('Hello World!');`"`Which? `console.log("Hello World!");`n`console.log('Hello World!');``/*
	Here's the amount of examples which required escape characters:
    Single quote: 1, 4, 6, 7 (4).
    Double quote: 2, 4, 5, 7 (4).
    Backtick: 3, 5, 6, 7 (4).
    They're all even. Go and look back at the examples, and pick the
    character that won't require escape characters in your most common
    use cases.
*//*
	The conclusion? I'm tending toward backticks right now.
    Of course, I'm still not undecided about using single quotes
    around mostly, but, practically, you'd wanna use backticks.
*/

Comentarios y calificaciones del post

Si conservas algún titubeo o forma de regenerar nuestro noticia puedes realizar una anotación y con deseo lo estudiaremos.

¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)



Utiliza Nuestro Buscador

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *