javascript default parameters
function multiply(a, b = 1) {
return a * b;
}
javascript default parameters
function multiply(a, b = 1) {
return a * b;
}
javascript parameter default parameter
function say(message='Hi') {
console.log(message);
}
say(); // 'Hi'
say(undefined); // 'Hi'
say('Hello'); // 'Hello'
function date(d = today()) {
console.log(d);
}
function today() {
return (new Date()).toLocaleDateString("en-US");
}
date();
function add(x = 1, y = x, z = x + y) {
return x + y + z;
}
console.log(add()); // 4
javascript default function parameter value
function multiply(a, b) {
b = (typeof b !== 'undefined') ? b : 1
return a * b
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us