From ac1736227075a98b909b1a1d5d0ca6dfe7cf1a4f Mon Sep 17 00:00:00 2001 From: Olmo Maldonado Date: Thu, 30 Sep 2010 23:14:52 -0500 Subject: [PATCH] Small doc fixes. * Array.invoke note added * Object.merge != $merge, more like deepArrayMerge --- Docs/Types/Array.md | 8 ++++++++ Docs/Types/Object.md | 9 ++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Docs/Types/Array.md b/Docs/Types/Array.md index 1f90480d..655cf2ec 100644 --- a/Docs/Types/Array.md +++ b/Docs/Types/Array.md @@ -183,7 +183,12 @@ Returns an array with the named method applied to the array's contents. var foo = [4, 8, 15, 16, 23, 42]; var bar = foo.invoke('limit', 10, 30); //bar is now [10, 10, 15, 16, 23, 30] +### Notes: + +The method that is invoked is a method of each of the items. +If the method does not exist, then an error will be thrown. For example: + [0, false, 'string'].invoke('limit', 0, 10); // throws an error! Array method: every {#Array:every} ---------------------------- @@ -515,6 +520,9 @@ Appends the passed array to the end of the current array. var myOtherArray = ['green', 'yellow']; ['red', 'blue'].append(myOtherArray); // returns ['red', 'blue', 'green', 'yellow']; + myOtheArray; // is now ['red', 'blue', 'green', 'yellow']; + + [0, 1, 2].append([3, [4]]); // [0, 1, 2, 3, [4]] ### Notes: diff --git a/Docs/Types/Object.md b/Docs/Types/Object.md index e0714f60..67acdcfd 100644 --- a/Docs/Types/Object.md +++ b/Docs/Types/Object.md @@ -77,11 +77,6 @@ Merges any number of objects recursively without referencing them or their sub-o var nestedObj2 = {a: {b: 2}}; var nested = Object.merge(nestedObj1, nestedObj2); // returns: {a: {b: 2, c: 1}} -### Notes: - -This method is an object-specific equivalent of *$merge* from MooTools 1.2. - - Function: Object.clone {#Object:Object-clone} -------------------------------------- @@ -172,12 +167,12 @@ Get a subset of an object. ### Examples: - var obj = { + var object = { a: 'one', b: 'two', c: 'three' }; - Object.subset(['a', 'c']); // returns {a: 'one', c: 'three'} + Object.subset(object, ['a', 'c']); // returns {a: 'one', c: 'three'} -- 2.11.4.GIT