Returns true
if the given string contains any whitespace characters, false
otherwise.
Use RegExp.prototype.test()
with an appropriate regular expression to check if the given string contains any whitespace characters.
代码片段
const containsWhitespace = str => /\s/.test(str);
使用样例
containsWhitespace('lorem'); // false
containsWhitespace('lorem ipsum'); // true