Uncaught TypeError: undefined has no properties

Who can help with the question? Called when trying to open an image

The error is in this line of code

: srcset[srcset.length – 1])[0];

thanks

$(document).on('click', '.fancy-srcset', function (e) {
        e.preventDefault();
        var fancyGroup = e.currentTarget.dataset.fancyboxGroup;
        var fancyElements = !fancyGroup
            ? [].slice.call(e.currentTarget.parentElement.children)
            : [].slice.call(e.currentTarget.parentElement.parentElement.querySelectorAll('[data-fancybox-group="' + fancyGroup + '"]'));
        var size = '400';
        ['576', '768', '992', '1200'].every(function (screenSize) {
            if (window.matchMedia('(min-width: ' + screenSize + 'px)').matches) {
                size = screenSize;
                return true;
            }
            return false;
        });
        $.fancybox(
            fancyElements.map(function (fancyElement) {
                var srcset = fancyElement.dataset.srcset.split(', ').map(function (elem) {
                    return elem.split(' ');
                });
                return (size
                    ? srcset.find(function (elem) {
                        return elem[1] === size + 'w';
                    })
                    : srcset[srcset.length - 1])[0];
            }),
            {
                index: fancyElements.indexOf(e.currentTarget)
            }
        );
    });

enter image description here

137 thoughts on “Uncaught TypeError: undefined has no properties”

  1. Pingback: cheapest viagra
  2. Pingback: order viagra
  3. Excellent read, I just passed this onto a friend who was doing a little research on that. And he just bought me lunch because I found it for him smile So let me rephrase that: Thank you for lunch! “Love is made in heaven and consummated on earth.” by John Lyly.

    Reply
  4. Pingback: cialis discount
  5. Pingback: cialis no pres
  6. Pingback: viagra samples
  7. Pingback: sildenafil citrate
  8. Pingback: viagra pornhub
  9. Pingback: women take viagra
  10. Pingback: viagra men
  11. Pingback: viagra women
  12. Pingback: viagra prices
  13. Pingback: viagra alternative
  14. Pingback: cialis or viagra
  15. Pingback: cvs viagra
  16. Pingback: cost of viagra
  17. Pingback: cialis prices