When an object literal uses a function as a property value, shorthand method syntax removes the redundant colon and `function` keyword: write `update(changes) { ... }` instead of `update: function(changes) { ... }`. The parentheses signal a method. section 12.0 section 12.2
function createStateManager() {
const state = {};
return {
update(changes) {
Object.assign(state, changes);
},
getState() {
return Object.assign({}, state);
}
}
}
A state manager shows concise methods used for updating and reading private state. section 12.2
A shorthand method evaluates to an anonymous function. It cannot refer to itself by its method name, so avoid this syntax for recursion. Calling itself through `this.at` can work only while `this.at` still points to the function; detaching or renaming the method breaks that assumption. section 12.2
