我有兩部分問題。將值嵌套在對象中並與變量值進行比較
1)我需要訪問一個嵌套在複雜對象中的唯一值列表。我能夠輸出的對象經由console.log
這樣:
console.log(dataStore);
此輸出下面的(部分):
`Object
getResponses: function getResponses(ids)
arguments: null
caller: null
length: 1
name: "getResponses"
prototype: Object
__proto__: function()
<function scope>
Closure
responseCache: Object
12345: gr.Response
12346: gr.Response
etc...
getImg: function (imageId)
etc... `
我需要集responseCache
下數字的值的列表的呼叫: 12345,12346,12347等。這些值的總量可能非常大。可能是10,可能是100的列表中。
2)我需要創建一個條件語句來比較不屬於上述對象的變量的值。例如:如果
variableX = variableXvalue;
if ("variableXvalue" is one of the unique values in "responseCache") {
//then do this
}
不知道它的問題在這裏的問題的目的,但variableX
是一個循環,遍歷網頁上的屬性。它遍歷頁面上所有匹配的標記/屬性,並且每次循環時都需要將這些屬性值與完整的值列表responseCache
進行比較。
謝謝你考慮這個問題。
這只是你的開發工具對你很好。你不能訪問'responseCache'。它在封閉的內部。它實際上是一個私有變量。 –