Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript remove junk element from array

let myArray = ["user1","user2", "", ""]
console.log(myArray)

function cleanArray(_array) {
  for (i in _array){
    if(_array[i] == ''){
      _array.splice(i, 1)
    }
  }
  return _array
}

console.log(cleanArray(cleanArray(myArray)))
 
PREVIOUS NEXT
Tagged: #javascript #remove #junk #element #array
ADD COMMENT
Topic
Name
7+2 =