1

I have in a SSJS javascript a function that takes in a parameter. In the function I need to check what type of element the parameter is.

I can check for example if that type is an array:

if(false == values instanceof Array)

I notice that sometimes the incoming parameter is an ArrayList of strings. Is it possible to check against this type also in SSJS?

For now I just convert the object type before I send it to the function.

Knut Herrmann
  • 30,880
  • 4
  • 31
  • 67
Patrick Kwinten
  • 1,988
  • 2
  • 14
  • 26

1 Answers1

3

You can check with

values instanceof java.util.ArrayList

or with

values instanceof java.util.List

if you want to cover all sorts of Java Lists.

Knut Herrmann
  • 30,880
  • 4
  • 31
  • 67
  • 1
    In SSJS you either need to do `importPackage` or use the full Java class name (`java.util.ArrayList` rather than just `ArrayList`). It's one of the key reasons for coding in Java vs SSJS, being able to incorporate standard Java code more easily. – Paul Stephen Withers Nov 15 '18 at 13:04