编辑代码

function getType(val) {
    let type = typeof val;
    if (type === 'object') {
        const typeStr = Object.prototype.toString.call(val).split(' ')[1];
        type = typeStr.substr(0, typeStr.length - 1);
    }
    return type;
}

const res = getType([]);

console.log(res);