1
lol.lewl = {
value: 'something',
anotherValue: lol.lewl.value+' and something else'
}
看到this,沒有回答。我認爲你知道我在這裏要做什麼,我得到:爲同一對象內的另一個值計算JSON對象值
TypeError: Cannot read property of undefined
lol.lewl = {
value: 'something',
anotherValue: lol.lewl.value+' and something else'
}
看到this,沒有回答。我認爲你知道我在這裏要做什麼,我得到:爲同一對象內的另一個值計算JSON對象值
TypeError: Cannot read property of undefined
你不能那樣做。你正在申報lol.lewl
,所以它不知道那是什麼。
你必須這樣做:
lol.lewl = {
value: 'something'
};
lol.lewl.anotherValue = lol.lewl.value+' and something else';
良好的探索,完美! –
不客氣:-) –
爲什麼不創建後'lol.lewl'只是分配'anotherValue'?如:'lol.lewl = {value:「something」}; lol.lewl.anotherValue = lol.lewl.value +'和別的東西'? – SimpleJ
@SimpleJ Gotcha! –