How to change object’s properties’ places?

I have an object playerInfoObject with properties w1 and w2, which are also objects.

I need to change their places between each other

They become equal when I’m trying to do this:

    var tmp = playerInfoObject.w1;
    playerInfoObject.w1 = playerInfoObject.w2;
    playerInfoObject.w2 = tmp;

How can I solve this problem?

Thank you in advance


Source: oop

Leave a Reply