Javascript/jQuery: remove all non-numeric values from array
arrays, javascript, jquery
Solution
Use `array.filter()` and a callback function that checks if a value is numeric:
var arr2 = arr.filter(function(el) {
return el.length && el==+el;
// more comprehensive: return !isNaN(parseFloat(el)) && isFinite(el);
});
`array.filter` has a polyfill for older browsers like IE8.
Problem
For an array: `["5","something","","83","text",""]` How to remove all non-numeric and empty values from an array? Desired output: `["5","83"]`