1

What is the correct term for the ability in ES2015 to implicitly assign the value of a variable to an object member of the same name?

const foo = 1;
const bar = { foo };
Steve Bennett
  • 114,604
  • 39
  • 168
  • 219
  • 1
    Shorthand property names – Ori Drori Sep 30 '20 at 00:36
  • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#New_notations_in_ECMAScript_2015 – Phil Sep 30 '20 at 00:42
  • Oh great, want to make that an answer? – Steve Bennett Sep 30 '20 at 00:44
  • Heh, someone voted to close this as off-topic for being "About general computing hardware and software"? Can't think of a topic much more related to programming than asking about syntax features. – Steve Bennett Sep 30 '20 at 00:46
  • @SteveBennett That was me and I didn't mean to offend. Your question is about the name of a feature which isn't exactly a good fit for a StackOverflow question. I bundle these sorts of questions along with the _"why is implemented this way"_ ones though this is at least objective. Anyway, it's only one vote and you're more than welcome to answer your own question – Phil Sep 30 '20 at 00:55
  • 1
    @Phil In this case, voting to close as a duplicate of the canonical topic about this syntax would be the way to go :-) – Bergi Sep 30 '20 at 01:03
  • @Bergi I see a big difference between _"what is this syntax"_ and _"what is this feature called"_ but yes, that other post answers both questions – Phil Sep 30 '20 at 01:05
  • Heh, that sounds like a poor bundling to me. Questions like this are useful because once you know what a feature is called, you can google it, you can read the documentation, etc. It also would have helped me find the dupe target ;) – Steve Bennett Sep 30 '20 at 03:15

0 Answers0