artinisc / Chat

Chat elaborado para a aula de Solucoes Web
1 stars 0 forks source link

Interpolação Desnecessária #3

Open lucasferreira opened 4 years ago

lucasferreira commented 4 years ago

Opa,

Referente a estes pontos:

https://github.com/artinisc/Chat/blob/2fd21cb18739efa848a1087635656f68680ada86/js/index.js#L9-L10

Quando não iremos concatenar (ou interpolar) uma string/variável em JS não é necessário o uso da template sintax, o trecho acima poderia ser simplesmente assim:

divAut.innerHTML = "Você diz:"; 
divTxt.innerHTML = novaMsg;

Caso você precisasse "unir" uma string com uma outra variável, teríamos algumas opções:

let opcao1 = 'Você diz: ' + novaMsg;
let opcao2 = "Você diz: " + novaMsg;
let opcao3_moderna = `Você diz: ${novaMsg}`;

Beleza?

artinisc commented 4 years ago

Ok, agradeço pelas dicas.


De: Lucas Ferreira notifications@github.com Enviado: domingo, 19 de abril de 2020 18:00 Para: artinisc/Chat Chat@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Assunto: [artinisc/Chat] Interpolação Desnecessária (#3)

Opa,

Referente a estes pontos:

https://github.com/artinisc/Chat/blob/2fd21cb18739efa848a1087635656f68680ada86/js/index.js#L9-L10

Quando não iremos concatenar (ou interpolar) uma string/variável em JS não é necessário o uso da template sintax, o trecho acima poderia ser simplesmente assim:

divAut.innerHTML = "Você diz:";

divTxt.innerHTML = novaMsg;

Caso você precisasse "unir" uma string com uma outra variável, teríamos algumas opções:

let opcao1 = 'Você diz: ' + novaMsg;

let opcao2 = "Você diz: " + novaMsg;

let opcao3_moderna = Você diz: ${novaMsg};

Beleza?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/artinisc/Chat/issues/3, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AMEQUXJRXYOIQCJSU3YMNVTRNNJ7LANCNFSM4ML5U7NA.