compact()

Create a new array or object with all of the false-ish values removed.

This function is valid in v2.21.0 to v2.23.0. This function has been downloaded 11 times.

Parameter

{Array|Object} arrOrObj
Array or object of values to comb through.

Returns

{Array|Object}
If arrOrObj is an array or is array-like then an array will be returned. Otherwise an object will be returned. The returned array or object will be similar to arrOrObj but will only have true-ish values.

Required Function

This function directly requires the following function which is included automatically:

  • filter()
    Creates a new object or a new array based on the specified object array. This new array will only have the values which pass the test function.