I have a javascript object on a page that contains some info. I need to loop through the object and copy it to another object.
Here is my starting code
var p_tag = {};
var new_tag = {};
p_tag.abc='abc';
p_tag.def='def';
p_tag.ghi='ghi';
for (var key in p_tag) {
if (p_tag.hasOwnProperty(key)) {
console.log(key + "'s favorite fruit is " + p_tag[key]);
}
}
I need to take the values from p_tag and copy them to new_tag as another object.
I may not know what keys are available on each page so looking for something that can go through all available p_tags and copy them to new_tag.
Thanks,