From 2db40234885cc245c2f7a319fdab4ecd81f5244a Mon Sep 17 00:00:00 2001
From: Arsen Melikyan <bugron@mail.ru>
Date: Tue, 17 Nov 2015 00:36:58 +0400
Subject: [PATCH] add new articles

---
 Array.isArray.md                  | 36 +++++++++++++++++++
 Math.max.md                       | 35 ++++++++++++++++++
 Math.min.md                       | 33 +++++++++++++++++
 js-Array-prototype-concat.md      | 40 +++++++++++++++++++++
 js-Array-prototype-every.md       | 67 +++++++++++++++++++++++++++++++++++
 js-Array-prototype-forEach.md     | 57 ++++++++++++++++++++++++++++++
 js-Array-prototype-lastIndexOf.md | 65 ++++++++++++++++++++++++++++++++++
 js-Array-prototype-reduce.md      | 72 +++++++++++++++++++++++++++++++++++++
 js-Array-prototype-sort.md        | 74 +++++++++++++++++++++++++++++++++++++++
 js-Array-prototype-splice.md      | 43 +++++++++++++++++++++++
 10 files changed, 522 insertions(+)
 create mode 100644 Array.isArray.md
 create mode 100644 Math.max.md
 create mode 100644 Math.min.md
 create mode 100644 js-Array-prototype-concat.md
 create mode 100644 js-Array-prototype-every.md
 create mode 100644 js-Array-prototype-forEach.md
 create mode 100644 js-Array-prototype-lastIndexOf.md
 create mode 100644 js-Array-prototype-reduce.md
 create mode 100644 js-Array-prototype-sort.md
 create mode 100644 js-Array-prototype-splice.md

