nobe4
nobe4

Reputation: 2842

Add Name Definition to "Function" in Javascript


I would like to do something like this :

var f = Function;
var f1 = f(){
    //do stuff
}

f1(); // call f1 as a function

The main idea is to create a new name and a new way to create a function : instead of doing function a() do f a().

Thanks in advance.

Upvotes: 1

Views: 152

Answers (2)

bouscher
bouscher

Reputation: 1360

Not quite what you meant, but maybe you can play around with this:

var f=function(){ 
return function(){alert(1)};  
}; 

var x=f(); 
x();

Upvotes: 1

Quentin
Quentin

Reputation: 943214

JavaScript provides no means by which you can extend the language with additional keywords.

Upvotes: 3

Related Questions