블로그 이미지
이비그치면

태그목록

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함

calendar

1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

let str1 = '000111';
let str2 = str1.match(/.{1,1}/g);
console.log(str2);  ==> ["0", "0", "0", "1", "1", "1"]

let str3 = '111111';
let str4 = str3.match(/.{1,1}/g);
console.log(str4); ==> ["1", "1", "1", "1", "1", "1"]

function zip(arrays) {
    return Array.apply(null,Array(arrays[0].length)).map(function(_,i){
        return arrays.map(function(array){return array[i]})
    });
}
 
console.log(zip([str2, str4]));   ==> [["0", "1"], ["0", "1"], ["0", "1"], ["1", "1"], ["1", "1"], ["1", "1"]]

bb = zip([str2, str4]).map(function(obj){ return (obj[0] != obj[1]); })

console.log(bb);    ==> [true, true, true, false, false, false]

이전 1 다음