I'm trying to use an arrow function within jQuery's map function. With the following titlesText is the correct length but each string is empty:
let titles = $(panelBody).find('h4');
let titlesText = $(titles).map(title => $(title).text());
My ES6 transpiling is working, and jQuery is working. Any ideas?
http://api.jquery.com/map/
The first argument to jQuery map is the index.
let testTitlesText = $(testTitles).map((index, testTitle) => $(testTitle).text());
Also as just a side note, you could use testTitle.innerText in the map to avoid creating a new jQuery object for each map invocation.
//testTitles is already a jQuery object, and you can use innerText
let testTitlesText = testTitles.map((index, testTitle) => testTitle.innerText);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With