lodash :: _.zip()과 _.unzip() 구현하기
_.zip()import _ from "lodash";const list1 = ['a', 'b']const list2 = [1, 2];const list3 = [true, false];/** * 1. Lodash zip() */const lodashZip = _.zip(list1, list2, list3);console.log(lodashZip); // [ [ 'a', 1, true ], [ 'b', 2, false ] ]/** * 2. myZip() 구현 */function myZip(...arr) { let zipResult = []; // [0, 0], [1, 0], [2, 0] -> [0, 1], [1, 1], [2, 1] for(let i = 0; i _...
2023.10.08