用<和>比较两个对象

时间:2020-02-09 18:31:33

标签: angular typescript

检查对象是否大于另一个对象时使用哪种方法?我试图实现一个compareTo方法,但是它仅在比较Objects是否等于(=)时才使用。

例如

export class Check {
    check: string;
}
export class Test {
    constructor() {
        const c1 = new Check(),
        c1.check = '1-';
        const c2 = new Check(),
        c2.check = '1';
        console.log(c1 < c2); // returns false but in my case it should be true because 1- is not as good as 1
    }
}

0 个答案:

没有答案
相关问题