question: private Object reduceMethod ( Context cx , int id , Scriptable scope , Scriptable thisObj , Object [ ] args ) { Object callbackArg = args . length > 0 ? args [ 0 ] : Undefined . instance ; if ( callbackArg == null || ! ( callbackArg instanceof Function ) ) { throw ScriptRuntime . notFunctionError ( callbackArg ) ; } Function f = ( Function ) callbackArg ; Scriptable parent = ScriptableObject . getTopLevelScope ( f ) ; long length = getLengthProperty ( cx , thisObj ) ; long offset = id == Id_reduceRight ? length - 1 : 0 ; Object value = args . length > 1 ? args [ 1 ] : Scriptable . NOT_FOUND ; for ( long i = 0 ; i < length ; i ++ ) { Object elem = getRawElem ( thisObj , Math . abs ( i - offset ) ) ; if ( elem == Scriptable . NOT_FOUND ) { continue ; } if ( value == Scriptable . NOT_FOUND ) { value = elem ; } else { Object [ ] innerArgs = new Object [ 4 ] ; innerArgs [ 0 ] = value ; innerArgs [ 1 ] = elem ; innerArgs [ 2 ] = Long . valueOf ( i ) ; innerArgs [ 3 ] = thisObj ; value = f . call ( cx , parent , parent , innerArgs ) ; } } if ( value == Scriptable . NOT_FOUND ) { throw ScriptRuntime . typeError0 ( "msg.empty.array.reduce" ) ; } return value ; }
target:  Implements the methods "reduce" and "reduceRight".