p5.js Data Complete Reference
In the p5.js Data, URL string containing either image data and the text contents of the file or a parsed object if the file is JSON and p5.XML if XML.
Local Storage
|
Description
|
storeItem() |
It stores a given value under a key name in the local storage of the browser. |
getItem() |
It is used to retrieve the value that has been stored using the storeItem() function. |
clearStorage() |
It clears all items present in the local storage set using the storeItem() function. |
removeItem() |
It removes the item that has been stored using the storeItem() function. |
Dictionary
|
Description
|
createStringDict() |
It is used to create a p5.StringDict instance with the given data. |
createNumberDict() |
It is used to create a p5.NumberDict instance with the given data. |
p5.TypedDict
|
Description
|
create() |
It is used to add the given key-value pair or collection of pairs to the dictionary. |
set() |
It is used to add or modify the value at the given key of the dictionary. |
print() |
It is used to print out all the key-value pairs currently present in the dictionary to the console. |
get() |
It is used to return the value at the given key of the dictionary. |
size() |
size() method is used to get the current size of the dictionary. |
clear() |
It is used to remove all the key-value pairs in the typed dictionary. |
remove() |
It is used to remove the given key-value pair from the typed dictionary. |
hasKey() |
It is used to check if the given key exists in the typed dictionary. |
p5.NumberDict
|
Description
|
add() |
It adds the given value to the value at the given key and stores the updated value at the same key. |
mult() |
It multiplies the given value to the value at the given key and stores the updated value at the same key. |
div() |
It divides the value at the given key with the given value and stores the updated result at the same key. |
minKey() |
It is used to find the lowest value of key in a number dictionary. |
minValue() |
It is used to find the lowest value in a number dictionary. |
maxValue() |
It is used to find the highest value in a number dictionary. |
Array Functions
|
Description
|
append() |
It increases the length of the original array by one. |
arrayCopy() |
It is used to copy a part of source array elements to another destination array. |
concat() |
concat() function is used to concatenate the two given arrays. |
reverse() |
reverse() function is used to reverse the order of the given array element. |
shorten() |
shorten() function is used to decrease the number of elements of the given array by one. |
shuffle() |
shuffle() function is used to shuffle the order of given array elements. |
sort() |
sort() function is used to sort the array elements. |
splice() |
splice() function is used to insert values or array elements in the given array. |
subset() |
subset() function is used to get the subset of the given array elements. |
Conversion
|
Description
|
float() |
It is used to get the floating point representation of the given string as a parameter. |
int() |
It is used to convert the given boolean, integer, and float value into its integer representation. |
str() |
It is used to convert the given boolean, string and number value into its string representation. |
boolean() |
It is used to convert the given string and number value into its boolean representation. |
byte() |
It converts the given string of number, number value or boolean into its byte representation. |
char() |
It converts the given string or number value into its corresponding single-character string representation. |
unchar() |
It converts a single-character string into its corresponding integer representation. |
hex() |
hex() function is used to convert a number into its hexadecimal notation. |
unhex() |
It converts a string representation of any input hexadecimal number to its equivalent integer value. |
String Functions
|
Description
|
join() |
It is used to join the input array of strings into a single string using separator. |
nf() |
nf() function is used to format the input numbers (integers or floats) into strings. |
nfc() |
It formats the input numbers into strings as well as it places appropriate commas to mark the unit of 1000. |
nfp() |
It formats the input numbers into strings as well as it gives (+) and (-) sign according to the sign of input numbers. |
nfs() |
It adds ” ” (space) in front of positive input numbers and add (-) sign in front of negative input numbers. |
split() |
split() function is used to break the input string into pieces using a delimiter. |
splitTokens() |
It is used to break the input string into pieces of data using a delimiter. |
trim() |
It is used to remove whitespace characters and tab from the beginning and end of an input String. |
Last Updated :
22 Aug, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...