楼主二面代码题解 var getItem = function(obj, way){ let ways = way.split('/'); if(ways.length == 1){ console.log(obj[ways[0]]); } else{ for(var k_p in ways){ if(obj[ways[k_p]] instanceof Object || obj[ways[k_p]] instanceof Array){ obj = obj[ways[k_p]]; continue; } else console.log(obj[ways[k_p]]); } } }