javascript - How to pass arguments to a function with one passed? (ES6) -
there function 3 arguments set default:
function func( = 1, b = 2, c = 3 ) { console.log(a, b, c); }
how pass arguments function 1 passed? example:
func(10, , 30);
you use undefined
, value undefined variables default parameters:
in javascript, parameters of functions default
undefined
.
the default check works like
b = b !== undefined ? b : 2
function func(a = 1, b = 2, c = 3) { console.log(a, b, c); } func(10, undefined, 30);
wiki
Comments
Post a Comment