var assert = require("assert"); var store = {}; function resolve(item) { return store[item]; } var FancyObject = function() { var arrayProperty = []; Object.defineProperty( this, "arrayProperty", { "set": function(newItem) { arrayProperty.push(resolve(newItem)); }, "get": function() { var prop = arrayProperty.slice(0); prop.valueOf = function() { return 0; } return prop; } } ); }; FancyObject.prototype = {}; FancyObject.prototype.valueOf = function() { var key = Math.random(); store[key] = this; return key; } var assignTo = new FancyObject(), assignee = new FancyObject(); assignee.easyIdentifier = 1234567; console.log( "Items in the object we're assigning to? %d", assignTo.arrayProperty.length); assignTo.arrayProperty += assignee; console.log( "Items in the object we're assigning to after increment op: %d", assignTo.arrayProperty.length); assert(assignTo.arrayProperty[0].easyIdentifier === 1234567);