Value thisArg = ctx->argument(1);
bool ok = true;
for (uint k = 0; ok && k < instance->value.size(); ++k) {
+ Value v = instance->value.at(k);
+ if (v.isUndefined())
+ continue;
+
Value args[3];
- args[0] = instance->value.at(k);
+ args[0] = v;
args[1] = Value::fromNumber(k);
args[2] = ctx->thisObject;
Value r;
Value thisArg = ctx->argument(1);
bool ok = false;
for (uint k = 0; !ok && k < instance->value.size(); ++k) {
+ Value v = instance->value.at(k);
+ if (v.isUndefined())
+ continue;
+
Value args[3];
- args[0] = instance->value.at(k);
+ args[0] = v;
args[1] = Value::fromNumber(k);
args[2] = ctx->thisObject;
Value r;
{
Value self = ctx->thisObject;
if (ArrayObject *instance = self.asArrayObject()) {
- Q_UNIMPLEMENTED();
+ Value callback = ctx->argument(0);
+ if (! callback.isFunctionObject())
+ assert(!"type error");
+ else {
+ Value thisArg = ctx->argument(1);
+ ArrayObject *a = ctx->engine->newArrayObject()->asArrayObject();
+ a->value.resize(instance->value.size());
+ for (quint32 k = 0; k < instance->value.size(); ++k) {
+ Value v = instance->value.at(k);
+ if (v.isUndefined())
+ continue;
+ Value r;
+ Value args[3];
+ args[0] = v;
+ args[1] = Value::fromNumber(k);
+ args[2] = ctx->thisObject;
+ __qmljs_call_value(ctx, &r, &thisArg, &callback, args, 3);
+ a->value.assign(k, r);
+ }
+ ctx->result = Value::fromObject(a);
+ }
} else {
assert(!"generic implementation");
}
print([10, 20, 30].every(function (v,k,o) { return v > 9 }));
print([10, 20, 30].some(function (v,k,o) { return v == 20 }));
+print([10, 20, 30].map(function (v,k,o) { return v * v }));