jquery - do make arraylist from the array having value by javascript -
i have a = [1,2,3,4,5]
b = [2,3,5,6,1,7]
c = [1,2,43,67,8,7]
d = []
e = []
f = []
g = [5,8,9,3]
want x = [a,b,c,g]
use of jquery
a solution in plain javascript array#filter()
:
function clean(array) { return array.filter(function (a) { return a.length; }); } var = [1, 2, 3, 4, 5], b = [2, 3, 5, 6, 1, 7], c = [1, 2, 43, 67, 8, 7], d = [], e = [], f = [], g = [5, 8, 9, 3], x = clean([a, b, c, d, e, f, g]); document.write('<pre>' + json.stringify(x, 0, 4) + '</pre>');
Comments
Post a Comment