小喵 🐈 says to Happy Web Developer 只好寫這樣了: function getData(data, depth) { return depth ? getData(data.data, depth - 1) : data; }