I have this ES6 code, after I compile it with Babel to ES5 the this
inside .each
's call back becomes undefined
. How do I fix this problem?
let mediaBoxes = $(".now-thumbnail");
let titles = [];
mediaBoxes.each(() => {
let obj = {
index: i,
title: $(this).find(".now-thumbnail-bottomtext").text().trim()
};
titles.push(obj);
});