Created
May 13, 2015 19:38
-
-
Save greduan/0708ea833085cd278e46 to your computer and use it in GitHub Desktop.
recursive func which goes goes through object and finds all .init() funcs and runs them
This file contains hidden or 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
var initialiseKeys = function initialiseKeys (obj) { | |
var val | |
for (var key in obj) { | |
val = obj[key] | |
// the key isn't 'init' BUT it's an object we need to explore it | |
if (key !== 'init' && typeof val === 'object') { | |
initialiseKeys(val) | |
// hey the key is 'init' and its value is a function! | |
} else if (key === 'init' && typeof val === 'function') { | |
obj.init() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment