Generally, recursion is used to determine whether the object is the same as the parent type.
Here we demonstrate simple object recursion, and array recursion is similar.
var obj = { a:{w:1,y:2,x:3}, b:{s:4,j:5,x:6}, c:{car:7,cat:8,mao:9}}function f(s){ for(var i in s){ if(typeof s[i]=="object"){ f(s[i]) }else{ console.log(s[i]); } }}f(obj);Return results: 1,2,3,4,5,6,7,8,9
The above method of using recursive traversal objects to obtain value is all the content I have shared with you. I hope you can give you a reference and I hope you can support Wulin.com more.