docs: private static Scriptable js_concat(Context cx, Scriptable scope,
                                          Scriptable thisObj, Object[] args)
      {
          // create an empty Array to return.
          scope = getTopLevelScope(scope);
          Scriptable result = cx.newArray(scope, 0);
          if (thisObj instanceof NativeArray && result instanceof NativeArray) {
              NativeArray denseThis = (NativeArray) thisObj;
              NativeArray denseResult = (NativeArray) result;
              if (denseThis.denseOnly && denseResult.denseOnly) {
                  // First calculate length of resulting array
                  boolean canUseDense = true;
                  int length = (int) denseThis.length;
                  for (int i = 0; i < args.length && canUseDense; i++) {
                      if (args[i] instanceof NativeArray) {
                          // only try to use dense approach for Array-like
                          // objects that are actually NativeArrays
                          final NativeArray arg = (NativeArray) args[i];
                          canUseDense = arg.denseOnly;
                          length += arg.length;
                      } else {
                          length++;
                      }
                  }
                  if (canUseDense && denseResult.ensureCapacity(length)) {
                      System.arraycopy(denseThis.dense, 0, denseResult.dense,
                                       0, (int) denseThis.length);
                      int cursor = (int) denseThis.length;
                      for (int i = 0; i < args.length && canUseDense; i++) {
                          if (args[i] instanceof NativeArray) {
                              NativeArray arg = (NativeArray) args[i];
                              System.arraycopy(arg.dense, 0,
                                      denseResult.dense, cursor,
                                      (int)arg.length);
                              cursor += (int)arg.length;
                          } else {
                              denseResult.dense[cursor++] = args[i];
                          }
                      }
                      denseResult.length = length;
                      return result;
                  }
              }
          }
  
          long length;
          long slot = 0;
  
          /* Put the target in the result array; only add it as an array
           * if it looks like one.
           */
          if (js_isArray(thisObj)) {
              length = getLengthProperty(cx, thisObj, false);
  
              // Copy from the target object into the result
              for (slot = 0; slot < length; slot++) {
                  Object temp = getRawElem(thisObj, slot);
                  if (temp != NOT_FOUND) {
                      defineElem(cx, result, slot, temp);
                  }
              }
          } else {
              defineElem(cx, result, slot++, thisObj);
          }
  
          /* Copy from the arguments into the result.  If any argument
           * has a numeric length property, treat it as an array and add
           * elements separately; otherwise, just copy the argument.
           */
          for (int i = 0; i < args.length; i++) {
              if (js_isArray(args[i])) {
                  // js_isArray => instanceof Scriptable
                  Scriptable arg = (Scriptable)args[i];
                  length = getLengthProperty(cx, arg, false);
                  for (long j = 0; j < length; j++, slot++) {
                      Object temp = getRawElem(arg, j);
                      if (temp != NOT_FOUND) {
                          defineElem(cx, result, slot, temp);
                      }
                  }
              } else {
                  defineElem(cx, result, slot++, args[i]);
              }
          }
          setLengthProperty(cx, result, slot);
          return result;
      }