How to return an object from a JavaScript function?



To return an object from a JavaScript function, use the return statement, with this keyword.

Example

You can try to run the following code to return an object from a JavaScipt function −

 Live Demo


   
      
   

Output

Updated on: 2020-06-23T06:07:20+05:30

6K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements