Answer the question
In order to leave comments, you need to log in
How to make other parameters not required?
I need to create a function that takes three parameters. In this function, only the first parameter is required, and the second and third may not be passed.
How to implement it? Give me a small example if possible...
Answer the question
In order to leave comments, you need to log in
function test(a, b=null, c=null) {
console.log(a);
if(b) console.log(b);
if(c) console.log(c);
}
test(1) // консоль: 1
test(1, 2) // консоль: 1, 2
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question