# About static methods in p5.js

**URL:** <https://discourse.processing.org/t/about-static-methods-in-p5-js/47909>\
**Category:** Coding Questions\
**Created:** [February 19, 2026, 8:03pm UTC](https://discourse.processing.org/t/about-static-methods-in-p5-js/47909 "2026-02-19T20:03:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![EricRogerGarcia](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ericrogergarcia/32/21029_2.png) [@EricRogerGarcia](https://discourse.processing.org/u/EricRogerGarcia)\
**Post date:** [February 19, 2026, 8:03pm UTC](https://discourse.processing.org/t/about-static-methods-in-p5-js/47909/1 "2026-02-19T20:03:24Z")

</div>

Hello,

Is it possible to access P5js functions in a static functions ?

I tried in this sketch but it doesnt work

```auto
"use strict";

function setup() {
  createCanvas(800, 600);
  fill(255);
}

function draw() {
  background(0);
  text(V.get("Hello", "number", this), 100, 100);
}

class V {
  static verif=true;

  static get(a, s, n) { // (anyType, type in a string, this) : anyType
    if (!V.verif) {
      return a;
    } else if ( typeof a === s) {
      return a;
    } else {
      let type = typeof a;
      bugMessage("Erreur V, in : "+n+", asked : "+s+", but it was : "+type,true);
      return 0;
    }
  }
}

function bugMessage(aString, aBoolean) {
  print(aString);
  if (aBoolean) {
    noLoop();
  }
}

```

I haven’t any error in the browser console

but it shows me something in P5 and it doesn’t work :

I wanted the sketch to stop (`noLoop()`) and my error message written in the console.

it works when I don’t use `bugMessage()`, it doesn’t work when I have `noLoop()` in the static method either.

---

<div class="post-metadata">

**Author:** ![davepagurek](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/davepagurek/32/17535_2.png) [@davepagurek](https://discourse.processing.org/u/davepagurek)\
**Post date:** [February 19, 2026, 9:06pm UTC](https://discourse.processing.org/t/about-static-methods-in-p5-js/47909/2 "2026-02-19T21:06:03Z")

</div>

I tried copy and pasting your code into the p5 web editor, and besides having to add `p5.disableFriendlyErrors = true` at the top due to FES not parsing the class with initialized properties in it (on the latest release, to be fixed soon!), it seems to work for me: [Golden saga by davepagurek -p5.js Web Editor](https://editor.p5js.org/davepagurek/sketches/qWn1mrbB6)

---

<div class="post-metadata">

**Author:** ![EricRogerGarcia](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ericrogergarcia/32/21029_2.png) [@EricRogerGarcia](https://discourse.processing.org/u/EricRogerGarcia)\
**Post date:** [February 20, 2026, 7:55am UTC](https://discourse.processing.org/t/about-static-methods-in-p5-js/47909/3 "2026-02-20T07:55:55Z")

</div>

> [@davepagurek](#):
>
> p5.disableFriendlyErrors = true

So glad !!!

thanksssssssssss ! 🙂

P.S. I’m going to have some static classes in my project !!!
