DOM 10

왜 for 루프는 작동하지 않고 forEach는 작동하는가?

const targetName = document.querySelectorAll('.name'); for(let i = 0; i < targetName.length; i++) { targetName[i].onClick = function() { for(let j = 0; j < arr.length; j++) { if(targetName[i].textContent === arr[j].firstName + ' ' + arr[j].lastName) { return printRole(arr[j]); } } } } //제대로 작동하지 않음 const targetName = document.querySelectorAll('.name'); targetName.forEach(function(el) { el.addEve..

알아볼 것 2020.10.12