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.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e701ad-2b3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e701ad-2b3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?