assigning an array to a this. variable?

Hi,

Seems I can't assign an array to a this. variable?

This gives me an error, for example:

this.color1 = [69,173,168];

It works fine though if I write something like:

this.color1 = "#23ee10";

Is that to be expected?

In pure Javascript this supposedly works ...

Thanksü

Tagged:

Answers

  • What this refers to here is entirely dependent on context - which you don't provide. It's typically a reference to the surrounding function; but you may have used a function to define a pseudo-class; or may even be using the new ECMAScript2015 class implementation. There are also cases where this doesn't in fact reference what you expect....

    In pure Javascript this supposedly works ...

    If you're working with the p5.js library then you are writing "pure javascript"...

    Can you post a short, complete sketch that demonstrates the issue.

  • You still don't provide your context: i.e. your own code. Also did you notice this:

    dat.GUI will modify colors in the format defined by their initial value.

Sign In or Register to comment.