Manipulating Arrays

Options

I have 2 arrays:

arrayA = [ 1, 2, 3, 4, 5]
arrayB = [1, 2, 3, 4]

I need to create a new array only with the value that does not have in the 2 arrays, in this case arrayC = [5], as in the example above.

How can I do this? Is there any way I can subtract one array by the other so that only the values are different from the 2 arrays?

Comments

  • Sean Montgomery
    Sean Montgomery Administrator

    ADMIN

    Options
    Hey Mauro,

    Good question. We will be adding some new filters later today to make this easier. Stay tuned!
  • Sean Montgomery
    Sean Montgomery Administrator

    ADMIN

    Options
    spoke too soon... ran into a hiccup with the build. we are going to be deploying this on monday.

    we will have filters to do a diff and an intersection. I'll reply back monday when the build is released.
  • Sean Montgomery
    Sean Montgomery Administrator

    ADMIN

    Options
     this is now live.

    there are 4 new filters that can help with this. 
    diff
    diff_assoc
    intersect
    intersect_assoc

    the assoc variants are more friendly if the object key is important. If you just care about the values, then use the first version.
  •  I tested it here, it worked. Thanks again.

    Feedback only. I think it's interesting to already add these new filters in the documentation with examples, this should reduce support. I always go there and do research when I have any questions or need to see if it's possible to solve a problem with the features that already exist in Xano.

    I know your implementation speed is super fast, but it can make support easier in the long term as the staff is reduced.
  • Prakash Chandran
    Prakash Chandran Administrator

    ADMIN

    Options
     Thanks for the feedback. We are in the process of a massive documentation overhaul for this exact reason and we promise you'll see it get a lot better in the coming weeks!