Array not really an array?

Here’s the setup

//oDataset is a dataset created by a recent query
var aNumbers = oDataset.getColumnAsArray(1); //Column 1 is a column of numbers;
var nMin = Math.min.apply(Math, aNumbers);

This will throw the following exception

TypeError: second argument to Function.prototype.apply must be an array

However, if you concatenate the result of getColumnAsArray to an empty array

//oDataset is a dataset created by a recent query
var aNumbers = [].concat(oDataset.getColumnAsArray(1)); //Column 1 is a column of numbers;
var nMin = Math.min.apply(Math, aNumbers);

it works just fine.

What’s going on here? getColumnAsArray doesn’t really return an array, just an array-like-object?

Servoy Version: 5.2.14 - build 1027

that returns a java Array (NativeJavaArray) those are quite the same as a native javascript array (NativeArray) for 97% of the use cases, but i guess not in this particular case.

If you do a concat then a new (real js array) is created and returned.

Interesting. I think this probably explains some issues I’ve had using the result of getColumnAsArray() with VelocityReports as well.

Logged the case at https://support.servoy.com/browse/SVY-3226