function currying in javascript

Something Like that:
function currying

What is function currying in javascript?
Creating a copy of a function but with some preset parameters (very useful in mathematical situations).

For that you need to create first html code.

HTML

<p id="demo"></p>

After that add this JS code.

JS

function multiply(a, b){
    document.getElementById('demo').innerHTML = a * b;
}

var multipleByTwo = multiply.bind(this, 2);
multipleByTwo(4);

[codepen_embed height=”265″ theme_id=”0″ slug_hash=”brLpNP” default_tab=”result” user=”pradeepanvi”]See the Pen function currying in javascript by Pradeep Kumar (@pradeepanvi) on CodePen.[/codepen_embed]

Now you can see

8

Leave a Reply

Your email address will not be published. Required fields are marked *