I have the following question : in Node/Javascript why this function declaration is wrong inside an object or a class??
var obj = {
function x() {
/* code */
},
bar: function() {
/* code */
}
};
the first function declaration x() cause
function x() {
^
SyntaxError: Unexpected identifier
i don't understand why i can't use the function keyword inside an object or a class , what difference does it make when using function x() or just x(), just x() works fine , but adding function keyword in front of it - cause the above problem. why ?