Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

convert object to boolean javascript

// bool will be false if object is null, false, 0, etc.
// bool will be true if object is an array, object, non-zero number, etc.

// method 1
let bool = !!object;

// method 2
let bool = Boolean(object);
 
PREVIOUS NEXT
Tagged: #convert #object #boolean #javascript
ADD COMMENT
Topic
Name
4+8 =