Details:
https://github.com/processing/p5.js/wiki/Global-and-instance-mode
I usually teach with 'global' mode as it is a bit simpler and easier to jump into, but it can encourage poor practices and lead to some headaches.
Here's a few things to be mindful of:
- Common JavaScript features like
cos()
andPI
become built-in globals, when a student transitions to other ecosystems (e.g. ThreeJS or even just Node.js) they have to re-learn which functions are builtin (e.g.setTimeout
) and which are namespaced (Math.PI
)