Skip to content

Instantly share code, notes, and snippets.

@SangHakLee
Created December 28, 2015 16:31
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SangHakLee/4da6159a7a08cdd12132 to your computer and use it in GitHub Desktop.
Save SangHakLee/4da6159a7a08cdd12132 to your computer and use it in GitHub Desktop.
check some value is empty ( include empty array, empty object and exclude number 0
// 넘어온 값이 빈값인지 체크합니다.
// !value 하면 생기는 논리적 오류를 제거하기 위해
// 명시적으로 value == 사용
// [], {} 도 빈값으로 처리
var isEmpty = function(value){
if( value == "" || value == null || value == undefined || ( value != null && typeof value == "object" && !Object.keys(value).length ) ){
return true
}else{
return false
}
};
@SangHakLee
Copy link
Author

SangHakLee commented Jun 24, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment