ts-utils
  • Getting Started
  • Contributing
  • Testing
  • Functions
    • Array Methods
      • isArr
      • isArrEmpty
      • pushUniqueValue
      • pushOrUpdate
    • Date Methods
      • toNow
      • formatDate
      • fromNow
    • Number Methods
      • toFixed
      • parseNumber
      • parseFormat
      • addUnit
      • addSeparators
      • formatNumber
      • ensureNumber
      • numberEmptyState
    • Object Methods
      • parseJSON
      • deepClone
      • parseNumValues
      • removeEmptyKeys
      • sanitizeQuery
      • removeKeys
      • renameKey
      • renameKeys
      • sortByKeyLength
      • querylize
      • parseNumericObj
      • reserveKeys
      • hasKeysAndValues
    • String Methods
      • randomStr
      • toUpperCase
      • toLowerCase
      • toFullUrl
      • initials
      • generateUuid
Powered by GitBook
On this page
  • isArr(variable)
  • Arguments
  • Returns
  • Example
  • Usage
  • Notes

Was this helpful?

  1. Functions
  2. Array Methods

isArr

isArr(variable)

Determines whether the provided variable is an array by utilizing the Array.isArray() method.

Arguments

  • variable (any): The variable to check if it is an array.

Returns

  • (boolean): Returns true if the variable is an array, false otherwise.

Example

typescript
import { isArr } from 'check-engineering/ts-utils';

console.log(isArr([1, 2, 3])); // => true
console.log(isArr('not an array')); // => false

Usage

typescript
import { isArr } from 'check-engineering/ts-utils';

const arr = [1, 2, 3];
const notArr = 'not an array';

console.log(isArr(arr)); // => true
console.log(isArr(notArr)); // => false

Notes

  • Ensure the input variable is checked for being an array using Array.isArray(variable).

  • This function provides a quick and reliable way to verify if a given variable is an array, aiding in type checking and validation within your TypeScript projects.

PreviousArray MethodsNextisArrEmpty

Last updated 11 months ago

Was this helpful?