- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are immediate functions in JavaScript?
The immediate function executes as soon as it is defined. To understand the role of immediate function, let’s see the difference between a function and an immediate function −
Here’s immediate function −
(function() { var str = "display"; }()); function display() { // this returns undefined alert(str); }
Here’s a function −
var str = "display"; function display() { // This returns "display" alert(str); }
Let’s see another example of immediate functions −
var name = 'Amit'; (function(sName) { alert( 'Student name = ' + sName ); }(sName))
- Related Articles
- What are functions in JavaScript?
- What are callback functions in JavaScript?
- What are generator functions in JavaScript?
- What are Partial functions in JavaScript?
- What are JavaScript Math Functions?
- What are JavaScript Nested Functions?
- What are JavaScript Factory Functions?
- What are optional arguments in JavaScript Functions?
- What are Rest parameters in JavaScript functions?
- What are Self-Invoking Anonymous Functions in JavaScript?
- What are different ways of defining functions in JavaScript?
- What are variadic functions in Java?
- What are virtual functions in C#?
- What is Non-Immediate Left Recursion in compiler design?
- Regular functions vs Arrow functions in JavaScript?

Advertisements