

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
How to execute a JavaScript function using its name in a variable?
To execute a JavaScript function using its name in a variable, use Anonymous Functions,
Anonymous functions are always loaded using a variable name. Anonymous, as the name suggests, allows creating a function without any names identifier. It can be used as an argument to other functions. Call them using a variable name −
This is how JavaScript anonymous functions can be used −
var func = function() { alert(‘This is anonymous'); } func();
Here’s an example −
//anonymous function var a = function() { return 5; }
- Related Questions & Answers
- How to execute a JavaScript function when I have its name as a string?
- How to load a JavaScript function using the variable name?
- How to ignore using variable name as a literal while using push() in JavaScript?
- How to execute a Javascript function in Python with Selenium?
- How to execute a Javascript using Selenium in Python?
- How to define global variable in a JavaScript function?
- How can we assign a function to a variable in JavaScript?
- How to print a variable name in C?
- How to stop a function during its execution in JavaScript?
- How to remove a column from matrix in R by using its name?
- How to remove a row from matrix in R by using its name?
- How to get a variable name as a string in Python?
- How to get a variable name as a string in PHP?
- Setting a default variable value to undefined in a function - JavaScript?
- How to access a JavaScript object using its own prototype?
Advertisements