JSFiddle - React, Tailwind, and code Playground

by gutek

JavaScript

var org = document.getElementsByTagName;
document.getElementsByTagName = function(tag) {
    console.log('getting tags: ', tag);
    return org(tag);
}

function insertDivs() {
    var el, i;
    for(i = 0; i < 100; i += 0) {
        el = document.createElement('div');
        document.body.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();