Javascript 字符串对象比较始终返回false

Javascript 字符串对象比较始终返回false,javascript,Javascript,以下是我正在执行的代码: filterIssues: function(objectKey, text){ var view = this; var keys = objectKey.split("."); var attributeKey = keys[0]; var attributeName; if (keys.length > 1){ attributeName = keys[1]; } view.issues

以下是我正在执行的代码:

filterIssues: function(objectKey, text){
    var view = this;
    var keys = objectKey.split(".");
    var attributeKey = keys[0];
    var attributeName;
    if (keys.length > 1){
        attributeName = keys[1];
    }
    view.issues.each(function(issue){
        var value = issue.get(attributeKey);
        console.log(text);

        if (value === undefined || value === null){
            issue.trigger("hide");
            return;
        }

        if (attributeName !== undefined){
            value = value[attributeName];
        }

        if(value !== undefined){
            var matchedText = value.substring(0, text.length - 1);
            if ( matchedText === text){
                issue.trigger("show");
                console.log(value);  
                return;     
            }
        }
        issue.trigger("hide");
    });
}     
matchedText==text
始终返回
false

这是我玩游戏机时得到的结果:

> matchedText
"sande"
> text
"sande"
> typeof(text)
"string"
> typeof(matchedText)
"string"
> matchedText === text
false
> matchedText == text
false
我确实意识到and
==
将始终检查两个对象是否相同,以及我是否阅读过 和


我忽略的代码中是否有错误?

我认为您误用了
subString()
方法。如果使用
subString()
,请使用不带-1的长度

我终于发现了问题所在。谢谢你的回答,我相信你可能没有找到答案,因为缺乏信息


问题在于我传递给函数的
文本
值。
文本
末尾包含一个
,这就是为什么比较不起作用

检查
matchedText.length
text.length
。什么类型的对象是
问题
以及
问题是什么。每个()
传递给函数(即什么是
问题
)?
issue.get()
返回什么?可能是栅栏柱错误
var matchedText=value.substring(0,text.length-1)是否尝试不使用-1?
matchedText.valueOf()==text.valueOf()
或with(=)给了您什么?您是否检查了trim()@James
matchedText.toString()==text.toString()
返回
false
==
我更改了长度,但没有-1,仍然是原来的长度。使用length-1肯定是错误的。子字符串的长度必须与caparison的文本长度相同,不能小于1。还是一样的问题。