Arefi Clayton Arefi Clayton - 1 year ago 106
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);

Thanks in advance

Answer Source

I found out.

Here it is:

obj->Set(String::NewFromUtf8(isolate, "msg"), v8::Integer::New(isolate, foo));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download