Remove Empty Elements From An Array With Javascript

Posted by Weston Ganger

I needed a method similar to ruby’s compact but for javascript.

Here I will describe how to easily do this with pure js.


var my_array = my_array.filter(function(x){
  return (x !== (undefined || null || ''));
});


Related External Links:

Article Topic:Software Development - Javascript

Date:January 05, 2016

Recommended Posts

Contact

604-309-8713
info@solidfoundationwebdev.com

Send Me A Message

I would love to get in touch and talk about your next project. Feel free to send a message and I will get back to you shortly.

Get Connected