Subj : Re: Seeking clarification on effect of literal vs. object syntax. To : Christopher M. Balz From : Brendan Eich Date : Fri Aug 26 2005 02:58 pm Christopher M. Balz wrote: > Thank you for your response. > > The ECMA-262 spec is quite clear about RegExps, so I > read you that arrays and objects work the other way (a > fresh object is created each time the variable holding > the literal expression is evaluated). No, what you just wrote in parentheses is *not* what I wrote, and it's incorrect. You just wrote that var a = [1, 2, 3]; for (var i = 0; i < 100; i++) print(a); creates an Array object for each evaluation of the variable a in the actual argument expression passed to print. I said, and ECMA specifies, that the array initialiser [1, 2, 3] is shorthand for new Array(1, 2, 3). > Wouldn't a program that had to constantly wrap array > literal variables in objects run much slower than one > that had made its arrays (for example) via the 'new > Array()' constructor call? I'm not sure why you thought each expression using a variable that happens to *refer* to an object created by an array or object initialiser re-evaluates the initialiser, but that isn't how JS works, and it doesn't make sense. For one thing, objects are reference types, so just evaluating a reference creates no new object. /be .