Announcement

Collapse
No announcement yet.

remove empty elements from an array in Javascript

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • mani
    replied
    the array filter method will solve this problem

    Code:
    const arr = [1,2,3,"",4,5,""]
    arr.filter(a=>a !== "")
    Click image for larger version

Name:	Screenshot 2021-09-29 at 2.46.08 PM.png
Views:	4
Size:	16.8 KB
ID:	894

    Leave a comment:


  • JavaScript
    started a topic remove empty elements from an array in Javascript

    remove empty elements from an array in Javascript

    remove empty elements from an array in Javascript

    example:

    Code:
    const arr = [1,2,3,"",4,5,""]

Related Topics

Collapse

Working...
X