0
我有一個數組持有各種通知,其中包括他們各自的標題和描述。我想通過它的標題訪問特定的通知,但我似乎無法在數組中找到匹配項,即使應該有。JS陣列沒有被正確訪問
NotificationMenu = function()
{
var NotificationItems = new Array();
this.Application = function(title, description, functionName)
{
this.mTitle = title;
this.mDescription = description;
this.mFunction = functionName;
this.mIsActive = true;
}
this.registerNotification = function(title, description, functionName)
{
NotificationItems.push(new this.Application(title, description, functionName));
}
this.activateNotification = function(title)
{
console.log("-NotificationMenu: Activating notification " + title);
// Check through the list of notifications for the one called to be shown
for(var i = 0; i < NotificationItems.length; ++i)
{
if (NotificationItems[i].mName === title)
{
// This is never getting called
console.log("-NotificationMenu: Successful entry");
}
}
}
}
我訪問我的數組的方式有什麼問題,使它無法匹配兩個標題?特別是行if(NotificationItems[i].mName === title)
不會返回true
。
* bonks head * Doing!這就是它,天哪,謝謝!這是小事情,有時需要新的眼睛趕上 – Briz 2012-01-04 17:41:50
@Briz這就是所謂的代碼失明。 – 2012-01-04 19:27:11