What is the a implicit return and how is it different from the non implicit return? Also, are there other types of returns we learn in JavaScript?

What is the a implicit return and how is it different from the non implicit return? Also, are there other types of returns we learn in JavaScript?

The opposite of implicit is explicit.

Explicit returns are really the bread and butter of most programming languages (including javascript). I don’t think I’ve ever written an implicit return other than for this example… but i see a lot of good use cases for it.

I think implicit returns in js have to do with arrow functions:

let func = x => x + x;                  
// implicit return (because no brackets for the function code)
func(5)
//returns 10

let func2 = (x, y) => { return x - y; }; 
// notice the brackets, and the explicit statement of return

func2(5,4)
//returns 1
2 Likes

Indeed. I think the idea is similar to Python’s lambda functions.

2 Likes

Thank you for translating it for me hahaha. Ahem…

2 Likes