Skip to content

Instantly share code, notes, and snippets.

@alex-boom
Last active October 22, 2021 12:29
Show Gist options
  • Save alex-boom/2cf595af752532d9e9165a258a39af70 to your computer and use it in GitHub Desktop.
Save alex-boom/2cf595af752532d9e9165a258a39af70 to your computer and use it in GitHub Desktop.
is-empty
//Чтобы проверить, является ли строка пустой, 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