Skip to content

Instantly share code, notes, and snippets.

@kara-ryli
Created February 6, 2015 23:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kara-ryli/31826051a9b794f4fb7b to your computer and use it in GitHub Desktop.
Save kara-ryli/31826051a9b794f4fb7b to your computer and use it in GitHub Desktop.
A tip I picked up from Fluent 2014
// V8 initializes memory space for _x and _y
// in advance
function Klass1() {
this._x = null;
this._y = null;
}
var k1 = new Klass1()._x = 'hi';
function Klass2() {}
// dynamically defined property converts to a
// linked list in memory, making accessing
// _x slower
var k2 = new Klass2()._x = 'hi';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment