
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Function Expression vs Function Declaration in JavaScript
Function Declaration
The “function” keyword declares a function in JavaScript. To define a function in JavaScript use the “function” keyword, followed by a unique function name, a list of parameters (that might be empty), and a statement block surrounded by curly braces.
Here’s an example −
function sayHello(name, age) { document.write (name + " is " + age + " years old."); }
Function Expression
Function Expression should not start with the keyword “function”. Functions defined can be named or anonymous.
Here are the examples −
//anonymous function expression var a = function() { return 5; }
Or
//named function expression var a = function bar() { return 5; }
Advertisements