SOURCE

function brecketMatch(str){
    if(str.lenttgh<2){
        return false
    }
    let len = str.length;
    let leftBrecket = '([{';
    let rightBrecket = ')]}';
    let stack = []  
    for(let i =0; i<len; i++){
        let s = str[i];
        if(leftBrecket.indexOf(s)>-1){
            stack.push(s)
        }
        if(rightBrecket.indexOf(s)>-1){
            let top = stack[stack.length-1];
            if(isMatch(top, s)){
                stack.pop()
            }else{
                return false
            }
        }
    }
    return stack.length === 0;
}

function isMatch(left, right){
    if(left === '(' && right===")"){
        return true
    }
     if(left === '[' && right==="]"){
        return true
    }
     if(left === '{' && right==="}"){
        return true
    }
    return false
}

let res = brecketMatch('{{{{{{}}}}}}}')
console.log(res);
console 命令行工具 X clear

                    
>
console