[p5.js 2.0 Bug Report]: noise(null) is treated as noise(0) while noise(undefined) errors, and this behaviour is undocumented and inconsistent.
Open
@jeetsdev is already working on this.
Since Jun 22, 2026.
Bug
Good First Issue
Help Wanted
p5.js 2.0+
- Dominant language
- JavaScript
- Stars
- 24k
- Forks
- 3.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 25
Description
Most appropriate sub-area of p5.js?
- Accessibility
- Color
- Core/Environment/Rendering
- Data
- DOM
- Events
- Image
- IO
- Math
- Typography
- Utilities
- WebGL
- Build process
- Unit testing
- Internationalization
- Friendly errors
- Other (specify if possible)
p5.js version
2.1.2
Web browser and version
Google Chrome Version 143.0.7499.170
Operating system
Windows 11
Steps to reproduce this
Steps:
- Run the sketch below
- Compare the outputs of noise(null) and noise(0)
- Observe that they are identical, while noise(undefined) throws an FES warning
Snippet:
function setup() {
noCanvas();
console.log("null:", noise(null));
console.log("0:", noise(0));
console.log("undefined:", noise(undefined));
}
Explanation:
noise(null) returns the same value as noise(0), while noise(undefined) produces a NaN and a Friendly Error message. Both null and undefined represent missing values in JavaScript, but they are handled differently here. This behaviour is not documented and can lead to silent bugs when null is passed unintentionally.
I'm happy to take on this task, if this is approved
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.