To check if an object is an array with JavaScript you can use Array.isArray(obj)
(for browsers that support it), like JavaScriptCore implement it, you can write your own JSValueIsArray
function, like this :
bool JSValueIsArray(JSContextRef ctx, JSValueRef value)
{
if (JSValueIsObject(ctx, value))
{
JSStringRef name = JSStringCreateWithUTF8CString("Array");
JSObjectRef array = (JSObjectRef)JSObjectGetProperty(ctx, JSContextGetGlobalObject(ctx), name, NULL);
JSStringRelease(name);
name = JSStringCreateWithUTF8CString("isArray");
JSObjectRef isArray = (JSObjectRef)JSObjectGetProperty(ctx, array, name, NULL);
JSStringRelease(name);
JSValueRef retval = JSObjectCallAsFunction(ctx, isArray, NULL, 1, &value, NULL);
if (JSValueIsBoolean(ctx, retval))
return JSValueToBoolean(ctx, retval);
}
return false;
}