Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

check if any property of object is null javascript

function hasNullProp(obj) {
	for (const key of Object.keys(obj)) {
    	if (obj[key] === null) {
            return true
        }
    }

	return false
}

// Returns true
const hasOneNullProp = hasNullProp({
	foo: 'string',
  	bar: null
})
 
PREVIOUS NEXT
Tagged: #check #property #object #null #javascript
ADD COMMENT
Topic
Name
3+7 =