[英]not able to understand this javascript code
我是 javascript 的新人,我必須了解一個 appcelerator 項目。 在 appcelerator 中,我們需要編寫 java 腳本。
var winForm = (function() {
var API = {};
API.list = [
{
title:'title1', hasChild:true, color:'#9B0B0B',font:'font'
},
{
title:'title2', hasChild:true, color:'#9B0B0B',font:'font'
},
{
title:'title3', hasChild:true, color:'#9B0B0B',font:'font'
}
];//end winList
return API;
})(); //end
module.exports = winForm;
抱歉在一個帖子里問了這么多問題。
list
被設置為由 3 個對象組成的數組(即[... ]
表示法)。 每個 object 都有 4 個屬性, title
、 hasChild
、 color
和font
,具有各自的值。winForm
中(然后存儲在module.exports
中)。module
object 上的某些屬性,無論它是什么。您應該花時間詳細了解 javascript 的工作原理。 我推薦http://javascript.info/作為一個很好的提升。
1) function 是variable = (function() {}())
形式的立即匿名自執行表達式 function
2) API 被初始化為一個 object(或哈希表),它的 scope 在 function 里面
3) API.list 是一個對象數組,每個對象包含四對key:value
4) Function 是自執行的,所以當您返回 API object 時,您將其分配給 winForm 變量
5) winForm
是返回object, winForm.list
是數組。
因為你分配module.exports = winForm;
那么module.exports.list
就是你的數組
1.This function is called as anonymous function or rather you can say self executing function
2.It is creating an empty object
3.API.list is array of the object .. To define array [ ] these brackets are used and for object { }.
4. You are using the return function .. and the result is getting stored in module.export
5. Export is the method name .. There has to be a method object define somewhere in js . you can you this method to get your result
as in the winForm function and used for some purpose
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.