Guest User

Untitled

a guest
Dec 10th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. /*
  2. * Get nested object property using dot notation
  3. * */
  4.  
  5. const getProperty = ( propertyName, object ) => {
  6. let parts = propertyName.split( "." ),
  7. length = parts.length,
  8. i,
  9. property = object || this;
  10.  
  11. for ( i = 0; i < length; i++ ) {
  12. property = property[parts[i]];
  13. }
  14.  
  15. return property;
  16. };
Add Comment
Please, Sign In to add comment