Check out a free preview of the full Hardcore Functional Programming in JavaScript, v2 course

The "Logging in Composition" Lesson is part of the full, Hardcore Functional Programming in JavaScript, v2 course featured in this preview video. Here's what you'd learn in this lesson:

Brian demonstrates how to use logging in function composition to debug code.

Preview
Close

Transcript from the "Logging in Composition" Lesson

[00:00:00]
>> Any last questions on compose before I make you compose?
>> I know one struggle I've had with compose is sometimes I need to insert some console logs to kind of figure out what I'm doing.
>> Check it out.
>> You know a go a way of doing that.

[00:00:13]
>> So, you could say, I like to do a tag in x and then console.log the tag the x and cheat and [LAUGH] return the x. So, if I log right here, what's going to happen is oops, I didn't give it a tag. [LAUGH] Should probably I wrote this in manual curried form.

[00:00:39]
I could curry it like that and get rid of that. Cool. But if I log like here, so what's gonna happen is, sorry. Again, not helpful editors, editor writers. So to log it in the middle of my pipeline. And then return it back, yeah, it's a very useful thing, very side effecty, but fine for debugging I'm not too strict on that, and so you can log, everywhere you can do log start and then we get there.

[00:01:21]
And we can even kind of do an inline little console.log and return an x here. But that's not it's not very helpful. [LAUGH] So. Yeah, I don't know how that works. Doesn't matter the point is use the log. But yeah, so that was a great question that happens all the time and it's very useful to know going in.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now