Arefi Clayton Arefi Clayton - 2 months ago 18
Node.js Question

Passing numeric element to object

I am working on a NodeJS addon project and i couldn't really understand how to pass a long value into my object.

Here is my code:

#include <node.h>
namespace NODEAPP
{
using v8::FunctionCallbackInfo;
using v8::Isolate;
using v8::Local;
using v8::Object;
using v8::String;
using v8::Value;
using v8::Handle;
void fooFunc(const FunctionCallbackInfo<Value>& args)
{
long foo = 51294;
long bar = 91923;
Isolate* isolate = args.GetIsolate();
Local<Object> obj = Object::New(isolate);
obj->Set(String::NewFromUtf8(isolate, "msg"), wanna pass foo here);
args.GetReturnValue().Set(obj);
}
}


Thanks in advance

Answer

I found out.

Here it is:

obj->Set(String::NewFromUtf8(isolate, "msg"), v8::Integer::New(isolate, foo));
Comments