Function as the Returned Object

Overview of functions being returned from other functions.

Background

There are times when you need to return functions from other functions. The function may be designed inside the called function block and is returned as the returned value. This is easy with JavaScript and we will explore it in this lesson.

Introduction

Functions that take other functions as an argument or return functions are called higher-order functions. In this lesson, we focus on functions that can be returned from the invocation of some functions. The returned value of type function is possible by writing a return statement which either returns the function itself or a variable assigned to the function. Check out the following example.

Returning regular functions

The following example showcases how a function can return a regular function.

Get hands-on with 1200+ tech skills courses.