Currying is a core concept of functional programming and a useful tool for any developer ' s toolbelt.
Example 1:
Let F = a = b = + c =a+b+ = f (1) (2) (3// 6
Example 2:
<!DOCTYPE HTML><HTML><Head> <MetaCharSet= "Utf-8"> <title>JS Bin</title> <Scriptsrc= "Https://cdnjs.cloudflare.com/ajax/libs/ramda/0.18.0/ramda.min.js"></Script></Head><Body><DivID= "One"style= "width:100px;height:100px;border:2px solid black">One</Div><DivID= "both"style= "width:100px;height:100px;border:2px solid black">Both</Div><DivID= "three"style= "width:100px;height:100px;border:2px solid black">Three</Div></Body></HTML>
Let one = document.getElementById (' one '= document.getElementById (' both '= document.getElementById (' Three '= a = b + = c = A.addeventlistener (b, (event)= {= C;}); F (one)(' click ') (' Red ');
Example 3:
Let one = document.getElementById (' one '= document.getElementById (' both '= document.getElementById (' Three '= a = b and c = A.addeventlistener (b, (event) ={ = = = F ( Oneclickevent (' mouseover ') (' Red '),twoclickevent (' mouseout ') (' Blue ');
Example 4:include Ramda Library:
Let one = document.getElementById (' one '= document.getElementById (' both '= document.getElementById (' Three '= R.curry ((a,b,c) ={ A.addeventlistener (b, (event)={ = c; });}); // with placeholder from Ramdaconst Clickgreen = f (r.__, ' click ', ' green '); Clickgreen (one );
Example 5:multi placeholders:
Let one = document.getElementById (' one '= document.getElementById (' both '= document.getElementById (' Three '= R.curry ((a,b,c) ={ A.addeventlistener (b, (event)={ = c; });}); // with placeholder from Ramdaconst Clickcolor = f (r.__, ' click' Yellow ' ' grey 'pink ');
[Javascript] What is JavaScript Function currying?