Last active
August 25, 2017 10:21
-
-
Save ccwq/cb8dd212d2636bbfa4ed72c509b700a7 to your computer and use it in GitHub Desktop.
This file contains 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 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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment