We only track property additions, because these are by far the most common case. Deleting a property results in going to "slow mode", i.e. using a dictionary for the object's properties. So as a general rule of thumb, using 'delete' makes thing slower.
What are you trying to achieve exactly? Perhaps there's a way without using 'delete'. Cheers, S. On Fri, Jun 1, 2012 at 8:34 AM, Zenwolf <[email protected]> wrote: > Greetings all, > > Does using the JavaScript "delete" keyword to delete a property from an > object effect how v8 will optimize the object? I've read that v8 creates > hidden "classes" to represent an object and all its various property > configurations. Does deleting a property just flip between two of these > hidden classes and is it less efficient than just nulling the local > property value? > > Secondly, how will v8 handle the case where I have a prototype object with > "name" property and also a local property "name" and I delete the local > property to expose the prototype value again? > > Example: > > function Foo() { > this.name = 'foo'; > } > > function Bar() {} > Bar.prototype = new Foo(); > var bar = new Bar(); > bar.name = 'bar'; > // later in the program... > delete bar.name; // exposes prototype name again (Foo's name). > > Will using delete in such a manner prevent v8 from fully optimizing the > code? Or should I not worry about this usage? > > Thank you very much for any insight! > > -- > v8-users mailing list > [email protected] > http://groups.google.com/group/v8-users -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
