Here you can find the source of isNumberArray()
'use strict';//from w w w . j a v a 2 s. c o m Array.prototype.isNumberArray = function() { return !this.some(x => typeof x != 'number'); } module.exports = function segmentNumbers(arr) { arr = arr.sort(); if (!arr.isNumberArray()) return []; let container = [], items = [], expectedVal = arr[0]; for (let i = 0 ; i <= arr.length - 1; i++) { if (arr[i] !== expectedVal) { if (items.length !== 0) { container.push(items); items = []; } } items.push(arr[i]); expectedVal = arr[i] + 1; } container.push(items); return container; }
Array.prototype.isInt = function (){ return this.filter(function(n){ return (typeof(n) === 'number') && (n%1 === 0)}) }; Array.prototype.even = function (){ return this.isInt().filter(function(n){ return n%2 === 0}) }; Array.prototype.odd = function (){ return this.isInt().filter(function(n){ return n%2 !== 0}) }; ...
Array.prototype.isLastIndex = function(index) { return index == (this.length - 1);
Array.prototype.isMember = function (b) { return this.some(function (i) { return this == i }, b);
Array.prototype.isNFromLastIndex = function(index, n) { return (this.length - 1 - n) == index;
Array.prototype.isNothing = function() { return this.length === 0; };
Array.prototype.isSparse = function() { return this.length !== Object.keys(this).length;