ccwq
11/4/2016 - 4:12 AM

相当于loadsh的_.get

/**
  * 获取某对象,对应深度的值
  * var data = {
  *      "level_1":{
  *          "level_2":"value"
  *      }
  * }
  * subfield(data,"level_1.level_2")     //"value"
  */
function subfield(data,f){
  if(f.substr) f = f.split(/\.|\\|\//);
  return f.length?arguments.callee(data[f.shift()],f):data;
}