p5.js NumberDict sub() Method
The sub() method of p5.NumberDict in p5.js subtracts the given value from the value at the given key and stores this updated value at the same key. A key-value pair is a set of two values that are mapped to each other. These values can be accessed by querying this dictionary using the key portion of the pair. A number dictionary can store multiple key-value pairs that can be accessed using the methods of the dictionary.
sub( Key, Number )
Parameters: This function has two parameters as shown above and discussed below:
- Key: This is a number that denotes the key from where the value would be subtracted.
- Number: This is a number that denotes the value that is to be subtracted.
The example below illustrates the sub() method in p5.js:
Online editor: https://editor.p5js.org/
Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/