diff --git a/Array.isArray.md b/Array.isArray.md
new file mode 100644
index 0000000..ab41c2f
--- /dev/null
+++ b/Array.isArray.md
@@ -0,0 +1,36 @@
+# Array.isArray
+The `Array.isArray()` method returns `true` if an object is an array, `false` if it is not.
+
+## Syntax
+```js
+Array.isArray(obj)
+```
+
+### Parameters
+
+**obj**
+The object to be checked. 
+
+[MDN link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray) | [MSDN link](https://msdn.microsoft.com/en-us/LIBRary/ff848265%28v=vs.94%29.aspx)
+
+## Examples
+
+```js
+// all following calls return true
+Array.isArray([]);
+Array.isArray([1]);
+Array.isArray(new Array());
+// Little known fact: Array.prototype itself is an array:
+Array.isArray(Array.prototype); 
+
+// all following calls return false
+Array.isArray();
+Array.isArray({});
+Array.isArray(null);
+Array.isArray(undefined);
+Array.isArray(17);
+Array.isArray('Array');
+Array.isArray(true);
+Array.isArray(false);
+Array.isArray({ __proto__: Array.prototype });
+```
diff --git a/Math.max.md b/Math.max.md
new file mode 100644
index 0000000..8dbedac
--- /dev/null
+++ b/Math.max.md
@@ -0,0 +1,35 @@
+# Math.max()
+The `Math.max()` function returns the largest of zero or more numbers.
+
+## Syntax
+```js
+Math.max(value1, value2, ...)
+```
+
+### Parameters
+`value1`, `value2` and other arguments should be numbers. All arguments are optional.
+
+If no arguments are given, the result is Infinity.
+If at least one of arguments cannot be converted to a number, the result is NaN.
+
+[MDN link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max) | [MSDN link](https://msdn.microsoft.com/en-us/LIBRary/dxcwky7y%28v=vs.94%29.aspx)
+
+## Examples
+
+```js
+Math.max();         // Infinity
+Math.max('a');      // NaN
+Math.max(NaN);      // NaN
+Math.max(5);        // 5
+Math.max(10, 20);   //  20
+Math.max(-10, -20); // -10
+Math.max(-10, 20);  //  20
+```
+
+```js
+var x = Math.max(107 - 3,  48 * 90);
+document.write(x);
+
+// Output:
+// 4320
+```
diff --git a/Math.min.md b/Math.min.md
new file mode 100644
index 0000000..eb15386
--- /dev/null
+++ b/Math.min.md
@@ -0,0 +1,33 @@
+# Math.min()
+The `Math.min()` function returns the smallest of zero or more numbers.
+
+## Syntax
+```js
+Math.min(value1, value2, ...)
+```
+
+### Parameters
+`value1`, `value2` and other arguments should be numbers. All arguments are optional.
+
+If no arguments are given, the result is Infinity.
+If at least one of arguments cannot be converted to a number, the result is NaN.
+
+[MDN link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min) | [MSDN link](https://msdn.microsoft.com/en-us/LIBRary/7x8968dh%28v=vs.94%29.aspx)
+
+## Examples
+
+```js
+Math.min();         // Infinity
+Math.min('a');      // NaN
+Math.min(NaN);      // NaN
+Math.min(5);        // 5
+Math.min(-1, 10);   // -1
+```
+
+```js
+var x = Math.min(107 - 3,  48 * 90);
+document.write(x);
+
+// Output:
+// 104
+```
diff --git a/js-Array-prototype-concat.md b/js-Array-prototype-concat.md
new file mode 100644
index 0000000..ef80370
--- /dev/null
+++ b/js-Array-prototype-concat.md
@@ -0,0 +1,40 @@
+# js Array prototype concat
+The `concat()` method returns a new array comprised of the array on which it is called joined with the array(s) and/or value(s) provided as arguments.
+
+## Syntax
+```js
+var new_array = old_array.concat(value1[, value2[, ...[, valueN]]])
+```
+
+### Parameters
+
+**valueN**
+
+Arrays and/or values to concatenate into a new array. See the description below for details. 
+
+[MDN link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat) | [MSDN link](https://msdn.microsoft.com/en-us/LIBRary/2e06zxh0%28v=vs.94%29.aspx)
+
+##Description
+`concat` creates a new array consisting of the elements in the object on which it is called, followed in order by, for each argument, the elements of that argument (if the argument is an array) or the argument itself (if the argument is not an array).
+
+## Examples
+
+```js
+var alpha = ['a', 'b', 'c'];
+var alphaNumeric = alpha.concat(1, [2, 3]);
+
+console.log(alphaNumeric); 
+// Result: ['a', 'b', 'c', 1, 2, 3]
+```
+
+```js
+var a, b, c, d;
+a = new Array(1,2,3);
+b = "dog";
+c = new Array(42, "cat");
+d = a.concat(b, c);
+document.write(d);
+
+//Output: 
+1, 2, 3, "dog", 42, "cat"
+```
diff --git a/js-Array-prototype-every.md b/js-Array-prototype-every.md
new file mode 100644
index 0000000..ea3b570
--- /dev/null
+++ b/js-Array-prototype-every.md
@@ -0,0 +1,67 @@
+# js Array prototype every
+The `every()` method tests whether all elements in the array pass the test implemented by the provided function.
+
+## Syntax
+```js
+arr.every(callback[, thisArg])
+```
+
+### Parameters
+
+- **callback**
+    Function to test for each element, taking three arguments:
+
+ - **currentValue** (required)
+        The current element being processed in the array.
+ - **index** (optional)
+        The index of the current element being processed in the array.
+ - **array** (optional)
+        The array every was called upon.
+
+- **thisArg**
+    Optional. Value to use as this when executing callback. 
+
+[MDN link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every) | [MSDN link](https://msdn.microsoft.com/en-us/LIBRary/ff679981%28v=vs.94%29.aspx)
+
+##Description
+The `every` method calls the `callback` function one time for each array element, in ascending index order, until the `callback` function returns false. If an element that causes `callback` to return false is found, the every method immediately returns `false`. Otherwise, the every method returns `true`.
+
+The callback function is not called for missing elements of the array.
+
+In addition to array objects, the every method can be used by any object that has a length property and that has numerically indexed property names.
+`every` does not mutate the array on which it is called.
+
+## Examples
+
+```js
+function isBigEnough(element, index, array) {
+  return element >= 10;
+}
+[12, 5, 8, 130, 44].every(isBigEnough);   // false
+[12, 54, 18, 130, 44].every(isBigEnough); // true
+```
+
+```js
+// Define the callback function.
+function CheckIfEven(value, index, ar) {
+    document.write(value + " ");
+
+    if (value % 2 == 0)
+        return true;
+    else
+        return false;
+}
+
+// Create an array.
+var numbers = [2, 4, 5, 6, 8];
+
+// Check whether the callback function returns true for all of the
+// array values.
+if (numbers.every(CheckIfEven))
+    document.write("All are even.");
+else
+    document.write("Some are not even.");
+
+// Output:
+// 2 4 5 Some are not even.
+```
diff --git a/js-Array-prototype-forEach.md b/js-Array-prototype-forEach.md
new file mode 100644
index 0000000..9ef3252
--- /dev/null
+++ b/js-Array-prototype-forEach.md
@@ -0,0 +1,57 @@
+# js Array prototype forEach
+The `forEach()` method executes a provided function once per array element.
+
+## Syntax
+```js
+arr.forEach(callback[, thisArg])
+```
+
+### Parameters
+
+
+- **callback**
+    Function to execute for each element, taking three arguments:
+
+ - **currentValue**
+        The current element being processed in the array.
+ - **index**
+        The index of the current element being processed in the array.
+ - **array**
+        The array that forEach is being applied to.
+
+- **thisArg**
+    Optional. Value to use as this when executing callback. 
+
+[MDN link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) | [MSDN link](https://msdn.microsoft.com/en-us/LIBRary/ff679980%28v=vs.94%29.aspx)
+
+##Description
+`forEach()` executes the provided callback once for each element present in the array in ascending order. It is not invoked for index properties that have been deleted or are uninitialised (i.e. on sparse arrays). Unlike `map()` or `reduce()` it always returns the value `undefined` and is not *chainable*. The typical use case is to execute side effects at the end of a chain.
+
+## Examples
+
+```js
+function logArrayElements(element, index, array) {
+  console.log('a[' + index + '] = ' + element);
+}
+
+// Note elision, there is no member at 2 so it isn't visited
+[2, 5, , 9].forEach(logArrayElements);
+// logs:
+// a[0] = 2
+// a[1] = 5
+// a[3] = 9
+```
+
+```js
+// Create an array.
+var numbers = [10, 11, 12];
+
+// Call the addNumber callback function for each array element.
+var sum = 0;
+numbers.forEach(
+    function addNumber(value) { sum += value; }
+);
+
+document.write(sum);
+// Output: 33
+```
diff --git a/js-Array-prototype-lastIndexOf.md b/js-Array-prototype-lastIndexOf.md
new file mode 100644
index 0000000..f5a25cd
--- /dev/null
+++ b/js-Array-prototype-lastIndexOf.md
@@ -0,0 +1,65 @@
+# js Array prototype lastIndexOf
+The `lastIndexOf()` method returns the last index at which a given element can be found in the array, or -1 if it is not present. The array is searched backwards, starting at `fromIndex`.
+
+## Syntax
+```js
+arr.lastIndexOf(searchElement[, fromIndex = arr.length - 1])
+```
+
+### Parameters
+
+- **searchElement**
+ - Element to locate in the array.
+- **fromIndex**
+ - *Optional*. The index at which to start searching backwards. Defaults to the array's length minus one, i.e. the whole array will be searched. If the index is greater than or equal to the length of the array, the whole array will be searched. If negative, it is taken as the offset from the end of the array. Note that even when the index is negative, the array is still searched from back to front. If the calculated index is less than 0, -1 is returned, i.e. the array will not be searched. 
+
+[MDN link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf) | [MSDN link](https://msdn.microsoft.com/en-us/LIBRary/ff679972%28v=vs.94%29.aspx)
+
+##Returns
+The index of the last occurrence of `searchElement` in the array, or -1 if `searchElement` is not found.
+
+##Description
+`lastIndexOf` compares `searchElement` to elements of the Array using strict equality (the same method used by the ===, or triple-equals, operator).
+
+##Remarks
+The search occurs in descending index order (last member first). To search in ascending order, use the `indexOf` method.
+
+The optional `fromIndex` argument specifies the array index at which to begin the search. If `fromIndex` is greater than or equal to the array length, the whole array is searched. If `fromIndex` is negative, the search starts at the array length plus `fromIndex`. If the computed index is less than 0, -1 is returned.
+
+## Examples
+
+```js
+var array = [2, 5, 9, 2];
+array.lastIndexOf(2);     // 3
+array.lastIndexOf(7);     // -1
+array.lastIndexOf(2, 3);  // 3
+array.lastIndexOf(2, 2);  // 0
+array.lastIndexOf(2, -2); // 0
+array.lastIndexOf(2, -1); // 3
+```
+
+```js
+// Create an array.
+var ar = ["ab", "cd", "ef", "ab", "cd"];
+
+// Determine the first location, in descending order, of "cd".
+document.write(ar.lastIndexOf("cd") + "<br/>");
+
+// Output: 4
+
+// Find "cd" in descending order, starting at index 2.
+document.write(ar.lastIndexOf("cd", 2) + "<br/>");
+
+// Output: 1
+
+// Search for "gh" (which is not found).
+document.write(ar.lastIndexOf("gh")+ "<br/>");
+
+// Output: -1
+
+// Find "ab" with a fromIndex argument of -3.
+// The search in descending order starts at index 3,
+// which is the array length minus 2.
+document.write(ar.lastIndexOf("ab", -3) + "<br/>");
+// Output: 0
+```
diff --git a/js-Array-prototype-reduce.md b/js-Array-prototype-reduce.md
new file mode 100644
index 0000000..c111a29
--- /dev/null
+++ b/js-Array-prototype-reduce.md
@@ -0,0 +1,72 @@
+# js Array prototype reduce
+The `reduce()` method applies a function against an accumulator and each value of the array (from left-to-right) to reduce it to a single value.
+
+## Syntax
+```js
+arr.reduce(callback[, initialValue])
+```
+
+### Parameters
+
+- **callback**
+    Function to execute on each value in the array, taking four arguments:
+
+ - **previousValue**
+ The value previously returned in the last invocation of the callback, or initialValue, if supplied. (See below.)
+ - **currentValue**
+        The current element being processed in the array.
+ - **currentIndex**
+        The index of the current element being processed in the array.
+ - **array**
+        The array reduce was called upon.
+
+- **initialValue**
+    Optional. Value to use as the first argument to the first call of the callback. 
+
+[MDN link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce) | [MSDN link](https://msdn.microsoft.com/en-us/LIBRary/ff679975%28v=vs.94%29.aspx)
+
+##Returns
+The accumulated result from the last call to the callback function.
+
+##Description
+Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
+
+##Remarks
+If an `initialValue` is provided, the reduce method calls the `callback` function one time for each element present in the array, in ascending index order. If an `initialValue` is not provided, the reduce method calls the `callback` function on each element, starting with the second element.
+
+The return value of the callback function is provided as the `previousValue` argument on the next call to the callback function. The return value of the last call to the callback function is the return value of the `reduce` method.
+
+The callback function is not called for missing elements of the array.
+
+## Examples
+
+```js
+var total = [0, 1, 2, 3].reduce(function(a, b) {
+  return a + b;
+});
+// total == 6
+
+var flattened = [[0, 1], [2, 3], [4, 5]].reduce(function(a, b) {
+  return a.concat(b);
+}, []);
+// flattened is [0, 1, 2, 3, 4, 5]
+```
+
+```js
+// Define the callback function.
+function appendCurrent (previousValue, currentValue) {
+    return previousValue + "::" + currentValue;
+    }
+
+// Create an array.
+var elements = ["abc", "def", 123, 456];
+
+// Call the reduce method, which calls the callback function
+// for each array element.
+var result = elements.reduce(appendCurrent);
+
+document.write(result);
+
+// Output:
+//  abc::def::123::456
+```
diff --git a/js-Array-prototype-sort.md b/js-Array-prototype-sort.md
new file mode 100644
index 0000000..7e63c4f
--- /dev/null
+++ b/js-Array-prototype-sort.md
@@ -0,0 +1,74 @@
+# js Array prototype sort
+The `sort()` method sorts the elements of an array *in place* and returns the sorted array.
+
+## Syntax
+```js
+arr.sort([compareFunction])
+```
+
+### Parameters
+| Parameter  |           Description                         |   Necessity   |
+|------------|-----------------------------------------------|---------------|
+|  compareFunction    | Optional. The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, Unicode character order.  |   Optional    |
+
+[MDN link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) | [MSDN link](https://msdn.microsoft.com/en-us/LIBRary/4b4fbfhk%28v=vs.94%29.aspx)
+
+##Returns
+The sorted array.
+
+##Remarks
+
+The `sort` method sorts the `Array` object in place; no new `Array` object is created during execution.
+
+If you supply a function in the `compareFunction` argument, it must return one of the following values:
+
+* A negative value if the first argument passed is less than the second argument.
+
+* Zero if the two arguments are equivalent.
+
+* A positive value if the first argument is greater than the second argument. 
+
+## Examples
+
+```js
+var fruit = ['cherries', 'apples', 'bananas'];
+fruit.sort(); // ['apples', 'bananas', 'cherries']
+
+var scores = [1, 10, 2, 21]; 
+scores.sort(); // [1, 10, 2, 21]
+// Watch out that 10 comes before 2,
+// because '10' comes before '2' in Unicode code point order.
+
+var things = ['word', 'Word', '1 Word', '2 Words'];
+things.sort(); // ['1 Word', '2 Words', 'Word', 'word']
+// In Unicode, numbers come before upper case letters,
+// which come before lower case letters.
+```
+
+```js
+var a = new Array(4, 11, 2, 10, 3, 1);
+
+var b = a.sort();
+document.write(b);
+document.write("<br/>");
+
+// This is ASCII character order.
+// Output: 1,10,11,2,3,4)
+
+// Sort the array elements with a function that compares array elements.
+b = a.sort(CompareForSort);
+document.write(b);
+document.write("<br/>");
+// Output: 1,2,3,4,10,11.
+
+// Sorts array elements in ascending order numerically.
+function CompareForSort(first, second)
+{
+    if (first == second)
+        return 0;
+    if (first < second)
+        return -1;
+    else
+        return 1; 
+}
+```
diff --git a/js-Array-prototype-splice.md b/js-Array-prototype-splice.md
new file mode 100644
index 0000000..7eaeaf5
--- /dev/null
+++ b/js-Array-prototype-splice.md
@@ -0,0 +1,43 @@
+# js Array prototype splice
+This method changes array's content by removing existing elements and/or adding new elements.
+
+## Syntax
+```js
+array.splice(start, deleteCount[, item1[, item2[, ...]]])
+```
+
+### Parameters
+| Parameter  |           Description                         |   Necessity   |
+|------------|-----------------------------------------------|---------------|
+|  start  | Index at which to start changing the array.                           |   Required    |
+|  deleteCount    | An integer indicating the number of old array elements to remove. If deleteCount is 0, no elements are removed. In this case, you should specify at least one new element. |   Required    |
+|  itemN    | The element to add to the array. If you don't specify any elements, splice() will only remove elements from the array. |   Optional    |
+
+[MDN link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice) | [MSDN link](https://msdn.microsoft.com/en-us/LIBRary/wctc5k7s%28v=vs.94%29.aspx)
+
+##Returns
+An array containing the deleted elements. If only one element is removed, an array of one element is returned. If no elements are removed, an empty array is returned.
+
+## Examples
+
+```js
+var arr = new Array("4", "11", "2", "10", "3", "1");
+arr.splice(2, 2, "21", "31");
+document.write(arr);
+
+// Output: 4,11,21,31,3,1
+```
+
+```js
+var myFish = ['angel', 'clown', 'mandarin', 'surgeon'];
+
+// removes 0 elements from index 2, and inserts 'drum'
+var removed = myFish.splice(2, 0, 'drum');
+// myFish is ['angel', 'clown', 'drum', 'mandarin', 'surgeon']
+// removed is [], no elements removed
+
+// removes 1 element from index 3
+removed = myFish.splice(3, 1);
+// myFish is ['angel', 'clown', 'drum', 'surgeon']
+// removed is ['mandarin']
+```
