From 83ad9b622b7732209c92d133d078dfe343120c14 Mon Sep 17 00:00:00 2001 From: Tobie Langel Date: Mon, 7 Sep 2009 19:29:04 +0200 Subject: [PATCH] doc: ported and updated old docs for Array#reverse. --- src/lang/array.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/lang/array.js b/src/lang/array.js index 671b975..ca86111 100644 --- a/src/lang/array.js +++ b/src/lang/array.js @@ -224,11 +224,24 @@ Array.from = $A; } /** - * Array#reverse([inline = false]) -> Array - * - inline (Boolean): Whether to modify the array in place. If `false`, - * clones the original array first. + * Array#reverse([inline = true]) -> Array + * - inline (Boolean): Whether to modify the array in place. Defaults to `true`. + * Clones the original array first when `false`. * - * Returns the reversed version of the array. + * Reverses the array's contents, optionally making a copy first. + * + * ### Examples + * + * // Making a copy + * var nums = [3, 5, 6, 1, 20]; + * var rev = nums.reverse(false); + * // nums -> [3, 5, 6, 1, 20] + * // rev -> [20, 1, 6, 5, 3] + * + * // Working inline + * var nums = [3, 5, 6, 1, 20]; + * nums.reverse(); + * // nums -> [20, 1, 6, 5, 3] **/ function reverse(inline) { return (inline !== false ? this : this.toArray())._reverse();