With the following code duktape gives me a parse error for the for of loop.
string script = u8R"(var foo = [
"foo",
"bar"
]
for (var bar of foo) {
print(bar);
}
)";
if (duk_peval_string(ctx, script.c_str()) != 0)
{
printf("eval failed: %s\n", duk_safe_to_string(ctx, -1));
}
else
{
printf("result is: %s\n", duk_get_string(ctx, -1));
}
Is there a workaround for this? It also does this with buffers.
The solution to this was to run it through BabelJS. This was due to for...of being added in Es6 which is not supported in Duktape.