How to filter objects based on different keys and save the results into an array

I want to filter object based on key

var form = { code_ 1 : "C", 
             option_1 : "1321", 
             code_ 2 : "A", 
             option_2 : "1521", 
             code_ 3 : "B", 
             option_3 : "1121", 
             ...
           }

I want filter object and save into array.

code = ["C", "A", "B"]
option = ["1321", "1521", "1121"]

but I don’t how because there is a number in the attribute name.

90 thoughts on “How to filter objects based on different keys and save the results into an array”

Leave a Comment