Code coverage report for object/get.js

Statements: 100% (10 / 10)      Branches: 100% (2 / 2)      Functions: 100% (3 / 3)      Lines: 100% (8 / 8)     

All files » object/ » get.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 211         1 33     33 21 21     29     1      
define(function () {
 
    /**
     * get "nested" object property
     */
    function get(obj, prop){
        var parts = prop.split('.'),
            last = parts.pop();
 
        while (prop = parts.shift()) {
            obj = obj[prop];
            if (typeof obj !== 'object') return;
        }
 
        return obj[last];
    }
 
    return get;
 
});