Skip to content

Instantly share code, notes, and snippets.

@val314159
Created December 19, 2014 18:45
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 val314159/8932c9326b07f2931ba2 to your computer and use it in GitHub Desktop.
Save val314159/8932c9326b07f2931ba2 to your computer and use it in GitHub Desktop.
{get,set,has}attr for javascript, works just like python. Sort-kinda cross-platformish!
// add python-like functions for attr access
function getattr(x,y){
return x[y];
}
function setattr(x,y,z){
x[y]=z;
}
function hasattr(x,y){
return (x[y]!==undefined);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment