Skip to content

Instantly share code, notes, and snippets.

@guipn
Created March 26, 2013 07:04
Show Gist options
  • Save guipn/5243621 to your computer and use it in GitHub Desktop.
Save guipn/5243621 to your computer and use it in GitHub Desktop.
Demonstration of Object.defineProperty on arrays. The algorithm followed is specified in 15.2.3.6 and 15.4.5.1.
var a = [];
Object.defineProperty(a, '0', {
get: function () {
console.log("Here it is.");
}
});
a.push(10);
void a[0]; // logs 'Here it is.'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment