티스토리 뷰
728x90
const obj = {};
const arr = [];
function isEmpty(param) {
return Object.keys(param).length === 0;
}
console.log(isEmpty(obj)); // true
console.log(isEmpty(arr)); // true
const obj = {};
const arr = [];
function isEmptyObject(param) {
return Object.keys(param).length === 0 && param.constructor === Object;
}
console.log(isEmptyObject(obj)); // true
console.log(isEmptyObject(arr)); // false
https://swtpumpkin.github.io/javascript/checkEmptyObject/
javascript 빈 객체 체크 (check empty object)
javascript check empty object자바스크립트에서 빈 객체를 체크하려는 경우 null로 체크 할 수 없습니다. 따라서 별도의 함수를 생성하여 체크하는 방법을 설명드리겠습니다. 함수 생성 방법1234567const obj
swtpumpkin.github.io
728x90
'공부' 카테고리의 다른 글
[Spark] `spark.executor.extraJavaOptions` log4j.xml (multi options) (0) | 2020.05.17 |
---|---|
[JS] convert bytes array to image (0) | 2020.05.17 |
[JS] check isEmpty (0) | 2020.05.17 |
[SpringBoot] configuration memory heap size (0) | 2020.05.17 |
[JS] uniqBy array by Lodash (0) | 2020.05.17 |
[Spark] submit conf by tuning (0) | 2020.05.14 |
댓글