Remove empty strings from array while keeping record Without Loop?

后端 未结 7 1605
臣服心动
臣服心动 2020-11-28 20:55

This question was asked here: Remove empty strings from array while keeping record of indexes with non empty strings

If you\'d notice the given as @Baz layed it out;

7条回答
  •  一生所求
    2020-11-28 21:26

    If are using jQuery, grep may be useful:


    var arr = [ a, b, c, , e, f, , g, h ];
    
    arr = jQuery.grep(arr, function(n){ return (n); });
    

    arr is now [ a, b, c, d, e, f, g];

提交回复
热议问题