开发者

Google V8 JavaScript Engine - How to set a value to null?

开发者 https://www.devze.com 2023-02-18 02:20 出处:网络
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 condition

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号