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

358
Visualizações
Issues using "String.prototype.substring"

I have some issues using the replace method for javascript strings :

I created a class that contains this method :

    setDataAt(pos, value) {
        this.#data = this.#data.substring(0, pos)+value+this.#data.substring(pos+1);
    }

but when I use it, the data is truncated as there wasn't any +this.#data.substring(pos+1);...
Per example, if my object obj has as #data attribute "Hello world", after making obj.setDataAt(5, '.'), the #data attribute will be "Hello." and not "Hello.world"

EDIT :

My issue doesn't seems to appair when I use it directly (below is a little part of my original code, all that is used into ma issue, and it totally work). But when I use it from my web page, it gives issues :

How to fix that? Thanks for all your answers

Another Edit :

The problem is that in my website page, the pos var isn't an integer, but a string. I have to replace all pos by parseInt(pos) to make it work correctly.

Thanks a lot @Nick_Paterson!

about 4 years ago · Juan Pablo Isaza
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