如何优化此代码? Java脚本

时间:2019-07-18 07:32:55

标签: javascript optimization refactoring

可以优化此代码吗?我认为它可以优化,我不知道如何。

function changeType(value) {
    if (value === "Oracle") {
        if (!this.dbForm.port || this.dbForm.port === '3306') {
            this.dbForm.port = '1521';
        }
        if (!this.dbForm.db || this.dbForm.db === 'root') {
            this.dbForm.db = 'orcl';
        }
    }
    else if (value === "Mysql") {
        if (!this.dbForm.port || this.dbForm.port === '1521') {
            this.dbForm.port = '3306'
        }
        if (!this.dbForm.db || this.dbForm.db === 'orcl') {
            this.dbForm.db = 'root';
        }
    }
}

0 个答案:

没有答案