We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Contextify a function by accepting the first parameter as this-object.
Similar: contextify, decontextify.
function contextify(x) // x: a function
const xfunction = require('extra-function'); function count(x, value) { var a = 0; for (var v of x) if (v===value) ++a; return a; } var fn = xfunction.contextify(count); fn.call([6, 3, 4, 3], 3); // → 2 fn.call([6, 1, 4, 3], 3); // → 1