jQuery/JavaScript/React - Access variable within nested loop

Danny Santos Source

I'm attempting to loop through a group of elements and then loop through a bunch of values. For some reason I can't access the element within the second loop, despite the fact that I have declared it outside of the loop:

populateSelect2Filters(key) {
  var _this = this

  $(`#multi-filter-${key}`).find('option').each(function(index, element){
    var el = element;

      // el is not defined


It is showing as an Uncaught ReferenceError: el is not defined. It's my understanding that this should be available?




comments powered by Disqus