I want to evaluate my JS array through QJSValue and call required methods. For example: push, splice, etc... But calling Array.prototype.push (or others) has no effect.
//QQmlApplicationEngine myEngine;
auto arr = myEngine->evaluate("[1, 2, 3]");
qDebug() << arr.isArray(); //true
qDebug() << arr.property("length").toInt(); //3
qDebug() << arr.property("push").call({4, 5, 6}); //call Array.prototype.push
qDebug() << arr.property("length").toInt(); //3
What's wrong?
looks like to be JS with
thisset to theArrayinstance:Try to call the property with
thisset to thearrinstance: