코드:
결과보기 »
<!DOCTYPE html> <html lang="ko"> <head> <meta charset="UTF-8"> <title>JavaScript Array Object</title> </head> <body> <h1>reduceRight() 메소드</h1> <script> var arr = [1, 2, 3, 4, 5]; function sumOfValues(x, y) { return x - y; } document.write(arr.reduceRight(sumOfValues)); // 5 - 4 - 3 - 2 - 1 = -5 </script> </body> </html>