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

141
Visualizações
p5.js returns UNDEFINED on this.instance_variable however, works when called explicitly. Please explain why. Example provided

I have read some stack overflow and all I was able to find was that "this" was not referencing the instance variable I had in question and that it was referencing the current window. This did not help my understanding of the problem beyond parroting this back.

I AM ABLE to access the value when I call it explicitly and I have not found this comparison discussed or whether this is convention. See:

class LetterButton {
      constructor(buttonName, text1) {
        console.log(buttonName + " created");
        this.buttonName = createButton(text1);
        this.buttonName.mousePressed(buttonFunction);
        
        function buttonFunction() {
          console.log(buttonName + "*");//<--works     
          console.log(this.buttonName);//<--does not  work UNDEFINED
        } //fn
        
        
      }//constructor
    }//end class
        
    function setup() {
      createCanvas(500, 500);
      background("beige");
      button = new LetterButton("tempButton","tempText") 
      button.buttonName.position(250,250);
    }
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I'm pretty sure this is the answer:

You don't have access to this.buttonName within a call from this.buttonName.mousePressed() Though I could be wrong.

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