From the course: Learning Functional Programming with JavaScript ES6+
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Functions as objects - JavaScript Tutorial
From the course: Learning Functional Programming with JavaScript ES6+
Functions as objects
- Throughout the other videos in this course, we've consistently seen that the way we treat functions in functional programming is quite different from what we might be used to, in say, object-oriented programming. We've seen that they can be treated like other types such as strings or numbers, and also that we can pass them as arguments into other functions, or return them from other functions. Well there's another aspect of functions in JavaScript that we're going to talk about today. In addition to the many other roles we've seen them play so far, the functions that we define in our code are also objects. So when we say that functions are objects, we mean that they have properties like objects do. They have a name property for example that returns whatever name we gave the function. So for instance if we define a function called sayHello that just prints hello to the console, we can say sayHello.name, and if we run our code, we see that that gives us a name that we initially gave…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.