-
-
Notifications
You must be signed in to change notification settings - Fork 0
boolean object
Nicholas Berlette edited this page Jun 19, 2025
·
1 revision
function isBooleanObject(it: unknown): it is Boolean;
Checks if a value is a Boolean object, which is a boxed-primitive boolean that
was created either with the new Boolean()
syntax, or by wrapping a primitive
boolean in the Object()
wrapper function.
Boxed primitives are strongly discouraged in JavaScript, as they can lead to all sorts of unexpected behavior and performance issues. As such, this function - and the other boxed primitive functions like it - are provided for your convenience, to help you easily ensure your code is not on the receiving end of such behavior.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a boxed-primitive boolean object; otherwise, false
.
Boxed Primitives
import { isBooleanObject } from "jsr:@nick/is/boolean-object";
isBooleanObject(Object(true)); // true
isBooleanObject(new Boolean(true)); // true
isBooleanObject(Boolean(true)); // false
isBooleanObject(true); // false