I have an object array that looks like the following example. I want to create a duplicate of it without the data values.
var fruits = ['Apple', 'Banana'];
var now = new Date();
var x = [{ 'fruits': fruits },
{ 'producer': 'farmer john', 'address': '123 old patch road', 'zip': 90291 },
27, 'hm',
{ 'asked': now }
]
Now assuming there is some JavaScript function, the new object structure would be copied into the following:
var theStructure = [{ 'fruits': ['',''] },
{ 'producer': '', 'address': '', 'zip': NaN },
NaN, '',
{'asked': NaN }]
I have read the posting at How to copy an object's structure (but not the data) but don't see how to make it apply in my case. Perhaps the solution is a long hand parsing of the original object with case statements to handle each data type.
My application is in AngularJS incase there is a simple way to provide a solution.
0,1,2, etc..) but if it's an object you want them ({fruits: ''}, etc..). Edit: working withinstanceofso see if I can come up with a solution.