Last active
October 22, 2021 12:29
-
-
Save alex-boom/2cf595af752532d9e9165a258a39af70 to your computer and use it in GitHub Desktop.
is-empty
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Чтобы проверить, является ли строка пустой, null или undefined: | |
function isEmpty(str) { | |
return (!str || 0 === str.length); | |
} | |
//Для проверки пустой строки, null или undefined: | |
function isBlank(str) { | |
return (!str || /^\s*$/.test(str)); | |
} | |
//Для проверки, является ли строка пустой или содержит только пробел: | |
String.prototype.isEmpty = function() { | |
return (this.length === 0 || !this.trim()); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment