Question about reusing object used in Object.defineProperty

J B port25 at gmail.com
Mon Sep 23 14:28:14 PDT 2013


var obj = {};

Object.defineProperty(this, 'foo', obj.value = 0);
Object.defineProperty(this, 'foo2', obj.value = 1);

vs.

Object.defineProperty(this, 'foo', {value:0});
Object.defineProperty(this, 'foo2', {value:1});


Would the former method help with reducing object allocation (and therefore
gc), or are there compiler optimizations that will automatically make the
former as efficient?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130923/5e34b59d/attachment.html>


More information about the es-discuss mailing list