Sunday, 15 September 2013

Getting true from the if statement which should return false

Getting true from the if statement which should return false

I'm building a chrome extension right now.
I'm almost done with building my extension, but I'm getting a weird problem.
I'm getting true from the if statement which should return false.
This is the code I'm working on right now.
var background = new Background();
chrome.runtime.onStartup.addListener(function(){
if(background.getStorage("track-mode").resetFlag == "success"){
var trackMode = background.getStorage("track-mode");
trackMode.resetFlag = "neutral";
background.setStorage("track-mode", trackMode);
//(1)It outputs "neutral" here in alert window as I expect.
alert(background.getStorage("track-mode").resetFlag);
//(2)It outputs true here. I'm expecting false here!
alert(background.getStorage("track-mode").resetFlag == "success");
//(3)It outputs false here. I'm expecting true here!
alert(background.getStorage("track-mode").resetFlag !== "success");
}
})
Please take a look at this code and please tell me if you find out what's
causing this problem.
Thanks!

No comments:

Post a Comment