Função Valor padrão
function multiply(a, b = 1) {
return a * b
}
multiply(5, 2) // 10
multiply(5) // 5
multiply(5, undefined) // 5
Worried Wolf
function multiply(a, b = 1) {
return a * b
}
multiply(5, 2) // 10
multiply(5) // 5
multiply(5, undefined) // 5
@Value("${some.key:my default value}")
private String stringWithDefaultValue;
function say(message='Hi', number=7) {
console.log(message);
console.log(number);
}
say();
// 'Hi'
// 7