|
|
|
ii. Set kPresent ( O , Pk ). iii. If kPresent is true , then 1. Set accumulator O , Pk ). iv. Set k to k - 1. c. If kPresent is false , throw a TypeError exception. 9. Repeat, while k
≥ 0, a. Let Pk be ! ( k )). b. Let kPresent ( O , Pk ). c. If kPresent is true , then i. Let kValue be ? ( O , Pk ). ii. Set accumulator ( callbackfn , undefined , « accumulator , kValue k ), O »). d. Set k to k - 1. 10. Return accumulator . NOTE 2 NOTE 1 When the reverse reverse method is called, the following steps are taken: 1. Let O be ? this value). 2. Let len be ? ( O ). 3. Let middle ( len / 2). 4. Let lower be 0. 5. Repeat, while lower
≠
middle , a. Let upper be len - lower - 1. b. Let upperP ( upper )). c. Let lowerP ( lower )). d. Let lowerExists ( O , lowerP ). e. If lowerExists is true , then i. Let lowerValue O , lowerP ). f. Let upperExists ( O , upperP ). g. If upperExists is true , then i. Let upperValue O , upperP ). h. If lowerExists is true and upperExists is true , then i. Perform ? ( O , lowerP , upperValue , true ). ii. Perform ? ( O , upperP , lowerValue , true ). i. Else if lowerExists is false and upperExists is true , then i. Perform ? ( O , lowerP , upperValue , true ). ii. Perform ? O , upperP ). j. Else if lowerExists is true and upperExists is false , then i. Perform ? O , lowerP ). ii. Perform ? ( O , upperP , lowerValue , true ). The reduceRight reduceRight function is intentionally generic; it does not require that its this value be an Array object. Therefore it can be transferred to other kinds of objects for use as a method. The elements of the array are rearranged so as to reverse their order. The object is returned as the 23.1.3.23 Array.prototype.reverse ( ) 653 |