N
N
newaitix2015-10-28 23:23:27
JavaScript
newaitix, 2015-10-28 23:23:27

Find out the name of the property that was called?

a={
b:function(){
//узнать здесь название свойства
//arguments.callee.name не работает как как функция анонимна
}
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin Kitmanov, 2015-10-28
@newaitix

She doesn't have to be anonymous, by the way:

a = {
    b: function b () {}
};

It is not clear why? It seems to me that there are easier ways to achieve what you need.

S
Sergey Voronkov, 2015-10-29
@no_smoking

As an option

var a = {
  b : function(){
    alert(arguments.callee.$name)
  }
}
for(var n in a) a[n].$name = n;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question