Skip to content

Instantly share code, notes, and snippets.

@joshthecoder
Forked from anonymous/gist:1359726
Created November 12, 2011 00:09
Show Gist options
  • Save joshthecoder/1359746 to your computer and use it in GitHub Desktop.
Save joshthecoder/1359746 to your computer and use it in GitHub Desktop.
static Persistent<Function> isNaN;
bool V8Util::isValueNaN(Handle<Value> value)
{
HandleScope scope;
if (isNaN.isEmpty()) {
Local<Object> global = Context::GetCurrent()->Global();
Local<Value> isNaNValue = global->Get(String::NewSymbol("isNaN"));
isNaN = Persistent<Function>::New(isNaNValue.As<Function>());
}
Handle<Value> args[] = { value };
return isNaN->Call(Handle<Object>(), 1, args)->BooleanValue();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment