4 Replies - 301 Views - Last Post: 27 June 2019 - 04:32 PM

#1 gart   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 15-June 18

Is this syntax supported by earlier versions of JS?

Posted 27 June 2019 - 02:19 PM

Example:

function f()
{
 var a = 153
 var b = 873
 return { a, b }
}



As opposed to:

function f()
{
 var a = 153
 var b = 873
 return { a : a, b : b }
}


Is This A Good Question/Topic? 0
  • +

Replies To: Is this syntax supported by earlier versions of JS?

#2 ArtificialSoldier   User is online

  • D.I.C Lover
  • member icon

Reputation: 2334
  • View blog
  • Posts: 7,111
  • Joined: 15-January 14

Re: Is this syntax supported by earlier versions of JS?

Posted 27 June 2019 - 02:41 PM

It looks like that syntax was added in ES2015.

https://developer.mo...Object_literals
Was This Post Helpful? 0
  • +
  • -

#3 gart   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 15-June 18

Re: Is this syntax supported by earlier versions of JS?

Posted 27 June 2019 - 03:21 PM

Okay so may be a good idea to use something like Babel if I plan to deploy in a browser (to support older browser versions)?

This post has been edited by Dormilich: 28 June 2019 - 01:23 AM

Was This Post Helpful? 0
  • +
  • -

#4 ArtificialSoldier   User is online

  • D.I.C Lover
  • member icon

Reputation: 2334
  • View blog
  • Posts: 7,111
  • Joined: 15-January 14

Re: Is this syntax supported by earlier versions of JS?

Posted 27 June 2019 - 03:56 PM

If you need to target older browsers, yeah.
Was This Post Helpful? 0
  • +
  • -

#5 gart   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 15-June 18

Re: Is this syntax supported by earlier versions of JS?

Posted 27 June 2019 - 04:32 PM

Probably should. Just makes things easier on the end user.

This post has been edited by Dormilich: 28 June 2019 - 01:24 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1