Function
JavaScript functions are objects. They can be defined using the Function constructor, like so:
var sum = new Function('a', 'b', 'return a + b;');
This is a (generally not recommended) alternative to the function literal (also known as function expression):
var sum = function (a, b) {
return a + b;
};
Or, the more common function definition:
function sum(a, b) {
return a + b;
}
The Function.prototype members
Following are the list of members of the Function constructor:
|
Property/Method |
Description |
|
|
Allows you to call another function while overwriting the other function's function whatIsIt(){
return this.toString();
}
> var myObj = {};
> whatIsIt... |
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at AU $24.99/month. Cancel anytime