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

259
Vistas
Write function, which returns an unique identifier for parameter.(Java Script)

I have tried to do it, but all I get is that output: ---> Symbol(Test) Is it even possible to get output like this(with single quotes in it): ---> Symbol('Test')

function getUnique(param) {
    param = Symbol(param);
    return param;
} 

console.log(getUnique('Test')) // Symbol('Test') <--- I need to get that output 

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

[Updated] Not sure if this is what you want...

function getUnique(param) {
    param = Symbol("'" + param + "'");
    return param;
} 

console.log(getUnique('Test')) 

about 4 years ago · Juan Pablo Isaza Denunciar

0

I may be completely misunderstanding your question, but if you mean

Symbol('Test') <--- I need to get that output

You can append the single quote characters to the string like so:

const getUnique = (param) => {
  const sym = Symbol(param);
  return sym;
}

console.log(getUnique(`'test'`))

about 4 years ago · Juan Pablo Isaza Denunciar

0

The representation of what gets printed at the console is implementation dependent and could even vary from version to version of the same implementation. Running it in latest chrome gives an output of Symbol(Test) and firefox gives Symbol("Test"). It's the same thing either way: the console printed output is just a representation of the thing. It isn't actually any different, it's still a unique Symbol 'Test'.

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