The name of a grammatical sugar of js (which should be es6)

let a = "1";
let b = "2";

let obj = {a, b};//{a:"1", b:"2"}

when initializing an object, pass in {a, b} directly, and the resulting object will have two properties, the key and value of which are the variable name and value of ab, respectively.
what is the name of sugar in this grammar?

Jun.28,2022

you can call him attribute abbreviation


ECMAScript 6 introduction


this really does not have a clear Chinese name. The attribute abbreviation mentioned by hfhan is the closest, which is called Shorthand property (ES2015 introduction, that is, ES6).
Why is it called shorthand?
because {a, b} is equivalent to the abbreviation of {a: a, b: B}


because it should be called deconstruction assignment


I also think it should be called structural assignment . Please take a look at teacher Ruan Yifeng's article


deconstruction assignment, most people should say so.

Menu