国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > JS > 正文

this[] 指的是什么內容 討論

2024-09-06 12:42:51
字體:
來源:轉載
供稿:網友
代碼
theMonths = new MakeArray(12)   
// load array with English month names   
function MakeArray(n) {   
this[0] = "anuary"  
this[1] = "February"  
this[2] = "March"  
this[3] = "April"  
this[4] = "May"  
this[5] = "June"  
this[6] = "July"  
this[7] = "August"  
this[8] = "September"  
this[9] = "October"  
this[10] = "November"  
this[11] = "December"  
this.length = n   
return this  
}   
這個是Java Script Bible 4th Edition上面的一段代碼. 
這種this的用法 是怎么個意思?javascript的this還有匿名obj的作用? 
這樣的用法只能限于函數內部吧
拋出異常的愛 寫道
這樣就可以在別的地方用
代碼
var my = new Object ();   
my.MakeArray= MakeArray;   
my.MakeArray(10);  
的確看到一個類似的用法 
代碼
// create basic array   
theMonths = new MakeArray(12)  
如果this[]的用法,表示this是一個array object 
那么 
代碼
this.length = n  
這個似乎讓this又成為了一個擁有一個array object 和一個 int 變量的 object了 
this于是看上去像某個匿名class的object了 
是否可以這樣理解呢?
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 横峰县| 广丰县| 屏南县| 德昌县| 德惠市| 寻乌县| 磐安县| 五河县| 饶河县| 济南市| 南和县| 隆化县| 通化市| 花莲县| 沾化县| 吴堡县| 鲁山县| 马山县| 五家渠市| 巴塘县| 腾冲县| 包头市| 天津市| 登封市| 营山县| 当雄县| 涪陵区| 嘉祥县| 砚山县| 平遥县| 泸州市| 宁城县| 犍为县| 黄平县| 东山县| 南召县| 甘谷县| 洞口县| 阳原县| 琼海市| 偏关县|