
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
What is the difference between: var functionName = function() {} and function functionName() {} in Javascript
functionDisplayOne is a function expression, however, functionDisplayTwo is a function declaration. It is defined as soon as its surrounding function is executed.
Both the ways are used to declare functions in JavaScript and functionDisplayOne is an anonymous function.
Here’s the function expression −
functionDisplayOne(); var functionDisplayOne = function() { console.log("Hello!"); };
The following is the function declaration −
functionDisplayTwo(); function functionDisplayTwo() { console.log("Hello!"); }
- Related Articles
- Difference between var and let in JavaScript
- Explain the differences in the usage of foo between function foo() {} and var foo = function() {}
- What is the difference between void, eval, and the Function constructor in JavaScript?
- What is the difference between "var" and "val" in Kotlin?
- What is the difference between VAR and DYNAMIC keywords in C#?
- What is the difference between order and rank function in R?
- What is the difference between class and typeof function in R?
- What is the difference between a method and a function?
- What is the difference between MySQL NOW() and CURDATE() function?
- What is the difference between MySQL LENGTH() and CHAR_LENGTH() function?
- What is the difference between MySQL stored procedure and function?
- Usage of var() CSS function
- What is the difference between function overriding and method hiding in C#?
- What is the difference between MAC and Hash function in Information Security?
- What is the significant difference between MySQL TRUNCATE() and ROUND() function?

Advertisements