7
我意外地寫了一個錯誤的JavaScript語法(我認爲是這樣)。爲什麼瀏覽器不會拋出語法錯誤的異常?
代碼
var temp = {};
temp.a = 34;
height:34, //should fail here.
temp.b = 56;
是語法是正確的?
謝謝。
我意外地寫了一個錯誤的JavaScript語法(我認爲是這樣)。爲什麼瀏覽器不會拋出語法錯誤的異常?
代碼
var temp = {};
temp.a = 34;
height:34, //should fail here.
temp.b = 56;
是語法是正確的?
謝謝。
冒號可用於label a statement,這就是發生在這裏的情況。代碼中沒有錯誤,它是有意的行爲。
編輯:better resource標籤上。 :)
像'goto' yay – Aesthete
最好的結果應該是[這一個](http://es5.github.com/#x12.12) – Alexander