JAvascript==演算子のコード解釈


JAvascript==演算子のコード解釈


問題のコードのように
function equal(a, b){
    if( a === null && b === undefined){
        return true;
    }else if(a === undefined && b === null){
        return true;
    }
    if(typeof a === "boolean" || typeof b === "boolean") {
        if (typeof a === "boolean") {
            if (a === true) {
                a = 1;
            } else {
                a = 0;
            }
        }
        if (typeof b === "boolean") {
            if (b === true) {
                b = 1;
            } else {
                b = 0;
            }
        }
    }
    else if(typeof a === "string" && typeof b === "number"){
        a = Number(a);
    }
    else if(typeof a === "number" && typeof b === "string"){
        b = Number(b);
    }

    return a === b;


}


関数equal()は==演算子に等しい.