for(let i = 1; i <= 10; i++) {
const para = document.createElement('p');
para.textContent = 'This is paragraph ' + i + '.';
document.body.appendChild(para);
para.onclick = function() {
alert('Hello from paragraph ' + i + '!');
}
}
I tried it on 3 modern browsers (Firefox, Chrome and Edge) and i is reported to be the correct number of the paragraph and not 11.
On Internet Explorer it’s indeed reported to be 11.
that good one
but not sure my explanation is right or not
but i think it depend on how complicated is your nested function so if require huge process it could lead to that error
Am not sure what to state here. Have not used IE in well over a decade. MS stated support for IE will be dropped in 2021https://techcommunity.microsoft.com/t5/microsoft-365-blog/microsoft-365-apps-say-farewell-to-internet-explorer-11-and/ba-p/1591666.