js how to implement map[index]++ concisely
With Array, I can use array[index]++ But with Map, I only know map.set(index,map.get(index)+1) I think it looks bad, and if index is a long name function, I have to split it into two lines. Is there a more concise way to implement map[index]++ I could only suggest a helper function, like function update(map, key, fn) { return map.set(key, fn(map.get(key), key)); } update(table, index, i=>i+1); There is no syntactic sugar for assignments, and therefore no shorthand assignments either. If your keys are strings, you could employ a Proxy with suitable traps to disguise the update as a property