I have a String array likes
var arr=["1","2",""];
arr.filter(Boolean);
arr.filter(function(e){return e != ""});
And I used one of these methods but that empty string still here. note: I'm using chrome.
Your code is working, you just need to correct type retunr to return and save modified array to variable
var arr=["1","2",""];
console.log(arr);
arr.filter(Boolean);
arr = arr.filter(function(e){return e != ""});
console.log(arr);
you can use arr.filter to filter a value. but if you are using IE then may be filter is not workng then you need to use pure javascript.
var arr=["1","2",""];
arr=arr.filter(function(o){ return o!=""});
console.log(arr);
output
(2) ["1", "2"]
var k=[];
for(var i=0;i<arr.length;i++){ if(arr[i]!=""){k.push(arr[i])}}
console.log(k);
retunr->returnfilter()method returns a new array, it doesn't work on the existing one by reference. As such you need to usearr = arr.filter(...