你也沒有必要使用new Array(),使用[]; 不要使用 new Number, new String, or new Boolean. 等等 不要使用new Function 來創建函數 比如你要寫 代碼如下: frames[0].onfocus = new Function("document.bgColor='antiquewhite'")
你應該這樣寫 代碼如下: frames[0].onfocus = function () {document.bgColor = 'antiquewhite';};,
第二種寫法可以使得編譯器盡早的看到函數體。使得錯誤盡快的檢查出來。 當你寫 Js代碼 代碼如下: myObj = new function () { this.type = 'core'; };