1var subsets = function (nums) {2const res = [];34const dfs = (i, slate) => {5if (i == nums.length) {6res.push(slate.slice());78return;9}1011// take the current number into the subset.12slate.push(nums[i]);13dfs(i + 1, slate);14slate.pop();1516// ignore the current number.17dfs(i + 1, slate);18};1920dfs(0, []);2122return res;23};