Popular recipes tagged "getter"http://code.activestate.com/recipes/tags/getter/2010-07-16T18:10:51-07:00ActiveState Code RecipesUsing a getter for a one-time calculation of a JavaScript object attribute (JavaScript) 2010-07-16T18:10:51-07:00Trent Mickhttp://code.activestate.com/recipes/users/4173505/http://code.activestate.com/recipes/577310-using-a-getter-for-a-one-time-calculation-of-a-jav/ <p style="color: grey"> JavaScript recipe 577310 by <a href="/recipes/users/4173505/">Trent Mick</a> (<a href="/recipes/tags/getter/">getter</a>, <a href="/recipes/tags/performance/">performance</a>). </p> <p>This is a technique for using a JavaScript getter to calculate the value of an attribute <strong>just the first time</strong>. Rather than caching the value in some private variable and returning it, you just delete the getter and put the calculated value in its place.</p> <p>Note: I'd read about this technique ages ago, but forgot the details and had to look-up "delete" for removing the getter. :)</p>