JavaScript Defining a Setter/Getter Using Object.defineProperty


Example

var setValue;
var obj = {};
Object.defineProperty(obj, "objProperty", {
    get: function(){
        return "a value";
    },
    set: function(value){
        setValue = value;
    }
});