JavaScript version?
-
How out of date is the implementation of JavaScript with Qt 5.15.2 ?
Today I was working with a script and wanted to insert an item at the start of an array, the array already had content, there is a way of inserting an item into the front of the array using the unshift function. However this doesn't work as I've tried it today.
Here is an example:
var arySimon = [1,2,3,4]; arySimon.unshift(99);
Should result in arySimon containing:
99,1,2,3,4
Nothing is happening, unshift isn't doing anything. I'd just like to know for future reference which version of JavaScript is in use.
-
How out of date is the implementation of JavaScript with Qt 5.15.2 ?
Today I was working with a script and wanted to insert an item at the start of an array, the array already had content, there is a way of inserting an item into the front of the array using the unshift function. However this doesn't work as I've tried it today.
Here is an example:
var arySimon = [1,2,3,4]; arySimon.unshift(99);
Should result in arySimon containing:
99,1,2,3,4
Nothing is happening, unshift isn't doing anything. I'd just like to know for future reference which version of JavaScript is in use.
@SPlatten said in JavaScript version?:
How out of date is the implementation of JavaScript with Qt 5.15.2 ?
You can find it out here:
-
@SPlatten said in JavaScript version?:
How out of date is the implementation of JavaScript with Qt 5.15.2 ?
You can find it out here:
@KroMignon , thank you
-
Matter of fact is, it was added in the 6th version of ECMA and Qml uses the 7th one
So it should be part of the JS engine, and a quick test
Component.onCompleted:{ var array1 = [1, 2, 3]; console.log(array1) array1.unshift(5) console.log(array1); }
confirms with the output:
qml: [1,2,3] qml: [5,1,2,3]
-
@KroMignon , thank you
@SPlatten said in JavaScript version?:
thank you
Your welcome, by the way I just made a little test:
var myList = [1, 2, 3, 4] console.log("List start: " + myList) myList.unshift(99) console.log("List unshifted: " + myList)
Returns in console window (with Qt 5.12.10):
List start: 1,2,3,4 List unshifted: 99,1,2,3,4
-
@SPlatten said in JavaScript version?:
thank you
Your welcome, by the way I just made a little test:
var myList = [1, 2, 3, 4] console.log("List start: " + myList) myList.unshift(99) console.log("List unshifted: " + myList)
Returns in console window (with Qt 5.12.10):
List start: 1,2,3,4 List unshifted: 99,1,2,3,4