1# CallbackInfo 2 3The object representing the components of the JavaScript request being made. 4 5The `Napi::CallbackInfo` object is usually created and passed by the Node.js runtime or node-addon-api infrastructure. 6 7The `Napi::CallbackInfo` object contains the arguments passed by the caller. The number of arguments is returned by the `Length` method. Each individual argument can be accessed using the `operator[]` method. 8 9The `SetData` and `Data` methods are used to set and retrieve the data pointer contained in the `Napi::CallbackInfo` object. 10 11## Methods 12 13### Constructor 14 15```cpp 16Napi::CallbackInfo::CallbackInfo(napi_env env, napi_callback_info info); 17``` 18 19- `[in] env`: The `napi_env` environment in which to construct the `Napi::CallbackInfo` object. 20- `[in] info`: The `napi_callback_info` data structure from which to construct the `Napi::CallbackInfo` object. 21 22### Env 23 24```cpp 25Napi::Env Napi::CallbackInfo::Env() const; 26``` 27 28Returns the `Env` object in which the request is being made. 29 30### NewTarget 31 32```cpp 33Napi::Value Napi::CallbackInfo::NewTarget() const; 34``` 35 36Returns the `new.target` value of the constructor call. If the function that was invoked (and for which the `Napi::NCallbackInfo` was passed) is not a constructor call, a call to `IsEmpty()` on the returned value returns true. 37 38### IsConstructCall 39 40```cpp 41bool Napi::CallbackInfo::IsConstructCall() const; 42``` 43 44Returns a `bool` indicating if the function that was invoked (and for which the `Napi::CallbackInfo` was passed) is a constructor call. 45 46### Length 47 48```cpp 49size_t Napi::CallbackInfo::Length() const; 50``` 51 52Returns the number of arguments passed in the `Napi::CallbackInfo` object. 53 54### operator [] 55 56```cpp 57const Napi::Value operator [](size_t index) const; 58``` 59 60- `[in] index`: The zero-based index of the requested argument. 61 62Returns a `Napi::Value` object containing the requested argument. 63 64### This 65 66```cpp 67Napi::Value Napi::CallbackInfo::This() const; 68``` 69 70Returns the JavaScript `this` value for the call 71 72### Data 73 74```cpp 75void* Napi::CallbackInfo::Data() const; 76``` 77 78Returns the data pointer for the callback. 79 80### SetData 81 82```cpp 83void Napi::CallbackInfo::SetData(void* data); 84``` 85 86- `[in] data`: The new data pointer to associate with this `Napi::CallbackInfo` object. 87 88Returns `void`. 89 90### Not documented here 91 92```cpp 93Napi::CallbackInfo::~CallbackInfo(); 94// Disallow copying to prevent multiple free of _dynamicArgs 95Napi::CallbackInfo::CallbackInfo(CallbackInfo const &) = delete; 96void Napi::CallbackInfo::operator=(CallbackInfo const &) = delete; 97``` 98