Thursday, May 9, 2024
 Popular · Latest · Hot · Upcoming
16
rated 0 times [  18] [ 2]  / answers: 1 / hits: 20697  / 10 Years ago, wed, september 17, 2014, 12:00:00

I am looking an equivalent of http://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html#isBlank(java.lang.CharSequence)
I found several 3rd party extensions, but is there one out of the box with underscore.js: http://underscorejs.org


More From » string

 Answers
40

Following @muistooshort's advice I created my mixin and wanted to share it:



  _.mixin({
isBlank: function(string) {
return (_.isUndefined(string) || _.isNull(string) || string.trim().length === 0)
}
});

> _(t).isBlank()
< true

> _(qwerty).isBlank()
< false

[#69418] Tuesday, September 16, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
citlalia

Total Points: 138
Total Questions: 104
Total Answers: 87

Location: Iceland
Member since Sat, Sep 17, 2022
2 Years ago
;