function createResetHandler(player) {
const resetVideos = document.querySelectorAll('.exit');
for (let i = 0; i < resetVideos.length; i ++) {
resetVideos[i].addEventListener('click', function resetVideoHandler() {
player.destroy();
});
}
}
Originally using forEach:
function createResetHandler(player) {
const resetVideos = document.querySelectorAll('.exit');
resetVideos.forEach(function resetVideoHandler(video) {
video.addEventListener('click', function resetVideoHandler() {
player.destroy();
});
});
}
The warning seems to disappear if you assign player.destroy to a const variable within the loop. I suggest you read through the responses to this stackoverflow question and fully understand what the warning is about because I am also not very sure whether assigning the method to a variable within the loop is a solution or just a workaround.
for (let i = 0; i < resetVideos.length; i++) {
const destroy = player.destroy;
resetVideos[i].addEventListener('click', function resetVideoHandler() {
destroy();
});