I have a function:
public static async myFunc(
x: 500,
y: boolean = true,
z = 1000,
)
I want to call the function without passing in y
myFunc(1000, 2000);
But getting an error that 2000 is not a boolean
I have a function:
public static async myFunc(
x: 500,
y: boolean = true,
z = 1000,
)
I want to call the function without passing in y
myFunc(1000, 2000);
But getting an error that 2000 is not a boolean
What about using object destructuring:
function myFunc({
x = 500,
y = true,
z = 1000,
})
You can pass object as argument into your function.
const myFunc = ({ x, y, z }) => {
console.log(x);
console.log(y);
console.log(z);
};
myFunc({ x: 500, y: false, z: 1000 });