The isLength
function from Lodash is used to check whether a value is a valid array-like length.
To use this function, first, we need to install Lodash in our project using npm:
index.tsx19 chars2 lines
Then we can import the isLength
function from Lodash in our module:
index.tsx40 chars2 lines
We can then use the isLength
function in our code:
index.tsx156 chars8 lines
The above code will output "10" is a valid length."
.
Note that isLength
returns true
for lengths that are integers between 0
and Number.MAX_SAFE_INTEGER
(inclusive).
gistlibby LogSnag