Created
December 19, 2014 18:45
-
-
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!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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