使用 V8 引擎,如何将值设置为 null
?基本上我想从 C++ 插件返回一个变量到 JavaScript,并且在某些条件下需要将变量设置为 null
。
最佳答案
您可以通过 v8::Null
显式返回 null
:
return scope.Close( Null() );
此外,事实证明,如果声明了一个Value
变量,它会自动分配给undefined
。例如,以下将 undefined
返回给 JavaScript:
HandleScope scope;
Local<Value> result;
...
return scope.Close(result);
关于c++ - Google V8 JavaScript 引擎 - 如何将值设置为 null?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5386123/