JSFiddle - React, Tailwind, and code Playground
by gutek
HTML
<div id="test"></div>
JavaScript
var org = document.getElementsByTagName;
document.getElementsByTagName = function(tag) {
console.log('getting tags:', tag);
return org.call(document, tag);
}
function insertDivs() {
var el, i, toins;
toins = document.getElementById('test');
for(i = 0; i < 100; i += 1) {
el = document.createElement('div');
//console.log(el);
toins.appendChild(el);
}
}
function test() {
var i, l;
console.group('wrong');
for(i = 0; i < document.getElementsByTagName('div').length; i += 1) {
}
console.groupEnd('wrong');
console.group('proper');
l = document.getElementsByTagName('div').length;
for(i = 0; i < l; i += 1) {
}
console.groupEnd('proper');
}
insertDivs();
test();