r/learnjavascript • • Feb 03 '21

Callback functions in JavaScript

https://jscurious.com/callback-functions-in-javascript/
3 Upvotes

5 comments sorted by

View all comments

Show parent comments

1

u/lemonizer Feb 03 '21

This is correct but the statement "the takeOrder function is returning nothing at all" is not entirely accurate. When a function does not have a `return` statement specified, it will return the primitive value of `undefined`.

2

u/ninoninoninous Feb 03 '21

If one wanted to be extremely pedantic about it, they could say the function still returns nothing, and that it's the JavaScript engine that returns the undefined when the result of executing the function produces no value.

But that would be really pedantic and doesn't really help anyone much, does it?

0

u/[deleted] Feb 03 '21

[deleted]

3

u/ninoninoninous Feb 03 '21 edited Feb 03 '21

And if one were to do that they could just search for 9.2.1 [[Call]], step 11, and see that it's the engine doing it.

But, again, is all this really necessary?