I've been trying to get multiple functions working in 1 const, but it either does not work (Uncaught SyntaxError: Unexpected identifier) or I'm missing something, and I hope someone can help.
Why does this work:
const dynamicresponse = {
login(response) {
alert(response);
}
}
And why does this not work?
const dynamicresponse = {
login(response) {
alert(response);
}
adminsearchuser(response) {
alert(response);
}
}
And is there a way to get the example above working?
{ login(response) { ... } }is shorthand for{ login: function() { ... } }(MDN). As @connexo already mentioned, you're missing commas and therefore get a syntax error.