On the default parameters of js

below, there is a method that accepts four parameters x y k j. Where the default value of k j is 1, 2

 get: function (x, y, k = 1, j = 2){}

you can call

when you want to omit the last two parameters.
this.get(1,2)

now if I just want to omit the third parameter, what should I write?
it seems impossible to know which parameter has been omitted in this way

this.get(1,2,3)
Mar.11,2021

this.get(1,2,undefined,3) 

it is recommended to write as follows

get: function ({x,y,k = 1, j= 2} = {}){}
this.get({x:1,y:2,j:3})

pass an object, the code is more readable, and the parameters are more free

function test (params) {
    let x = params.x || 'default'
    let y = params.y || 'default'
    let z = params.z || 'default'
}

test({
    x: 1,
    z: 3
})

es6 can also deconstruct assignment


this.get

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eb26a6-481ab.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eb26a6-481ab.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?