Object to array (Without Null Elements)

Hello,

I am new coding…

I have this object from an API.

dateModified: "2016-07-18 22:06:00"
idDrink: "15997"
strAlcoholic: "Optional alcohol"
strCategory: "Ordinary Drink"
strCreativeCommonsConfirmed: "No"
strDrink: "GG"
strDrinkAlternate: null
strDrinkThumb: "https://www.thecocktaildb.com/images/media/drink/vyxwut1468875960.jpg"
strGlass: "Collins Glass"
strIBA: null
strImageAttribution: null
strImageSource: null
strIngredient1: "Galliano"
strIngredient2: "Ginger ale"
strIngredient3: "Ice"
strIngredient4: null
strIngredient5: null
strIngredient6: null
strIngredient7: null
strIngredient8: null
strIngredient9: null
strIngredient10: null
strIngredient11: null
strIngredient12: null
strIngredient13: null
strIngredient14: null
strIngredient15: null
strInstructions: "Pour the Galliano liqueur over ice. Fill the remainder of the glass with ginger ale and thats all there is to it. You now have a your very own GG."
strInstructionsDE: "Den Galliano-Likör über Eis gießen. Füllen Sie den Rest des Glases mit Ginger Ale und das ist alles, was dazu gehört. Du hast jetzt ein eigenes GG."
strInstructionsES: null
strInstructionsFR: null
strInstructionsIT: "Versare il liquore Galliano su ghiaccio.\r\nRiempi il resto del bicchiere con ginger ale e questo è tutto.\r\nOra hai il tuo GG personale."
strInstructionsZH-HANS: null
strInstructionsZH-HANT: null
strMeasure1: "2 1/2 shots "
strMeasure2: null
strMeasure3: null
strMeasure4: null
strMeasure5: null
strMeasure6: null
strMeasure7: null
strMeasure8: null
strMeasure9: null
strMeasure10: null
strMeasure11: null
strMeasure12: null
strMeasure13: null
strMeasure14: null
strMeasure15: null
strTags: null
strVideo: null
[[Prototype]]: Object

How I can create and array of object but excluding the null elements.

Some Drinks have 7 ingredients, some 4, but right now I am hard-coding this in the HTML and I would like to do it efficiently,

Thanks.

You can use a for in to loop through and see if the value is null.

If it’s null you can remove it with your preferred way
Not sure what you mean by array of object

Thanks for your answer, as far I know an array of object is something like this

[{ Name: "Bruce", lastName: "Wayne"}]

You want each key value pair as an element in the array? You can use a for loop for that.

So check if it’s null value if not put it in the array

Thanks,

Yes ,I finally did with a for loop few hours ago…

I found a cool video on YT…