Skip to content

Instantly share code, notes, and snippets.

@neagle
Created May 25, 2012 19:14
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 neagle/2789974 to your computer and use it in GitHub Desktop.
Save neagle/2789974 to your computer and use it in GitHub Desktop.
define([], function () {
var Wiser = window.Wiser || {};
if (typeof Wiser === 'object') {
Wiser.utils = Wiser.utils || {};
if (typeof Wiser.utils === 'object') {
/* WiserTogether Utility Functions
*
*/
/* getProperty: checks a long object property chain for a value and
* returns undefined if any property along the chain does not exist
* instead of throwing an error
*/
Wiser.utils.getProperty = function (object, propertiesString) {
var i,
length,
split = propertiesString.split('.');
for (i = 0, length = split.length; i < length; i += 1) {
object = object[split[i]];
if (object === undefined) {
// Can't proceed
break;
}
}
return object;
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment