angularjsjqlite

How to get an array of elements from jqLite object


I'm trying to write a test that checks that I have 3 elements, each with a different value. I have found them in my compiled component using compiled.find('li'), but I am unable to then map because I have a jQLite object instead of a simple array.

How do I get an array of the found elements?


Solution

  • Use Object.assign:

    var arr = Object.assign([],jqLiteObj);
    

    Properties that parse as integers will be added to the array. Other properties will be added as named properties of the array object.

    For more information, see