Google V8 JavaScript Engine - How to set a value to null?
Using the V8 engine, h开发者_运维问答ow do I set a value to null
? Basically I want to return a variable from a C++ addon to JavaScript, and the variable needs to be set to null
under certain conditions.
You can explicitly return null
via v8::Null
:
return scope.Close( Null() );
Also, it turns out that if a Value
variable is declared, it is automatically assigned to undefined
. For example, the following returns undefined
back to JavaScript:
HandleScope scope;
Local<Value> result;
...
return scope.Close(result);
精彩评论