Here's an example of a console.log() helper, a variation of which I've used in production code and is pretty much identical to @afrazchelsea
's greet() example, that allows you to specify a scope name that it'll use to prefix each message.
Without currying, the function would look like this:
Here's an example of a
console.log()
helper, a variation of which I've used in production code and is pretty much identical to @afrazchelsea 'sgreet()
example, that allows you to specify ascope
name that it'll use to prefix each message.Without currying, the function would look like this:
Requiring you to specify
scope
on every call:This curried version of the function accepts the single argument
scope
, and returns a second function that accepts the single argumentmsg
:This allows you to create pre-scoped logger functions for which you only have to specify
msg
:For reference, here's the normal
function
/ non-arrow-function version of that curriedscopedLogged()
function:which works the same way:
Amazing @derekenos , thank you!
I see I see. Thanks for the great example.