Skip to main content
added 120 characters in body
Source Link
ulou
  • 5.9k
  • 6
  • 40
  • 51

With ES6:

 
function test(a, b = 3) {
   console.log(a, b);
}

test(1);      // Output: 1 3
test(1, 2);   // Output: 1 2
function test(a, b = 3) {
   console.log(a, ' ', b);
}

test(1);      // Output: 1 3
test(1, 2);   // Output: 1 2
 

With ES6:

 
function test(a, b = 3) {
   console.log(a, ' ', b);
}

test(1);      // Output: 1 3
test(1, 2);   // Output: 1 2

With ES6:

function test(a, b = 3) {
   console.log(a, b);
}

test(1);      // Output: 1 3
test(1, 2);   // Output: 1 2
 

Source Link
ulou
  • 5.9k
  • 6
  • 40
  • 51

With ES6:

function test(a, b = 3) {
   console.log(a, ' ', b);
}

test(1);      // Output: 1 3
test(1, 2);   // Output: 1 2