-
Notifications
You must be signed in to change notification settings - Fork 35
Function
MitalAshok edited this page Nov 6, 2016
·
2 revisions
Returns a version of the function that has given parameters prefilled and passes given parameters through to the original, denoted by placeholders.
this::partial(staticParams)
-
this
: {T} -
...staticParams
: (any) The prefilled parameters.
parseInt::partial(_)("10", 2) // 10
parseInt::partial(_, 16)("10") // 16
function foo (a, b, c, d) {
console.log(a, b, c, d);
}
foo::partial(_, 2, ___)(1, 3, 4) // logs "1 2 3 4"
function foo (a, b, c, d) {
console.log(a, b, c, d);
}
foo::partial(___, 3, _)(1, 2, 4) // logs "1 2 3 4"
const slice1 = Array.prototype.slice::partial(1, ___);
[1, 2, 3, 4]::slice1() // [2, 3, 4]