MV Named parameters? [SOLVED]

I put this in RMMV but I'm pretty sure it's a general question but well, anyways...

Hello ^^ This is probably a noob question but I am a noob so here it is:
For context, I have this function:
Code:
$.move = function(name, x=0, y=0, scale = 100, dur=60) {
        var moveId = $.getId(name);
        for (i = 0; i <= moveId.length - 1; i++) {
            $gameScreen.movePicture(moveId[i], 0, x, y, scale, scale, 255, 0, dur);
        }
    }

Suppose, I want to call this function but I want to use only name, x and dur. Everything else can keep their default value. In python you can just do $.move('randome name', x=500, dur=30) but I guess it's not possible in js (it is. I didn't know) TT Any ideas?
In this case I would use or operand (||) where values are used.

$.move = function (name, x, y, scale, dur) {
var moveId = $.getId(name);
for (i = 0; i <= moveId.length - 1; i++) {
$gameScreen.movePicture(moveId, 0, x || 0, y || 0, scale || 100, scale || 100, 255, 0, dur || 60);
}
}

Edit: Though this solution won't allow 0 parameters to scale and dur 🙂
That's it! Thank you ^^
That's it! Thank you ^^
the x= 0 in parameter is not an named parameters but an Default parameter which make if you do not include it it will spawn its default value.

its the same as : this.x = x || 0;
it's a shortend for optional parameters.

EDIT : wtf it pasted a old quote
I tried doing what @OcRam said but it seems they need to be in order? I did $.move('a1 norm', x=500, dur=30)
The pictures were moving strange so I console.logged the values. y is 30 (which should be dur)! So I guess they need to be in order. *sigh*

Any way to like, make it not depend on order? Because now I have to type in the entire thing just to make it to duration if I don't need the ones in the middle :") I'm pretty lazy...

@nio kasgami No I edited my post and removed stuff XD I thought the issue was solved but not really.

-------------------------------
Edit:
Did some research.
Changed the code to this:
Code:
$.move = function(group) {
        var moveId = $.getId(group.name);
        for (i = 0; i <= moveId.length - 1; i++) {
            $gameScreen.movePicture(moveId[i], group.origin||0, group.x||0, group.y||0, group.scale||100, group.scale||100, group.opacity||255, group.opacity||0, group.dur||60)
        }
    }
And called with this:
Code:
$.move({name: 'a1 norm', x:500, dur:15});
This works without order.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/named-parameters-solved.126876/