Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

217
Visualizações
How to distinguish plain quoted string and template literal(backtick)

They are the same in the result, but they have different abilities. Is there any way to identify between them so that I can restrict the user(of a function) to use only template literal as an argument?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

No, not really... just like you can't really differentiate 5 and 4 + 1.

about 4 years ago · Juan Pablo Isaza Relatório

0

You mean something like an imaginary isFromTemplateLitteral boolean?

function(string){
  if(string.isFromTemplateLitteral()){
    // console.log("YES!")
  }
}

No can do.
Because the string was passed to the function using reference in the memory stack for it. So even before the function body starts running, string is already a normal string. A primitive with type string.

There is no way to know how it has been constructed (template litteral, concatenation, simple/double quotes, etc.) or where it really comes from (user input, harcoded text, regular expression match, etc).

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda