1

Are function literals and function expressions the same thing, or is there a difference?

4

1 Answer 1

1

As answered on topic Exact meaning of Function literal in JavaScript: "A function literal is just an expression that defines an unnamed function."

Description of "function expression" on MDN about function name says, that it "Can be omitted, in which case the function is anonymous.". (unnamed function === anonymous function)

Another example of anonymous function notation is "arrow function expression" in ES6

var func = (x, y) => { return x + y; };

This does the same thing as:

var func = function (x, y) { return x + y; };

and (almost) the same thing as:

function func(x, y) { return x + y; };

For more in-deph explanation read: Difference between “anonymous function” and “function literal” in JavaScript


TL;DR:

Function Literal is kind of function expression.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.