- From: Jonas Sicking <jonas@sicking.cc>
- Date: Mon, 28 Oct 2013 17:08:22 -0700
- To: Boris Zbarsky <bzbarsky@mit.edu>
- Cc: Anne van Kesteren <annevk@annevk.nl>, "public-script-coord@w3.org" <public-script-coord@w3.org>, es-discuss <es-discuss@mozilla.org>
On Mon, Oct 28, 2013 at 4:43 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote: > If there is a better proposal for the "return an array that can be read but > not written but I can still write to it" use case, I'm all ears. My suggestion has been: Return a frozen (and thus immutable) Array. When you need to change the contents of the array, create a new frozen Array which contains the new Array contents. In the case of gamepads, the second rule would kick in when a gamepad was connected or disconnected. The "i don't want others to change the array, but I want to be able to do so myself" is basically a "live array", which a lot of people has expressed dislike of. So maybe it's something we should avoid. My proposal above has two nice properties: x.arrayProp === x.arrayProp returns true. x.arrayProp behaves entirely like a normal array (including Array.isArray and Array.concat), as long as you don't try to mutate it. / Jonas
Received on Tuesday, 29 October 2013 00:09:19 UTC