void MyFunction(const FunctionCallbackInfo& args) { String::Utf8Value str(args[0]); printf("The string passed into MyFunction is: %s\n", *str); }
void MyFunction(const FunctionCallbackInfo& args) { Isolate* isolate = args.GetIsolate(); args.GetReturnValue().Set(String::NewFromUtf8(isolate, "Hello World")); }
void MyFunction(const FunctionCallbackInfoHere we use the ThrowException function to throw a TypeError exception in case the function was called with wrong arguments. Package library: Node.js/V8 engine& args) { Isolate* isolate = args.GetIsolate(); isolate->ThrowException(Exception::TypeError( String::NewFromUtf8(isolate, "Wrong arguments"))); }