How to get the the variable name from within a function in this example:
// it should return A var A = function(){ console.log(this.name); }
Is there something like this?
That function is anonymous; it has no name. You could, however, give it a name:
var A = function a() {};
Then its name is accessible via Function.name:
Function.name
var A = function a() {}; A.name > 'a'
1.4m articles
1.4m replys
5 comments
57.0k users