From 70dbcf39eb63bed58214ab4b93b56e29b4e709ae Mon Sep 17 00:00:00 2001 From: tjcrowder Date: Mon, 7 Sep 2009 12:42:24 +0100 Subject: [PATCH] doc: port old docs for Array#indexOf, update examples slightly --- src/lang/array.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/lang/array.js b/src/lang/array.js index 980b6b7..a3e7b4e 100644 --- a/src/lang/array.js +++ b/src/lang/array.js @@ -313,11 +313,22 @@ Array.from = $A; /** * Array#indexOf(item[, offset = 0]) -> Number * - item (?): A value that may or may not be in the array. - * - offset (Number): The number of initial items to skip before beginning the - * search. + * - offset (Number): The number of initial items to skip before beginning + * the search. * - * Returns the position of the first occurrence of `item` within the array — or - * `-1` if `item` doesn't exist in the array. + * Returns the index of the first occurrence of `item` within the array, + * or `-1` if `item` doesn't exist in the array. + * + * ### Examples + * + * [3, 5, 6, 1, 20].indexOf(1) + * // -> 3 + * + * [3, 5, 6, 1, 20].indexOf(90) + * // -> -1 (not found) + * + * ['1', '2', '3'].indexOf(1); + * // -> -1 (not found, 1 !== '1') **/ function indexOf(item, i) { i || (i = 0);