How to remove null values from javascript object

+1 vote
asked Dec 13, 2012 in java script by codeg (2,600 points)


I have a javascript object that contains two arrays. Sometimes one of the arrays may be empty. I'm trying to loop through the object via a recursive function but I don't want any arrays that are empty or empty strings to enter the loop. What I have so far is producing the error Typeerror: obj.filter is not a function.

NOTE: obj is in this example has two arrays inside of it, but really, it could be anything that I pass into the function.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.