Adam Cameron
leftbower
03/13/2022, 3:52 PMleftbower
03/13/2022, 3:57 PMdeactivateduser
03/13/2022, 4:17 PMbdw429s
03/14/2022, 4:46 PMisArray()
check-- so they are "arrays" at some high level.
I'd be reticent to call this a bug-- if I had to choose, I think I'd rather have BIFs favor returning a native CFML type SO LONG AS important behaviors weren't lost. i.e., if you were using a specific sub class of java.util.List with additional methods/behaviors, you'd not want that lost. But in this case, the original array wasn't even an instance of a Java class-- it was just a pure native array of strings.
[Ljava.lang.String;
So at any rate, a CFML array would be a superset of that. That's not to say there's another another example out there which may not be as desirable.David Buck
03/14/2022, 7:17 PMAdam Cameron
David Buck
03/14/2022, 10:06 PMmap()
function that is an instance method of the built-in Array
object. Like CF's arrayMap()
function, you can feed it objects that technically aren't JavaScript Arrays (via Array.prototype.map.call()
), but it always returns a JavaScript Array. I don't know if any other types of objects have a map()
method, but if they did, they'd presumably return their respective types instead of arrays.David Buck
03/14/2022, 10:12 PMconst obj = {0:"foo", 1:"bar", length:2};
console.log(obj); //returns Object { 0: "foo", 1: "bar", length: 2 }
console.log(Array.prototype.map.call(obj, x => x)); //Returns Array(2) [ "foo", "bar" ]
Adam Cameron