Skip to content

Instantly share code, notes, and snippets.

@giannispan
Created February 1, 2016 17:13
Show Gist options
  • Save giannispan/56c1e3c9cd3ad52b273b to your computer and use it in GitHub Desktop.
Save giannispan/56c1e3c9cd3ad52b273b to your computer and use it in GitHub Desktop.
Is Integer Array ?
function isIntArray(arr) {
console.log(arr);
if (arr == null) return false;
if (arr.constructor !== Array || arr == null) return false;
if (arr.length < 1) return true;
for (var i = 0; i < arr.length; i++)
if ((arr[i] % 1 != 0)) return false;
else
var check = isInt(arr[i]);
return check;
}
function isInt(value) {
return !isNaN(value) && Number.isInteger(value) && (value.toFixed(0) % 1 == 0) &&
parseInt(Number(value)) == value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment