The "pop" filter is not behaving as expected

Options
In JavaScript the "pop" method returns the last element in an array and then removes the last element from the array.

When working with an array in Xano function stack, the "pop" "filter" returns the last element of an array OK but doesn't remove the last element.
[pop 01.jpg][pop 02.jpg]
Then this also is strange.  The "Array remove from end" returns the last element but then empties the array.
[pop 03.jpg][pop 04.jpg]
I think this is a bug, not a feature.  But I'm a newbee and I don't always know how to do things the right way.

Thanks

Comments

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    

    In your 8.4.5.1. You are Updating the Variable var: qP1 with the the last value of your var: qParams. This is not updating your qParams variable at all, instead you are replacing your qP1 variable with result of what the pop filter would do to qParams.
    [CleanShot 2022-04-20 at 11.31.40.png]
    Array: Remove from End of Array - will remove the last element from the array and update it. If you want to return the last element in a variable then you need to specify a return variable in that function. 

    I've double-checked and this function is working correctly, so there may be some other logic in your function stack leading to an empty array (unless you have an array of 1 item).
  • David Richardson
    Options
    Hey Michael
    Still in trouble.

    I'm extracting text values from JSON and all that works fine.  Initially I create a CSV list and insert it in a table field.  The list will in most cases be 2 or three elements. 

    When a user uses that same bunch of check boxes any number of boxes can be checked but one might expect 2 to 5 maybe?  I want to put visitor values in an array.  Then with conditional statements insert the array values in the variables: pQ1, pQ2.... Those then are used in a GET all records query.  [pop 05.jpg] The stack extracts those values fine. 
    [pop 06.jpg]Then I use this part of the function stack[pop 07.jpg]I think I'm doing that right.  But I get this result:
    [pop 08.jpg]so the last value was popped off (airbrush) but now the qParams array is empty.  qParams would be the same running this again with the same three values.  There's nothing to alter qParams after 8.4.4.1

    I'd love to know what you're doing different!
    😀