Allowing object field name shorthand
Michael Kriegel
michael.kriegel at actifsource.com
Fri Jun 23 05:27:40 UTC 2017
I also vote against this. A further problem could be duplication of
field names in large objects. Imagine there is a
field2.field3.field4.field5 in the beginning of your object and then
another one 100 lines below. Using the currently well defined way to
define nested objects at least groups fields which belong to an object.
var obj = {
field1: "val" ,
field2.field3: 3,
//hundrets of lines
field2.field3: true
};
Also it is much shorter, not to repeat the field names each time:
var obj = {
field1: "val" ,
field2:{
field3: 3,
field4: true
}
};
Michael
On 23.06.2017 04:13, Sebastian Malton wrote:
>
> I don't see how this is like referencing the object a field is in
> during object construction. Yes field2.field4 would not be able to
> reference field2.field3 but that is not what I am proposing. I am
> proposing a syntactic sugar for nested objects
>
>
> On 2017-06-22 10:05 PM, J Decker wrote:
>>
>>
>> On Thu, Jun 22, 2017 at 7:56 AM, Sebastian Malton
>> <sebastian at malton.name <mailto:sebastian at malton.name>> wrote:
>>
>> I would like to propose that the dot or '.' is allowed in object
>> field names so that the following are allowed.
>>
>> var obj = {
>> field1: "val" ,
>> field2.field3: 3,
>> field2.field4: true
>> };
>>
>>
>> This is much like
>> var obj = {
>> field1: 3
>> field2 : 4
>> field3 : obj.field2+3
>> }
>>
>> which falls apart because obj isn't technically fully defined, and
>> doesn't have a field2. So your second field2.field4 wouldn't be able
>> to reference the previous object created for field2.field3.
>>
>> it would be a huge complexity for engines to create objects....
>>
>>
>>
>> Sebastian
>>
>>
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org <mailto:es-discuss at mozilla.org>
>> https://mail.mozilla.org/listinfo/es-discuss
>> <https://mail.mozilla.org/listinfo/es-discuss>
>>
>>
>>
>>
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
--
Michael Kriegel • Head of R&D • Actifsource AG • Haldenstrasse 1 • CH-6340 Baar • www.actifsource.com • +41 56 250 40 02
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170623/73bea16c/attachment-0001.html>
More information about the es-discuss
mailing list