1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
# Boolean
Class `Napi::Boolean` inherits from class [`Napi::Value`][].
`Napi::Boolean` class is a representation of the JavaScript `Boolean` object. The
`Napi::Boolean` class inherits its behavior from the `Napi::Value` class
(for more info see: [`Napi::Value`](value.md)).
## Methods
### Constructor
Creates a new empty instance of an `Napi::Boolean` object.
```cpp
Napi::Boolean::Boolean();
```
Returns a new _empty_ `Napi::Boolean` object.
### Constructor
Creates a new instance of the `Napi::Boolean` object.
```cpp
Napi::Boolean(napi_env env, napi_value value);
```
- `[in] env`: The `napi_env` environment in which to construct the `Napi::Boolean` object.
- `[in] value`: The `napi_value` which is a handle for a JavaScript `Boolean`.
Returns a non-empty `Napi::Boolean` object.
### New
Initializes a new instance of the `Napi::Boolean` object.
```cpp
Napi::Boolean Napi::Boolean::New(napi_env env, bool value);
```
- `[in] env`: The `napi_env` environment in which to construct the `Napi::Boolean` object.
- `[in] value`: The primitive boolean value (`true` or `false`).
Returns a new instance of the `Napi::Boolean` object.
### Value
Converts a `Napi::Boolean` value to a boolean primitive.
```cpp
bool Napi::Boolean::Value() const;
```
Returns the boolean primitive type of the corresponding `Napi::Boolean` object.
## Operators
### operator bool
Converts a `Napi::Boolean` value to a boolean primitive.
```cpp
Napi::Boolean::operator bool() const;
```
Returns the boolean primitive type of the corresponding `Napi::Boolean` object.
[`Napi::Value`]: ./value.md
|