I encountered the following code when I was working through meteor tutorial.
{
'submit .new-task'(event) {
// some code here
},
}
I was very confused because I had never seen an object literal that contains some string followed by an anonymous function. After I read the MDN web docs about object initializer, I know that the code above is equivalent to the following:
{
'submit .new-task': function(event) {
// some code here
},
}
The syntax looks very odd to me maybe because I am simply not got used to it.
Top comments (0)