# We have to claim variables in advance?

**URL:** <https://discourse.processing.org/t/we-have-to-claim-variables-in-advance/29431>\
**Category:** Beginners\
**Tags:** homework\
**Created:** [April 17, 2021, 1:42am UTC](https://discourse.processing.org/t/we-have-to-claim-variables-in-advance/29431 "2021-04-17T01:42:53Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [April 17, 2021, 11:17am UTC](https://discourse.processing.org/t/we-have-to-claim-variables-in-advance/29431/4 "2021-04-17T11:17:22Z")

</div>

also a funny thing is that this works too

```javascript

function setup() {
  createCanvas(100,100);
  pg = createGraphics(100,100); // claim variable like this
}

function draw() {
  pg.background(100);
  image(pg, 0, 0);
}

let pg;

```

as written above, it’s about the scope and not necessarily “in advance”.

---

_[View the full topic](https://discourse.processing.org/t/we-have-to-claim-variables-in-advance/29431)._
