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

257
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 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