我可以做在Javascript東西,機器會自動改變這個:總是轉換爲對象
var x = 0;
爲以下(但只在memory--我不想改變「查看源文件」):
var x = {Value: 0};
對於爲例:
var x = { Value: 0 };
function a(x) //This function doesn't work if the parameter is not an object, and it would be better if I didn't have to write { Value: 0 }
{
x.Value++;
}
a(x);
alert(x.Value);
你能不能給我們的,你會如何用一個例子那? – georg 2012-04-22 09:11:18
「如果我不必寫」需要對象的對象,那會更好?!?只需在函數中使用'typeof x' – Aprillion 2012-04-22 09:21:26
否,我的意思是變量仍然是一個對象,但對象的聲明是自動的 – user1342369 2012-04-22 09:23:51