Logo

Programming-Idioms

History of Idiom 110 > diff from v24 to v25

Edit summary for version 25 by 1.7.4:
New JS implementation by user [1.7.4]
↷

Version 24

2018-03-21, 21:21:01

Version 25

2019-01-23, 19:07:36

Idiom #110 Check if string is blank

Set boolean blank to true if string s is empty, or null, or contains only whitespace ; false otherwise.

Idiom #110 Check if string is blank

Set boolean blank to true if string s is empty, or null, or contains only whitespace ; false otherwise.

Code
let blank = s == null || !s.test (/[^\s]/)
Comments bubble
Because _== is being used instead of ===, undefined will also return true—which is good because it represents the absence of a value just like null.