본문 바로가기
Library & Framework/jQuery

[jQuery] isEmptyObject() - 객체에 값이 있는지, 비었는지 체크하기

by 썸머워즈 2021. 7. 1.
반응형

객체의 빈값 여부를 찾는 방법은 다양할 수 있는데,그 중에서 jQeury에서 제공해주는 jQuery.isEmptyObject() 메서드에 대해 알아보고자 한다.

 

▷ 구문

- jQuery.isEmptyObject(object)
- $.isEmptyObject(object)
(둘이 같은 의미이다.)

예제를 통해 알아보도록 하자.

 

▷ 예제1)

jQuery.isEmptyObject({}); //true
jQuery.isEmptyObject({it : 'mine'}); //false 

$.isEmptyObject({}); //true
$.isEmptyObject({it : 'mine'}); //false


참조 : https://api.jquery.com/jquery.isemptyobject/

 

jQuery.isEmptyObject() | jQuery API Documentation

Description: Check to see if an object is empty (contains no enumerable properties). As of jQuery 1.4 this method checks both properties on the object itself and properties inherited from prototypes (in that it doesn't use hasOwnProperty). The argument sho

api.jquery.com

반응형


댓글

TOP