The attached code shows how to create getters and setters for a JavaScript object against the object prototype.
The example shows a situation where I want to store the underlying data (an RGBA colour) as an array, but wish to allow access throough getters and setters: i.e. colour.red = 255.
Running the example produces the following result:
red=255, green=128, blue=16, alpha=100
red=255
green=128
blue=16
alpha=100
red=0, green=128, blue=16, alpha=100
red=0