Skip to content

Instantly share code, notes, and snippets.

@bleroy
Last active December 24, 2018 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bleroy/bdbc7c371c2e42e5d313641f4358f5fd to your computer and use it in GitHub Desktop.
Save bleroy/bdbc7c371c2e42e5d313641f4358f5fd to your computer and use it in GitHub Desktop.
let someProperty, someOtherProperty;
function setProperty(target, propertyName, value) {
target[propertyName] = value;
}
function getProperty(target, propertyName) {
return target[propertyName];
}
const a = {foo: 'bar'};
somePorperty = 'someProperty';
someOtherPorperty = 'someOtherProperty'
setProperty(a, someProperty, 42);
setProperty(a, someOtherProperty, 'hello world');
console.log(getProperty(a, someProperty)); // outputs: "hello world"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment