Skip to content

Instantly share code, notes, and snippets.

@rkeVader
Created March 12, 2019 12:31
Show Gist options
  • Save rkeVader/91a244187d60e6328bcc56b8ecde39e3 to your computer and use it in GitHub Desktop.
Save rkeVader/91a244187d60e6328bcc56b8ecde39e3 to your computer and use it in GitHub Desktop.
function CreateProperty(O, P, Getter, Setter) {
Object.defineProperty(O, P, {
get: Getter,
set: Setter
});
} // CreateProperty
// SAMPLE USAGE
/*
CreateProperty(
testclass.prototype,
'TestProp',
function() {
console.log('TestProp Getter Called');
return this._testProp;
},
function(value) {
console.log('TestProp Setter Called With [' + value + ']');
this._testProp = value;
}
);
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment