What is JavaScript shorthand property? [duplicate]

With ES6, you can use shorthand property names which allow you to write something like this.

var s="abc";
var n = 1;
var o = { s, n }; // This is equivalent to { s: s, n: n }

In your case, prop = [1,2,3] was parsed as one shorthand property (s and n in the example above), but it was not a proper property name.

Leave a Comment