function addition(x, y) {
return x + y;
}
const plus5 = addition.bind(null, 5)
plus5(10) // output -> 15
Note the use of .bind above, which returns another function ("plus5") which has the "x" input by default set to null, and "y" set to 5 by default. This way xalling plus5 with just the "x" variable set (as per last line) won't result in null, because "y" is set by default
Note the use of .bind above, which returns another function ("plus5") which has the "x" input by default set to null, and "y" set to 5 by default. This way xalling plus5 with just the "x" variable set (as per last line) won't result in null, because "y" is set by default