There is a code:
var ul = document.getElementById('products'), docfrag = document.createDocumentFragment(), products = [ { name: "test1", price: 240 }, { name: "test2", price: 250 }, { name: "test3", price: 260 }, { name: "test4", price: 270 }, { name: "test5", price: 280 }, { name: "test6", price: 290 } ]; products.forEach(function(e) { var div = document.createElement("div"); div.textContent = '<br>' + e.name + ' ' +e.price; docfrag.appendChild(div); }); ul.appendChild(docfrag); products.forEach(function(e) { if(e.price == 250) alert(e.name); return; }); <div id="products"> </div> How to make so that those would be output not as text, but transfer the string?