Monday, August 31, 2015

Thursday, August 27, 2015

ECMAScript 5 Array Methods

returned value array methods
undefined array.forEach(function)
a new array
a new array array.filter(predicate)
a boolean value array.every(predicate)
a boolean value array.some(predicate)
a value array.reduce(function[, initialValue])
a value array.reduceRight(function[, initialValue])
index|-1 array.indexOf(searchValue[, fromIndex])
index|-1 array.lastIndexOf(searchValue[, fromIndex])

Saturday, August 22, 2015

JavaScript Array Methods

1. Array Methods

returned valuearray methods
a string array.join([separator])
the array itself array.reverse()
the array itself array.sort([function])
a new array array.concat(value1[, value2[, ...]])
a new array array.slice(startIndex[,endIndex])
deleted elements array array.splice(startIndex, deleteCount[, value1[, value2[, ...]]])
the new length array.push(value1[, value2[, ...]])
the last element array.pop()
the new length array.unshift(value1[, value2[, ...]])
the first element array.shift()
a string array.toString()
a string array.toLocaleString()

Monday, August 10, 2015

JavaScript Arrays

A JavaScript array is an ordered collection of values: a value is called array's element, a value's numeric position is called the element's index.
JavaScript arrays indexes are 32-bits unsigned integer values: the index of the first element is 0, and the highest possible index is (232−2) ≡ 4,294,967,294.
Array values may be of any type and different types can be present in the same array.
JavaScript arrays are dynamic: they grow or shrink according to what is necessary.
A JavaScript array may be dense or sparse:
  • a dense array is an array whose element indexes are contiguous
  • a sparse array is an array whose element indexes are NOT contiguous: it have gaps/holes.
Every JavaScript arrays has a length property:
  • if the array is dense, the length property equals the number of elements and its value is one more than the highest index in the array.
  • if the array is sparse, the length property is greater than the number of elements.