# Random to initialize variables

**URL:** <https://discourse.processing.org/t/random-to-initialize-variables/21466>\
**Category:** Beginners\
**Created:** [May 31, 2020, 11:39pm UTC](https://discourse.processing.org/t/random-to-initialize-variables/21466 "2020-05-31T23:39:51Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [June 1, 2020, 10:46am UTC](https://discourse.processing.org/t/random-to-initialize-variables/21466/3 "2020-06-01T10:46:08Z")

</div>

> [@davidhurwich](#):
>
> Why is it that functions do not work outside of **setup()** or **draw()**?

> [@When can you use cos and sin outside of setup or draw](http://discourse.processing.org/t/when-can-you-use-cos-and-sin-outside-of-setup-or-draw/11805/4):
>
> I’ve changed your post to the p5.js forum category then. expressionless p5js is a diff. flavor beast. bear Indeed, none of its API is available until either it finds out that setup() or draw() is in the global context (window) or we manually instantiate class p5: new p5; cowboy_hat_face new p5; // prematurely instantiate class p5. ;-) const SQRT\_3 = sqrt(3); // we can access p5's sqrt() method outside functions! function setup() { print(SQRT\_3); } For cos() & sin() and similar, we …

---

_[View the full topic](https://discourse.processing.org/t/random-to-initialize-variables/21466)._
