pixi-jsFunctions
Function: cleanArray()
> cleanArray<T>(arr): T[]
Defined in: node_modules/pixi.js/lib/utils/data/clean.d.ts:28
Internal
Removes all undefined/null elements from the given array and compacts the array.
This function iterates through the array, shifting non-undefined elements to the left
to fill gaps created by undefined elements. The length of the array is then adjusted
to remove the trailing undefined elements.
Type Parameters
T
T
Parameters
arr
T[]
The array to be cleaned.
Returns
T[]
The cleaned array with all undefined elements removed.
Example
// Example usage:
const arr = [1, undefined, 2, undefined, 3];
const cleanedArr = cleanArray(arr);
console.log(cleanedArr); // Output: [1, 2, 3]