Does anyone know what type of object `context.valu...
# suitescript
s
Does anyone know what type of object
context.values
is in the reduce phase of a Map/Reduce script? It seems to act like an array, and I am able to use it like an array in code, but if I call
Array.isArray(context.values)
or
util.isArray(context.values)
I get false from both methods. Is it some kind of special Collection object specific to Rhino?
b
its probably a JavaArray
🧐 1
call Object.prototype.toString to see its class
s
thanks
Yes, it is a JavaArray. Are there any gotchas with just treating it like a plain old JS array? I haven't run into any so far. Rhino exposing Java types through JS script always seems very strange to me. Most of the time I try not to worry about or make use of JS engine-specific implementation features. I would hope Rhino makes the conversion back and forth seamless enough that I can continue to not worry about it.
b
it was more common in ss1, and generally the worst i saw was confusing error messages
you can probably use Array.slice if you are really worried
s
I think I am okay. Someone else ( a non-NetSuite developer ) made the suggestion that developers should check if an object is an array before using array methods on it. But I can just document that this is a special Object type that Rhino allows us to treat as an array. I think that will satisfy the code reviewer.