Closed Gauravms2143 closed 1 year ago
Your code example above is creating an array with one element of ""
, therefor when you check if it is empty - it is not.
I have confirmed the same thing is happening with the Laravel Collection, so this is expected. Your best bet would be to filter the collection for null values first.
const c = collect("");
c.count(); // 1
c.isEmpty(); // false
c.filter().isEmpty(); // true
// Returns:
Collection {
items: [ '' ]
}
This issue should be closed
In JavaScript, string "" is considered as empty string.
But
collect("").isEmpty()) //
return output as false.link for code
(https://github.com/ecrmnn/collect.js/blob/master/src/methods/isEmpty.js)