I have an object, with some properties in it, and as I'm trying to compare a given string property of this object, waiting for the compared result is true I got false !
Adding an empty string to the property (create a new String) and give the result I was waiting for.
Cann somebody explain me why can't I compare Strings-properties of Objects directly without using a "modified-copy" of it?
(code verified on jsbin.com : https://jsbin.com/kojehinexe/edit?js,console)
var hohoho = { "testCallback_abc": {
"abc": {
"addToNumber": {
"executed": true,
"returnedExecutionValue": [42]
},
"addToArray": {
"executed": true
},
"addToObject": {
"executed": true
},
"returnATestValue": {
"executed": true,
"returnedExecutionValue": ["testValue"]
}
}
}
}
var testString = "testValue";
console.log(hohoho.testCallback_abc.abc.returnATestValue.returnedExecutionValue === testString); // return false
console.log(hohoho.testCallback_abc.abc.returnATestValue.returnedExecutionValue+"" === testString); // return true