Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

226
Vistas
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 Respuestas
Responde la pregunta

0

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

about 4 years ago · Juan Pablo Isaza Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda