void MyFunction(const FunctionCallbackInfo& args) { Isolate* isolate = args.GetIsolate(); int result = doSomething(); args.GetReturnValue().Set(Number::New(isolate, result)); }
void MyFunction(const FunctionCallbackInfoThis code demonstrates how to use `GetReturnValue` to return a string value from a C++ function `MyFunction`. Both examples demonstrate the use of the `GetReturnValue` method to retrieve the return value of a function and set it to a specific type, allowing it to be returned to JavaScript code. This method is a part of the V8 engine, which is included in the Node.js runtime environment.& args) { Isolate* isolate = args.GetIsolate(); Local message = String::NewFromUtf8(isolate, "Hello world!"); args.GetReturnValue().Set(message); }