The other day I was a bit tired, I wrote this JavaScript code:
var obj = {a(toto){console.log("func a: ", toto);} };
then I tried:
obj.a("hello");
> func a: hello
And it worked.
What I really meant to write was:
var obj = {a: function(toto){console.log("func a: ", toto);} };
So my question is: why does the first code work?
Is there a doc somewhere that explains it, and do you think I can use it? (will it work in all browsers?)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…