Logo

Programming-Idioms

History of Idiom 110 > diff from v34 to v35

Edit summary for version 35 by justafoo:
[JS] always default to const instead of let
↷

Version 34

2019-09-26, 17:55:29

Version 35

2019-09-26, 17:56:21

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]/)
Code
const 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.
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.