Hello!
Tell me, please, how in javascript (without jQuery) in a forEach loop, fill the object with elements and put this received object into an array:
newArr = []; newObj = {}; Array.prototype.slice.call(document.querySelectorAll('#mydiv a')).forEach(function(e) { data = e.getAttribute('data'); //строка, например "Фрукты" value = e.innerHTML; //строка - "Апельсин" //тут надо вставить в объект полученные данные data и value }); As a result, you need to get an object inside the array of this structure:
newArr= [ {Фрукты: "Апельсин"}, {Овощи: "Томат"}; ] Thank!