letarr=[{code:'abcd',pcode:'abc',},{code:'abc',pcode:'ab'},{code:'ab',pcode:'a'}]letobj={code:'abcd',pcode:'abc',}如上所示,arr里面的數(shù)據(jù)都是有上下關系的,現(xiàn)在希望根據(jù)obj在arr中依次查找父級,比如obj的父應該是{code:'abc',pcode:'ab'},然后繼續(xù)查找{code:'abc',pcode:'ab'}的父數(shù)據(jù)應為{code:'ab',pcode:'a'},以此類推,最后將符合條件的數(shù)據(jù)存放到一個數(shù)組里面,求一個遞歸的解法。
平行結構數(shù)據(jù),依次查找父數(shù)據(jù)萬分感謝
元芳怎么了
2019-09-26 08:57:44